zincjs 1.2.0 → 1.3.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/CHANGELOG.md +9 -37
- package/build/zinc.frontend.js +1 -1
- package/build/zinc.js +45 -17
- package/build/zinc.js.map +1 -1
- package/package.json +2 -2
- package/src/assets/mapMarker.svg +1 -1
- package/src/controls.js +2 -2
- package/src/primitives/marker.js +3 -2
- package/src/primitives/textureSlides.js +126 -46
- package/src/primitives/zincObject.js +1 -1
- package/src/shaders/textureSlide.js +6 -4
package/build/zinc.js
CHANGED
|
@@ -253,7 +253,7 @@ var THREE=__webpack_require__(3),THREEGeometry=__webpack_require__(5).Geometry,u
|
|
|
253
253
|
*
|
|
254
254
|
* @return {Boolean}
|
|
255
255
|
*/ //Update the geometry and colours depending on the morph.
|
|
256
|
-
ZincObject.prototype.setMorphTime=function(time){var timeChanged=!1;if(this.clipAction){var ratio=time/this.duration,actualDuration=this.clipAction._clip.duration,newTime=ratio*actualDuration;newTime!=this.clipAction.time&&(this.clipAction.time=newTime,timeChanged=!0),timeChanged&&this.isTimeVarying()&&this.mixer.update(0)}else{var _newTime=time;_newTime=time>this.duration?this.duration:0>time?0:time,_newTime!=this.inbuildTime&&(this.inbuildTime=_newTime,timeChanged=!0)}timeChanged&&(this.boundingBoxUpdateRequired=!0,updateMorphColorAttribute(this.geometry,this.morph),this.timeEnabled&&(this.markerUpdateRequired=!0))},ZincObject.prototype.isTimeVarying=function(){return!!(this.timeEnabled||this.morphColour)},ZincObject.prototype.getVisibility=function(){return
|
|
256
|
+
ZincObject.prototype.setMorphTime=function(time){var timeChanged=!1;if(this.clipAction){var ratio=time/this.duration,actualDuration=this.clipAction._clip.duration,newTime=ratio*actualDuration;newTime!=this.clipAction.time&&(this.clipAction.time=newTime,timeChanged=!0),timeChanged&&this.isTimeVarying()&&this.mixer.update(0)}else{var _newTime=time;_newTime=time>this.duration?this.duration:0>time?0:time,_newTime!=this.inbuildTime&&(this.inbuildTime=_newTime,timeChanged=!0)}timeChanged&&(this.boundingBoxUpdateRequired=!0,updateMorphColorAttribute(this.geometry,this.morph),this.timeEnabled&&(this.markerUpdateRequired=!0))},ZincObject.prototype.isTimeVarying=function(){return!!(this.timeEnabled||this.morphColour)},ZincObject.prototype.getVisibility=function(){return!!this.morph&&this.morph.visible},ZincObject.prototype.setVisibility=function(visible){this.morph.visible!==visible&&(this.morph.visible=visible,this.region&&(this.region.pickableUpdateRequired=!0))},ZincObject.prototype.setAlpha=function(alpha){var material=this.morph.material,isTransparent=!1;1>alpha&&(isTransparent=!0);var transparentChanged=material.transparent!=isTransparent;material.opacity=alpha,material.transparent=isTransparent,transparentChanged&&(isTransparent?this.checkAndCreateTransparentMesh():this.checkAndRemoveTransparentMesh()),this.secondaryMesh&&this.secondaryMesh.material&&(this.secondaryMesh.material.opacity=alpha)},ZincObject.prototype.setFrustumCulled=function(flag){this.morph&&(this.morph.frustumCulled=flag)},ZincObject.prototype.setVertexColors=function(vertexColors){this.morph.material.vertexColors=vertexColors,this.geometry.colorsNeedUpdate=!0,this.secondaryMesh&&this.secondaryMesh.material&&(this.secondaryMesh.material.vertexColors=vertexColors)},ZincObject.prototype.getColour=function(){return this.morph&&this.morph.material?this.morph.material.color:void 0},ZincObject.prototype.setColour=function(colour){this.morph.material.color=colour,this.secondaryMesh&&this.secondaryMesh.material&&(this.secondaryMesh.material.color=colour),this.geometry.colorsNeedUpdate=!0},ZincObject.prototype.getColourHex=function(){return!this.morphColour&&this.morph&&this.morph.material&&this.morph.material.color?this.morph.material.color.getHexString():void 0},ZincObject.prototype.setColourHex=function(hex){this.morph.material.color.setHex(hex),this.secondaryMesh&&this.secondaryMesh.material&&this.secondaryMesh.material.color.setHex(hex)},ZincObject.prototype.setMaterial=function(material){this.morph.material=material,this.geometry.colorsNeedUpdate=!0,this.secondaryMesh&&this.secondaryMesh.material&&(this.secondaryMesh.material.dispose(),this.secondaryMesh.material=material.clone(),this.secondaryMesh.material.side=THREE.FrontSide)},ZincObject.prototype.getClosestVertexIndex=function(){var closestIndex=-1;if(this.morph){var position=this.morph.geometry.attributes.position,boundingBox=new THREE.Box3().setFromBufferAttribute(position),center=new THREE.Vector3;if(boundingBox.getCenter(center),position&&boundingBox)for(var distance=-1,currentDistance=0,current=new THREE.Vector3,i=0;i<position.count;i++)current.fromArray(position.array,3*i),currentDistance=current.distanceTo(center),-1==distance?distance=currentDistance:distance>currentDistance&&(distance=currentDistance,closestIndex=i)}return closestIndex},ZincObject.prototype.getClosestVertex=function(applyMatrixWorld){var position=new THREE.Vector3;if(-1==this.closestVertexIndex&&(this.closestVertexIndex=this.getClosestVertexIndex()),0<=this.closestVertexIndex){var influences=this.morph.morphTargetInfluences,attributes=this.morph.geometry.morphAttributes;if(influences&&attributes&&attributes.position){for(var found=!1,i=0;i<influences.length;i++)0<influences[i]&&(found=!0,this._vertex.fromArray(attributes.position[i].array,3*this.closestVertexIndex),position.add(this._vertex.multiplyScalar(influences[i])));if(found)return applyMatrixWorld?position.applyMatrix4(this.morph.matrixWorld):position}else return position.fromArray(this.morph.geometry.attributes.position.array,3*this.closestVertexIndex),applyMatrixWorld?position.applyMatrix4(this.morph.matrixWorld):position}return this.getBoundingBox().getCenter(position),applyMatrixWorld?position.applyMatrix4(this.morph.matrixWorld):position},ZincObject.prototype.getBoundingBox=function(){if(this.morph&&this.morph.visible){if(this.boundingBoxUpdateRequired){var influences=this.morph.morphTargetInfluences,attributes=void 0;this.morph.geometry&&(attributes=this.morph.geometry.morphAttributes);var found=!1;if(influences&&attributes&&attributes.position){for(var min=new THREE.Vector3,max=new THREE.Vector3,box=new THREE.Box3,i=0;i<influences.length;i++)0<influences[i]&&(found=!0,box.setFromArray(attributes.position[i].array),min.add(box.min.multiplyScalar(influences[i])),max.add(box.max.multiplyScalar(influences[i])));found&&this.cachedBoundingBox.set(min,max)}found||this.cachedBoundingBox.setFromBufferAttribute(this.morph.geometry.attributes.position),this.morph.updateWorldMatrix(),this.cachedBoundingBox.applyMatrix4(this.morph.matrixWorld),this.boundingBoxUpdateRequired=!1}return this.cachedBoundingBox}},ZincObject.prototype.dispose=function(){this.morph&&this.morph.geometry&&this.morph.geometry.dispose(),this.morph&&this.morph.material&&this.morph.material.dispose(),this.secondaryMesh&&this.secondaryMesh.material&&this.secondaryMesh.material.dispose(),this.geometry&&this.geometry.dispose(),this.animationGroup=void 0,this.mixer=void 0,this.morph=void 0,this.clipAction=void 0,this.groupName=void 0},ZincObject.prototype.markerIsEnabled=function(options){return!!("on"===this.markerMode||options&&options.displayMarkers&&"inherited"===this.markerMode)},ZincObject.prototype.updateMarker=function(playAnimation,options){if(!(!1==playAnimation&&this.markerIsEnabled(options)))this.marker&&this.marker.isEnabled()&&(this.marker.disable(),this.morph.remove(this.marker.morph)),this.markerUpdateRequired=!0;else if(this.groupName){if(this.marker||(this.marker=new(__webpack_require__(7).Marker)(this),this.markerUpdateRequired=!0),this.markerUpdateRequired){var position=this.getClosestVertex(!1);position&&(this.marker.setPosition(position.x,position.y,position.z),this.markerUpdateRequired=!1)}options&&options.camera&&options.markerDepths&&options.markerDepths.push(this.marker.updateNDC(options.camera.cameraObject)),this.marker.isEnabled()||(this.marker.enable(),this.morph.add(this.marker.morph))}},ZincObject.prototype.processMarkerVisual=function(min,max){this.marker&&this.marker.isEnabled()&&this.marker.updateVisual(min,max)},ZincObject.prototype.initiateMorphColor=function(){1==this.morphColour&&"undefined"!=typeof this.geometry&&(this.morph.material.vertexColors==THREE.VertexColors||!0==this.morph.material.vertexColors)&&updateMorphColorAttribute(this.geometry,this.morph)},ZincObject.prototype.setRenderOrder=function(renderOrder){this.morph&&renderOrder!==void 0&&(this.morph.renderOrder=renderOrder,this.secondaryMesh&&(this.secondaryMesh.renderOrder=this.morph.renderOrder+1))},ZincObject.prototype.getClosestVertexDOMElementCoords=function(scene){if(scene&&scene.camera){var inView=!0,position=this.getClosestVertex(!0);return position.project(scene.camera),position.z=Math.min(Math.max(position.z,0),1),(1<position.x||-1>position.x||1<position.y||-1>position.y)&&(inView=!1),scene.getZincCameraControls().getRelativeCoordsFromNDC(position.x,position.y,position),{position,inView}}},ZincObject.prototype.setMarkerMode=function(mode){mode!==this.markerMode&&(this.markerMode="on"===mode||"off"===mode?mode:"inherited",this.region&&(this.region.pickableUpdateRequired=!0))},ZincObject.prototype.render=function(delta,playAnimation,options){if(!0==playAnimation){if(this.clipAction&&this.isTimeVarying())this.mixer.update(delta);else{var targetTime=this.inbuildTime+delta;targetTime>this.duration&&(targetTime-=this.duration),this.inbuildTime=targetTime}0!=delta&&(this.boundingBoxUpdateRequired=!0,1==this.morphColour&&"undefined"!=typeof this.geometry&&(this.morph.material.vertexColors==THREE.VertexColors||!0==this.morph.material.vertexColors)&&updateMorphColorAttribute(this.geometry,this.morph))}this.updateMarker(playAnimation,options)},exports.ZincObject=ZincObject;
|
|
257
257
|
|
|
258
258
|
/***/ }),
|
|
259
259
|
/* 5 */
|
|
@@ -392,7 +392,7 @@ var THREE=__webpack_require__(3),markerImage=new Image(128,128);markerImage.src=
|
|
|
392
392
|
*/ /**
|
|
393
393
|
* Disable and hide the marker.
|
|
394
394
|
*/ //this should be handle by scene... check the sync at
|
|
395
|
-
this.updateVisual=(min,max)=>{var scale=1,opacity=1,porportion=0;min!==max&&(porportion=1-(vector.z-min)/(max-min),scale=.5+.5*porportion,opacity=.6+.4*porportion),sprite.material.opacity=opacity,this.setSpriteSize(scale)},this.updateNDC=camera=>(vector.copy(this.morph.position),vector.project(camera),vector.z=Math.min(Math.max(vector.z,0),1),vector.z),this.setPosition=(x,y,z)=>{this.morph.position.set(x,y,z)},this.setSpriteSize=size=>{sprite.scale.set(.015,.02,1),sprite.scale.multiplyScalar(size)},this.dispose=()=>{this.morph&&this.morph.
|
|
395
|
+
this.updateVisual=(min,max)=>{var scale=1,opacity=1,porportion=0;min!==max&&(porportion=1-(vector.z-min)/(max-min),scale=.5+.5*porportion,opacity=.6+.4*porportion),sprite.material.opacity=opacity,this.setSpriteSize(scale)},this.updateNDC=camera=>(vector.copy(this.morph.position),vector.project(camera),vector.z=Math.min(Math.max(vector.z,0),1),vector.z),this.setPosition=(x,y,z)=>{this.morph.position.set(x,y,z)},this.setSpriteSize=size=>{sprite.scale.set(.015,.02,1),sprite.scale.multiplyScalar(size)},this.dispose=()=>{this.morph&&this.morph.clear(),spriteMaterial&&spriteMaterial.dispose(),sprite&&(sprite.clear(),sprite=void 0)},this.isEnabled=()=>enabled,this.enable=()=>{enabled=!0,this.morph.visible=!0},this.disable=()=>{enabled=!1,this.morph.visible=!1},initialise()};/**
|
|
396
396
|
* A special graphics type with a tear drop shape.
|
|
397
397
|
* It is currently used to mark the location of a
|
|
398
398
|
* {@link zincObject}.
|
|
@@ -406,7 +406,7 @@ this.updateVisual=(min,max)=>{var scale=1,opacity=1,porportion=0;min!==max&&(por
|
|
|
406
406
|
/* 8 */
|
|
407
407
|
/***/ (function(module, exports) {
|
|
408
408
|
|
|
409
|
-
module.exports = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxOC4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgMzY1IDU2MCIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMzY1IDU2MCIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+
|
|
409
|
+
module.exports = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxOC4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgMzY1IDU2MCIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMzY1IDU2MCIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8Zz4NCgk8cGF0aCBmaWxsPSIjMDA1OTc0IiBkPSJNMTgyLjksNTUxLjdjMCwwLjEsMC4yLDAuMywwLjIsMC4zUzM1OC4zLDI4MywzNTguMywxOTQuNmMwLTEzMC4xLTg4LjgtMTg2LjctMTc1LjQtMTg2LjkNCgkJQzk2LjMsNy45LDcuNSw2NC41LDcuNSwxOTQuNmMwLDg4LjQsMTc1LjMsMzU3LjQsMTc1LjMsMzU3LjRTMTgyLjksNTUxLjcsMTgyLjksNTUxLjd6IE0xMjIuMiwxODcuMmMwLTMzLjYsMjcuMi02MC44LDYwLjgtNjAuOA0KCQljMzMuNiwwLDYwLjgsMjcuMiw2MC44LDYwLjhTMjE2LjUsMjQ4LDE4Mi45LDI0OEMxNDkuNCwyNDgsMTIyLjIsMjIwLjgsMTIyLjIsMTg3LjJ6Ii8+DQo8L2c+DQo8L3N2Zz4NCg=="
|
|
410
410
|
|
|
411
411
|
/***/ }),
|
|
412
412
|
/* 9 */
|
|
@@ -813,26 +813,54 @@ function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var inf
|
|
|
813
813
|
/* 25 */
|
|
814
814
|
/***/ (function(module, exports, __webpack_require__) {
|
|
815
815
|
|
|
816
|
-
var THREE=__webpack_require__(3),shader=__webpack_require__(26),TextureSlides=function(textureIn){
|
|
816
|
+
var THREE=__webpack_require__(3),shader=__webpack_require__(26),TextureSlides=function(textureIn){__webpack_require__(27).TexturePrimitive.call(this,textureIn),this.isTextureSlides=!0;var textureSettings=[],idTextureMap={};this.morph=new THREE.Group,this.morph.userData=this;/**
|
|
817
817
|
@typedef SLIDE_SETTINGS
|
|
818
818
|
@type {Set}
|
|
819
819
|
@property {String} direction - the value must be x, y or z, specify the
|
|
820
820
|
direction the slide should be facing.
|
|
821
821
|
@property {Number} value - Normalised value of the location on direction.
|
|
822
|
+
@property {String} id - ID of the mesh, it is only available if the settings
|
|
823
|
+
is returned from {@link TextureSlides.createSlide} or
|
|
824
|
+
{@link TextureSlides.getTextureSettings}.
|
|
822
825
|
*/ /**
|
|
823
826
|
* Create the slides required for visualisation based on the slide settings.
|
|
824
|
-
* The slides
|
|
827
|
+
* The slides themselves are {THREE.PlanGeometry} objects.
|
|
825
828
|
*
|
|
826
829
|
* @param {SLIDE_SETTINGS} slideSettings - An array to each slide settings.
|
|
827
830
|
*/ /**
|
|
831
|
+
* Set the value of the uniforms for a specific mesh in this
|
|
832
|
+
* texture slide object.
|
|
833
|
+
*
|
|
834
|
+
* @param {THREE.Mesh} mesh - Mesh to be modified
|
|
835
|
+
* @param {SLIDE_SETTINGS} slideSettings - Slide settings.
|
|
836
|
+
*/ /**
|
|
837
|
+
* Modify the mesh based on a setting
|
|
838
|
+
*
|
|
839
|
+
* @param {SLIDE_SETTINGS} settings - s.
|
|
840
|
+
*/ /**
|
|
841
|
+
* Create a slide required for visualisation based on the slide settings.
|
|
842
|
+
* The slide itself is an {THREE.PlanGeometry} object.
|
|
843
|
+
*
|
|
844
|
+
* @param {SLIDE_SETTINGS} settings -settings of the slide to be created.
|
|
845
|
+
* @return {SLIDE_SETTINGS} - Returned settings, it includes the newly
|
|
846
|
+
* created mesh's id.
|
|
847
|
+
*/ /**
|
|
848
|
+
* Return a copy of texture settings used by this object.
|
|
849
|
+
*
|
|
850
|
+
* @return {SLIDE_SETTINGS} - Returned the list of settings..
|
|
851
|
+
*/ /**
|
|
828
852
|
* Get the array of slides, return them in an array
|
|
829
853
|
*
|
|
830
854
|
* @return {Array} - Return an array of {@link THREE.Object)
|
|
831
855
|
*/ /**
|
|
832
856
|
* Remove a slide, this will dispose the slide and its material.
|
|
833
857
|
*
|
|
834
|
-
* @param {Slide} slide -
|
|
858
|
+
* @param {Slide} slide - Slide to be remvoed
|
|
835
859
|
*/ /**
|
|
860
|
+
* Remove a slide, this will dispose the slide and its material.
|
|
861
|
+
*
|
|
862
|
+
* @param {Number} id - id of slide to be remvoed
|
|
863
|
+
*/ /**
|
|
836
864
|
* Clean up all internal objects.
|
|
837
865
|
*/ /**
|
|
838
866
|
* Get the bounding box of this slides.
|
|
@@ -840,13 +868,13 @@ var THREE=__webpack_require__(3),shader=__webpack_require__(26),TextureSlides=fu
|
|
|
840
868
|
* transformation to calculate the position of the box.
|
|
841
869
|
*
|
|
842
870
|
* @return {THREE.Box3}.
|
|
843
|
-
*/
|
|
871
|
+
*/this.createSlides=slideSettings=>{slideSettings.forEach(slide=>this.createSlide(slide))},setUniformSlideSettingsOfMesh=(mesh,settings)=>{var material=mesh.material,uniforms=material.uniforms;switch(settings.direction){case"x":uniforms.direction.value=1,uniforms.slide.value.set(settings.value,0,0);break;case"y":uniforms.direction.value=2,uniforms.slide.value.set(0,settings.value,0);break;case"z":uniforms.direction.value=3,uniforms.slide.value.set(0,0,settings.value);break;default:}material.needsUpdate=!0,this.boundingBoxUpdateRequired=!0},this.modifySlideSettings=settings=>{settings&&settings.id&&settings.id in idTextureMap&&idTextureMap[settings.id]&&setUniformSlideSettingsOfMesh(idTextureMap[settings.id],settings)},this.createSlide=settings=>{if(this.texture&&this.texture.isTextureArray&&this.texture.isReady()&&settings&&settings.direction&&void 0!==settings.value){var geometry=new THREE.PlaneGeometry(1,1);geometry.translate(.5,.5,0);var uniforms=shader.getUniforms();uniforms.diffuse.value=this.texture.impl,uniforms.depth.value=this.texture.size.depth;var options={fs:shader.fs,vs:shader.vs,uniforms:uniforms,glslVersion:shader.glslVersion,side:THREE.DoubleSide,transparent:!1},material=this.texture.getMaterial(options);material.needsUpdate=!0;var mesh=new THREE.Mesh(geometry,material),slideSettings={value:settings.value,direction:settings.direction,id:mesh.id};return textureSettings.push(slideSettings),setUniformSlideSettingsOfMesh(mesh,slideSettings),idTextureMap[mesh.id]=mesh,this.morph.add(mesh),slideSettings}},this.getTextureSettings=()=>[...textureSettings],this.getSlides=()=>this.morph?[...this.morph.children]:[],this.removeSlide=slide=>{slide&&this.removeSlideWithId(slide.id)},this.removeSlideWithId=id=>{if(this.morph&&id in idTextureMap&&idTextureMap[id]){if(this.morph.getObjectById(id)){var slide=idTextureMap[id];this.morph.remove(slide),slide.clear(),slide.geometry&&slide.geometry.dispose(),slide.material&&slide.material.dispose(),this.boundingBoxUpdateRequired=!0}var index=textureSettings.findIndex(item=>item.id===id);-1<index&&textureSettings.splice(index)}},this.dispose=()=>{this.morph.children.forEach(slide=>{slide.geometry&&slide.geometry.dispose(),slide.material&&slide.material.dispose()}),__webpack_require__(27).TexturePrimitive.prototype.dispose.call(this),this.boundingBoxUpdateRequired=!0},this.getBoundingBox=function(){return this.morph&&this.morph.children&&this.morph.visible&&this.boundingBoxUpdateRequired&&(this.cachedBoundingBox.makeEmpty(),this.morph.children.forEach(slide=>{var value=slide.material.uniforms.slide.value;this.cachedBoundingBox.expandByPoint(value)}),this.morph.updateWorldMatrix(),this.cachedBoundingBox.applyMatrix4(this.morph.matrixWorld),this.boundingBoxUpdateRequired=!1),this.cachedBoundingBox}};TextureSlides.prototype=Object.create(__webpack_require__(27).TexturePrimitive.prototype),exports.TextureSlides=TextureSlides;
|
|
844
872
|
|
|
845
873
|
/***/ }),
|
|
846
874
|
/* 26 */
|
|
847
875
|
/***/ (function(module, exports, __webpack_require__) {
|
|
848
876
|
|
|
849
|
-
var THREE=__webpack_require__(3),glslVersion=THREE.GLSL3,fs="\nprecision highp float;\nprecision highp int;\nprecision highp sampler2DArray;\n\nuniform sampler2DArray diffuse;\nin vec3 vUw;\n\nout vec4 outColor;\n\nvoid main() {\n\n vec4 color = texture( diffuse, vUw );\n\n // lighten a bit\n outColor = vec4( color.rgb + .2, 1.0 );\n\n}\n",vs="\nout vec3 vUw;\nuniform float depth;\nuniform vec3 slide;\n\nvoid main() {\n\n vec3 slidePos = position.xyz;\n\n if (
|
|
877
|
+
var THREE=__webpack_require__(3),glslVersion=THREE.GLSL3,fs="\nprecision highp float;\nprecision highp int;\nprecision highp sampler2DArray;\n\nuniform sampler2DArray diffuse;\nin vec3 vUw;\n\nout vec4 outColor;\n\nvoid main() {\n\n vec4 color = texture( diffuse, vUw );\n\n // lighten a bit\n outColor = vec4( color.rgb + .2, 1.0 );\n\n}\n",vs="\nout vec3 vUw;\nuniform float depth;\nuniform vec3 slide;\nuniform int direction;\n\nvoid main() {\n\n vec3 slidePos = position.xyz;\n\n if (direction == 1)\n slidePos = vec3(slide.x, position.x, position.y);\n if (direction == 2)\n slidePos = vec3(position.x, slide.y, position.y);\n if (direction == 3)\n slidePos = vec3(position.x, position.y, slide.z);\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4( slidePos, 1.0 );\n\n vUw.xyz = vec3(slidePos.x, slidePos.y, slidePos.z * depth);\n\n}\n",getUniforms=function(){return{diffuse:{value:void 0},depth:{value:1},slide:{value:new THREE.Vector3(0,0,1)},direction:{value:1}}};exports.fs=fs,exports.vs=vs,exports.glslVersion=glslVersion,exports.getUniforms=getUniforms;
|
|
850
878
|
|
|
851
879
|
/***/ }),
|
|
852
880
|
/* 27 */
|
|
@@ -1573,7 +1601,7 @@ var handleSyncControl=()=>{this._state===STATE.ROTATE||this._state===STATE.TOUCH
|
|
|
1573
1601
|
* Disable syncControl.
|
|
1574
1602
|
*/this.update=timeChanged=>{var delta=timeChanged*playRate,controlEnabled=enabled;currentMode===MODE.PATH?updatePath(delta):currentMode===MODE.SMOOTH_CAMERA_TRANSITION&&smoothCameraTransitionObject?(smoothCameraTransitionObject.update(delta),smoothCameraTransitionObject.isTransitionCompleted()&&(smoothCameraTransitionObject==null,currentMode=MODE.DEFAULT),controlEnabled=!1):currentMode===MODE.ROTATE_CAMERA_TRANSITION&&rotateCameraTransitionObject?(rotateCameraTransitionObject.update(delta),rotateCameraTransitionObject.isTransitionCompleted()&&(rotateCameraTransitionObject==null,currentMode=MODE.DEFAULT),controlEnabled=!1):currentMode===MODE.AUTO_TUMBLE&&cameraAutoTumbleObject?cameraAutoTumbleObject.update(delta):currentMode===MODE.SYNC_CONTROL&&ndcControl&&(handleSyncControl(),controlEnabled=!1),controlEnabled&&(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?deviceOrientationControl.update():this.cameraObject.lookAt(this.cameraObject.target)},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 eye_distance=radius/Math.tan(view_angle*Math.PI/360),localEyePosition=[centreX+eyex*eye_distance,centreY+eyey*eye_distance,centreZ+eyez*eye_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=eye_distance+clip_distance,newViewport.eyePosition=localEyePosition,newViewport.targetPosition=[centreX,centreY,centreZ],newViewport.upVector=[this.cameraObject.up.x,this.cameraObject.up.y,this.cameraObject.up.z],newViewport},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(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,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(axisIn,angleIn,targetCameraIn,durationIn){var duration=durationIn,inbuildTime=0,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;targetCameraIn.rotateAboutLookAtpoint(axisIn,ratio*angleIn)};this.update=delta=>{!1===this.enabled||(updateCameraSettings(delta),inbuildTime==duration&&(completed=!0))},this.isTransitionCompleted=()=>completed},RayCaster=function(sceneIn,hostSceneIn,callbackFunctionIn,hoverCallbackFunctionIn,rendererIn){var scene=sceneIn,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),hostSceneIn!==scene){var threejsScene=scene.getThreeJSScene();renderer.render(threejsScene,zincCamera.cameraObject)}raycaster.setFromCamera(mouse,zincCamera.cameraObject);var objects=scene.getPickableThreeJSObjects();//Reset pickedObjects array
|
|
1575
1603
|
return pickedObjects.length=0,raycaster.intersectObjects(objects,!0,pickedObjects)};this.pick=(zincCamera,x,y)=>{enabled&&renderer&&scene&&zincCamera&&callbackFunction&&(getIntersectsObject(zincCamera,x,y),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
|
|
1576
|
-
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(tumbleDirectionIn,tumbleRateIn,stopOnCameraInputIn,targetCameraIn){var tumbleAxis=new THREE.Vector3,targetCamera=targetCameraIn;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(tumbleDirectionIn),this.requireUpdate=!1),targetCamera.rotateAboutLookAtpoint(tumbleAxis,-tumbleRateIn*delta/1e3))}}
|
|
1604
|
+
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(tumbleDirectionIn,tumbleRateIn,stopOnCameraInputIn,targetCameraIn){var tumbleAxis=new THREE.Vector3,targetCamera=targetCameraIn;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(tumbleDirectionIn),this.requireUpdate=!1),targetCamera.rotateAboutLookAtpoint(tumbleAxis,-tumbleRateIn*delta/1e3))}},StereoCameraZoomFixed=function(){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};Object.assign(StereoCameraZoomFixed.prototype,{update:(()=>{var focus,fov,aspect,near,far,zoom,eyeRight=new THREE.Matrix4,eyeLeft=new THREE.Matrix4;return function(camera){var needsUpdate=focus!==camera.focus||fov!==camera.fov||aspect!==camera.aspect*this.aspect||near!==camera.near||far!==camera.far||zoom!==camera.zoom;if(needsUpdate){focus=camera.focus,fov=camera.fov,aspect=camera.aspect*this.aspect,near=camera.near,far=camera.far,zoom=camera.zoom;// Off-axis stereoscopic effect based on
|
|
1577
1605
|
// http://paulbourke.net/stereographics/stereorender/
|
|
1578
1606
|
var xmin,xmax,projectionMatrix=camera.projectionMatrix.clone(),eyeSep=.064/2,eyeSepOnProjection=eyeSep*near/focus,ymax=near*Math.tan(.5*(THREE.Math.DEG2RAD*fov))/camera.zoom;// translate xOffset
|
|
1579
1607
|
// for left eye
|
|
@@ -1583,19 +1611,19 @@ eyeLeft.elements[12]=-eyeSep,eyeRight.elements[12]=eyeSep,xmin=-ymax*aspect+eyeS
|
|
|
1583
1611
|
* @authod mrdoob / http://mrdoob.com/
|
|
1584
1612
|
* @authod arodic / http://aleksandarrodic.com/
|
|
1585
1613
|
* @authod fonserbc / http://fonserbc.github.io/
|
|
1586
|
-
*/var StereoEffect=function(renderer){var _stereo=new StereoCameraZoomFixed;_stereo.aspect=.5,this.setSize=(width,height)=>{renderer.setSize(width,height)},this.render=(scene,camera)=>{scene.updateMatrixWorld(),null===camera.parent&&camera.updateMatrixWorld(),_stereo.update(camera);var size=renderer.getSize();renderer.setScissorTest(!0),renderer.clear(),renderer.setScissor(0,0,size.width/2,size.height),renderer.setViewport(0,0,size.width/2,size.height),renderer.render(scene,_stereo.cameraL),renderer.setScissor(size.width/2,0,size.width/2,size.height),renderer.setViewport(size.width/2,0,size.width/2,size.height),renderer.render(scene,_stereo.cameraR),renderer.setScissorTest(!1)}}
|
|
1587
|
-
* @author richt / http://richt.me
|
|
1588
|
-
* @author WestLangley / http://github.com/WestLangley
|
|
1589
|
-
*
|
|
1590
|
-
* W3C Device Orientation control (http://w3c.github.io/deviceorientation/spec-source-orientation.html)
|
|
1591
|
-
*/ModifiedDeviceOrientationControls=function ModifiedDeviceOrientationControls(object){var scope=this;this.object=object,this.object.rotation.reorder("YXZ"),this.enabled=!0,this.deviceOrientation={},this.screenOrientation=0;var onDeviceOrientationChangeEvent=event=>{scope.deviceOrientation=event},onScreenOrientationChangeEvent=()=>{"undefined"!=typeof window&&(scope.screenOrientation=window.orientation||0)},setObjectQuaternion=(()=>{var zee=new THREE.Vector3(0,0,1),euler=new THREE.Euler,q0=new THREE.Quaternion,q1=new THREE.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5));// - PI/2 around the x-axis
|
|
1614
|
+
*/var StereoEffect=function(renderer){var _stereo=new StereoCameraZoomFixed;_stereo.aspect=.5,this.setSize=(width,height)=>{renderer.setSize(width,height)},this.render=(scene,camera)=>{scene.updateMatrixWorld(),null===camera.parent&&camera.updateMatrixWorld(),_stereo.update(camera);var size=renderer.getSize();renderer.setScissorTest(!0),renderer.clear(),renderer.setScissor(0,0,size.width/2,size.height),renderer.setViewport(0,0,size.width/2,size.height),renderer.render(scene,_stereo.cameraL),renderer.setScissor(size.width/2,0,size.width/2,size.height),renderer.setViewport(size.width/2,0,size.width/2,size.height),renderer.render(scene,_stereo.cameraR),renderer.setScissorTest(!1)}},ModifiedDeviceOrientationControls=function(object){var scope=this;this.object=object,this.object.rotation.reorder("YXZ"),this.enabled=!0,this.deviceOrientation={},this.screenOrientation=0;var onDeviceOrientationChangeEvent=event=>{scope.deviceOrientation=event},onScreenOrientationChangeEvent=()=>{"undefined"!=typeof window&&(scope.screenOrientation=window.orientation||0)},setObjectQuaternion=(()=>{var zee=new THREE.Vector3(0,0,1),euler=new THREE.Euler,q0=new THREE.Quaternion,q1=new THREE.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5));// - PI/2 around the x-axis
|
|
1592
1615
|
return(cameraObject,alpha,beta,gamma,orient)=>{var vector=new THREE.Vector3(0,0,1);vector.subVectors(cameraObject.target,cameraObject.position),euler.set(beta,alpha,-gamma,"YXZ");// 'ZXY' for the device, but 'YXZ' for us
|
|
1593
1616
|
var quaternion=new THREE.Quaternion;// orient the device
|
|
1594
1617
|
// camera looks out the back of the device, not the top
|
|
1595
1618
|
// adjust for screen orientation
|
|
1596
1619
|
quaternion.setFromEuler(euler),quaternion.multiply(q1),quaternion.multiply(q0.setFromAxisAngle(zee,-orient)),vector.applyQuaternion(quaternion),vector.addVectors(cameraObject.position,vector),cameraObject.lookAt(vector)}})();this.connect=()=>{onScreenOrientationChangeEvent(),"undefined"!=typeof window&&(window.addEventListener("orientationchange",onScreenOrientationChangeEvent,!1),window.addEventListener("deviceorientation",onDeviceOrientationChangeEvent,!1)),scope.enabled=!0},this.disconnect=()=>{"undefined"!=typeof window&&(window.removeEventListener("orientationchange",onScreenOrientationChangeEvent,!1),window.removeEventListener("deviceorientation",onDeviceOrientationChangeEvent,!1)),scope.enabled=!1},this.update=()=>{if(!1!==scope.enabled){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;// Z
|
|
1597
|
-
setObjectQuaternion(scope.object,alpha,beta,gamma,orient)}},this.dispose=function(){this.disconnect()},this.connect()}
|
|
1598
|
-
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 zoom=Math.max(targetCamera.zoom-.002*delta,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()}}
|
|
1620
|
+
setObjectQuaternion(scope.object,alpha,beta,gamma,orient)}},this.dispose=function(){this.disconnect()},this.connect()},NDCCameraControl=function(){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
|
|
1621
|
+
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 zoom=Math.max(targetCamera.zoom-.002*delta,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()}};/**
|
|
1622
|
+
* @author richt / http://richt.me
|
|
1623
|
+
* @author WestLangley / http://github.com/WestLangley
|
|
1624
|
+
*
|
|
1625
|
+
* W3C Device Orientation control (http://w3c.github.io/deviceorientation/spec-source-orientation.html)
|
|
1626
|
+
*/exports.Viewport=Viewport,exports.CameraControls=CameraControls,exports.SmoothCameraTransition=SmoothCameraTransition,exports.RotateCameraTransition=RotateCameraTransition,exports.RayCaster=RayCaster,exports.CameraAutoTumble=CameraAutoTumble,exports.StereoEffect=StereoEffect,exports.NDCCameraControl=NDCCameraControl;
|
|
1599
1627
|
|
|
1600
1628
|
/***/ }),
|
|
1601
1629
|
/* 40 */
|