zincjs 0.40.0 → 0.41.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/zinc.js CHANGED
@@ -103,7 +103,7 @@ __webpack_require__(1);/**
103
103
  *
104
104
  * @namespace
105
105
  * @author Alan Wu
106
- */var Zinc=function(){this.Revision="0.36.5",this.defaultMaterialColor=16777215,this.defaultOpacity=1,this.modelPrefix=void 0,this.Geometry=__webpack_require__(2).Geometry,this.Glyph=__webpack_require__(10).Glyph,this.Glyphset=__webpack_require__(13).Glyphset,this.Pointset=__webpack_require__(17).Pointset,this.Lines=__webpack_require__(20).Lines,this.Renderer=__webpack_require__(23).Renderer,this.Scene=__webpack_require__(25).Scene,this.GeometryCSG=__webpack_require__(31).GeometryCSG,this.GlyphsetCSG=__webpack_require__(37).GlyphsetCSG,this.Viewport=__webpack_require__(29).Viewport,this.CameraControls=__webpack_require__(29).CameraControls,this.SmoothCameraTransition=__webpack_require__(29).SmoothCameraTransition,this.RayCaster=__webpack_require__(29).RayCaster,this.CameraAutoTumble=__webpack_require__(29).CameraAutoTumble,this.StereoEffect=__webpack_require__(29).StereoEffect,this.loadExternalFile=__webpack_require__(6).loadExternalFile,this.loadExternalFiles=__webpack_require__(6).loadExternalFiles,this.THREE=__webpack_require__(3)};module.exports=new Zinc;
106
+ */var Zinc=function(){this.Revision="0.40.0",this.defaultMaterialColor=16777215,this.defaultOpacity=1,this.modelPrefix=void 0,this.Geometry=__webpack_require__(2).Geometry,this.Glyph=__webpack_require__(10).Glyph,this.Glyphset=__webpack_require__(13).Glyphset,this.Pointset=__webpack_require__(17).Pointset,this.Lines=__webpack_require__(20).Lines,this.Renderer=__webpack_require__(23).Renderer,this.Scene=__webpack_require__(25).Scene,this.GeometryCSG=__webpack_require__(34).GeometryCSG,this.GlyphsetCSG=__webpack_require__(40).GlyphsetCSG,this.Viewport=__webpack_require__(32).Viewport,this.CameraControls=__webpack_require__(32).CameraControls,this.SmoothCameraTransition=__webpack_require__(32).SmoothCameraTransition,this.RayCaster=__webpack_require__(32).RayCaster,this.CameraAutoTumble=__webpack_require__(32).CameraAutoTumble,this.StereoEffect=__webpack_require__(32).StereoEffect,this.loadExternalFile=__webpack_require__(6).loadExternalFile,this.loadExternalFiles=__webpack_require__(6).loadExternalFiles,this.THREE=__webpack_require__(3)};module.exports=new Zinc;
107
107
 
108
108
  /***/ }),
109
109
  /* 1 */
@@ -150,7 +150,7 @@ var THREE=__webpack_require__(3),THREEGeometry=__webpack_require__(5).Geometry,Z
150
150
  * Total duration of the animation, this value interacts with the
151
151
  * {@link Zinc.Renderer#playRate} to produce the actual duration of the
152
152
  * animation. Actual time in second = duration / playRate.
153
- */this.isZincObject=!0,this.geometry=void 0,this.morph=void 0,this.secondaryMesh=void 0,this.groupName=void 0,this.timeEnabled=!1,this.morphColour=!1,this.inbuildTime=0,this.mixer=void 0,this.animationGroup=void 0,this.duration=6e3,this.clipAction=void 0,this.userData=[],this.videoHandler=void 0,this.marker=void 0,this.markerUpdateRequired=!0,this.markerVertexIndex=-1,this.boundingBoxUpdateRequired=!0,this.cachedBoundingBox=new THREE.Box3,this._vertex=new THREE.Vector3,this.anatomicalId=void 0};ZincObject.prototype.setDuration=function(durationIn){this.duration=durationIn,this.clipAction&&this.clipAction.setDuration(this.duration)},ZincObject.prototype.getDuration=function(){return this.duration},ZincObject.prototype.toBufferGeometry=function(geometryIn,options){var geometry;return geometryIn instanceof THREEGeometry?(options.localTimeEnabled&&(null==geometryIn.morphNormals||0==geometryIn.morphNormals.length)&&geometryIn.computeMorphNormals(),geometry=geometryIn.toBufferGeometry(),options.localMorphColour&&__webpack_require__(6).copyMorphColorsToBufferGeometry(geometryIn,geometry)):geometryIn instanceof THREE.BufferGeometry&&(geometry=geometryIn.clone()),geometry.colorsNeedUpdate=!0,geometry.computeBoundingBox(),geometry.computeBoundingSphere(),geometryIn._video&&(geometry._video=geometryIn._video),geometry},ZincObject.prototype.checkAndCreateTransparentMesh=function(){if(this.isGeometry&&this.morph.material.transparent){if(!this.secondaryMesh){var secondaryMaterial=this.morph.material.clone();secondaryMaterial.side=THREE.FrontSide,this.secondaryMesh=new THREE.Mesh(this.morph.geometry,secondaryMaterial),this.secondaryMesh.renderOrder=2,this.secondaryMesh.userData=this,this.secondaryMesh.name=this.groupName}this.morph.material.side=THREE.BackSide,this.morph.material.needsUpdate=!0,this.morph.add(this.secondaryMesh),this.animationGroup.add(this.secondaryMesh)}},ZincObject.prototype.checkAndRemoveTransparentMesh=function(){this.isGeometry&&this.secondaryMesh&&(this.morph.remove(this.secondaryMesh),this.animationGroup.uncache(this.secondaryMesh),this.animationGroup.remove(this.secondaryMesh)),this.morph.material.side=THREE.DoubleSide},ZincObject.prototype.setMesh=function(mesh,localTimeEnabled,localMorphColour){if(this.animationGroup=new THREE.AnimationObjectGroup(mesh),this.mixer=new THREE.AnimationMixer(this.animationGroup),this.geometry=mesh.geometry,this.clipAction=void 0,this.geometry.morphAttributes.position){var animationClip=THREE.AnimationClip.CreateClipsFromMorphTargetSequences(this.geometry.morphAttributes.position,10,!0);animationClip&&null!=animationClip[0]&&(this.clipAction=this.mixer.clipAction(animationClip[0]).setDuration(this.duration),this.clipAction.loop=THREE.loopOnce,this.clipAction.clampWhenFinished=!0,this.clipAction.play())}this.timeEnabled=localTimeEnabled,this.morphColour=localMorphColour,this.morph=mesh,this.morph.userData=this,this.morph.matrixAutoUpdate=!1,this.checkAndCreateTransparentMesh(),this.timeEnabled&&this.setFrustumCulled(!1),this.boundingBoxUpdateRequired=!0},ZincObject.prototype.setName=function(groupNameIn){this.groupName=groupNameIn,this.morph&&(this.morph.name=this.groupName),this.secondaryMesh&&(this.secondaryMesh.name=this.groupName)},ZincObject.prototype.getCurrentTime=function(){if(this.clipAction){var ratio=this.clipAction.time/this.clipAction._clip.duration;return this.duration*ratio}return this.inbuildTime};var updateMorphColorAttribute=function(targetGeometry,morph){if(morph&&targetGeometry.morphAttributes.color){var morphColors=targetGeometry.morphAttributes.color,influences=morph.morphTargetInfluences,length=influences.length;targetGeometry.deleteAttribute("morphColor0"),targetGeometry.deleteAttribute("morphColor1");for(var bound=0,morphArray=[],i=0;1>bound||i<length;i++)0<influences[i]&&(bound++,morphArray.push([i,influences[i]]));2==morphArray.length?(targetGeometry.setAttribute("morphColor0",morphColors[morphArray[0][0]]),targetGeometry.setAttribute("morphColor1",morphColors[morphArray[1][0]])):1==morphArray.length&&(targetGeometry.setAttribute("morphColor0",morphColors[morphArray[0][0]]),targetGeometry.setAttribute("morphColor1",morphColors[morphArray[0][0]]))}};/**
153
+ */this.isZincObject=!0,this.geometry=void 0,this.morph=void 0,this.secondaryMesh=void 0,this.groupName=void 0,this.timeEnabled=!1,this.morphColour=!1,this.inbuildTime=0,this.mixer=void 0,this.animationGroup=void 0,this.duration=6e3,this.clipAction=void 0,this.userData=[],this.videoHandler=void 0,this.marker=void 0,this.markerUpdateRequired=!0,this.markerVertexIndex=-1,this.boundingBoxUpdateRequired=!0,this.cachedBoundingBox=new THREE.Box3,this._vertex=new THREE.Vector3,this.anatomicalId=void 0};ZincObject.prototype.setDuration=function(durationIn){this.duration=durationIn,this.clipAction&&this.clipAction.setDuration(this.duration)},ZincObject.prototype.getDuration=function(){return this.duration},ZincObject.prototype.toBufferGeometry=function(geometryIn,options){var geometry;return geometryIn instanceof THREEGeometry?(options.localTimeEnabled&&(null==geometryIn.morphNormals||0==geometryIn.morphNormals.length)&&geometryIn.computeMorphNormals(),geometry=geometryIn.toIndexedBufferGeometry(),options.localMorphColour&&__webpack_require__(6).copyMorphColorsToIndexedBufferGeometry(geometryIn,geometry)):geometryIn instanceof THREE.BufferGeometry&&(geometry=geometryIn.clone()),geometry.colorsNeedUpdate=!0,geometry.computeBoundingBox(),geometry.computeBoundingSphere(),geometryIn._video&&(geometry._video=geometryIn._video),geometry},ZincObject.prototype.checkAndCreateTransparentMesh=function(){if(this.isGeometry&&this.morph.material&&this.morph.material.transparent){if(!this.secondaryMesh){var secondaryMaterial=this.morph.material.clone();secondaryMaterial.side=THREE.FrontSide,this.secondaryMesh=new THREE.Mesh(this.morph.geometry,secondaryMaterial),this.secondaryMesh.renderOrder=this.morph.renderOrder+1,this.secondaryMesh.userData=this,this.secondaryMesh.name=this.groupName}this.morph.material.side=THREE.BackSide,this.morph.material.needsUpdate=!0,this.morph.add(this.secondaryMesh),this.animationGroup.add(this.secondaryMesh)}},ZincObject.prototype.checkAndRemoveTransparentMesh=function(){this.isGeometry&&this.secondaryMesh&&(this.morph.remove(this.secondaryMesh),this.animationGroup.uncache(this.secondaryMesh),this.animationGroup.remove(this.secondaryMesh)),this.morph.material.side=THREE.DoubleSide},ZincObject.prototype.setMesh=function(mesh,localTimeEnabled,localMorphColour){if(this.animationGroup=new THREE.AnimationObjectGroup(mesh),this.mixer=new THREE.AnimationMixer(this.animationGroup),this.geometry=mesh.geometry,this.clipAction=void 0,this.geometry&&this.geometry.morphAttributes&&this.geometry.morphAttributes.position){var animationClip=THREE.AnimationClip.CreateClipsFromMorphTargetSequences(this.geometry.morphAttributes.position,10,!0);animationClip&&null!=animationClip[0]&&(this.clipAction=this.mixer.clipAction(animationClip[0]).setDuration(this.duration),this.clipAction.loop=THREE.loopOnce,this.clipAction.clampWhenFinished=!0,this.clipAction.play())}this.timeEnabled=localTimeEnabled,this.morphColour=localMorphColour,this.morph=mesh,this.morph.userData=this,this.morph.matrixAutoUpdate=!1,this.checkAndCreateTransparentMesh(),this.timeEnabled&&this.setFrustumCulled(!1),this.boundingBoxUpdateRequired=!0},ZincObject.prototype.setName=function(groupNameIn){this.groupName=groupNameIn,this.morph&&(this.morph.name=this.groupName),this.secondaryMesh&&(this.secondaryMesh.name=this.groupName)},ZincObject.prototype.getCurrentTime=function(){if(this.clipAction){var ratio=this.clipAction.time/this.clipAction._clip.duration;return this.duration*ratio}return this.inbuildTime};var updateMorphColorAttribute=function(targetGeometry,morph){if(morph&&targetGeometry.morphAttributes.color){var morphColors=targetGeometry.morphAttributes.color,influences=morph.morphTargetInfluences,length=influences.length;targetGeometry.deleteAttribute("morphColor0"),targetGeometry.deleteAttribute("morphColor1");for(var bound=0,morphArray=[],i=0;1>bound||i<length;i++)0<influences[i]&&(bound++,morphArray.push([i,influences[i]]));2==morphArray.length?(targetGeometry.setAttribute("morphColor0",morphColors[morphArray[0][0]]),targetGeometry.setAttribute("morphColor1",morphColors[morphArray[1][0]])):1==morphArray.length&&(targetGeometry.setAttribute("morphColor0",morphColors[morphArray[0][0]]),targetGeometry.setAttribute("morphColor1",morphColors[morphArray[0][0]]))}};/**
154
154
  * Set the local time of this geometry.
155
155
  *
156
156
  * @param {Number} time - Can be any value between 0 to duration.
@@ -194,7 +194,7 @@ var THREE=__webpack_require__(3),THREEGeometry=__webpack_require__(5).Geometry,Z
194
194
  */ /**
195
195
  * Clear this geometry and free the memory.
196
196
  */ //Update the geometry and colours depending on the morph.
197
- 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&&1==this.timeEnabled&&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.visible},ZincObject.prototype.setVisibility=function(visible){this.morph.visible=visible},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?void 0:this.morph.material.color.getHexString()},ZincObject.prototype.setColourHex=function(hex){this.morph.material.color.setHex(hex),this.secondaryMesh&&this.secondaryMesh.material&&this.secondaryMesh.material.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(){var position=new THREE.Vector3;if(-1==this.markerVertexIndex&&(this.markerVertexIndex=this.getClosestVertexIndex()),0<=this.markerVertexIndex){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.markerVertexIndex),position.add(this._vertex.multiplyScalar(influences[i])));if(found)return position}else return position.fromArray(this.morph.geometry.attributes.position.array,3*this.markerVertexIndex),position}return this.getBoundingBox().getCenter(position),position},ZincObject.prototype.getBoundingBox=function(){if(this.morph&&this.morph.visible){if(this.boundingBoxUpdateRequired){var influences=this.morph.morphTargetInfluences,attributes=this.morph.geometry.morphAttributes,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.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.updateMarker=function(playAnimation,options){if(!(!1==playAnimation&&options&&options.displayMarkers))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();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.render=function(delta,playAnimation,options){if(!0==playAnimation){if(this.clipAction&&1==this.timeEnabled)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;
197
+ 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&&1==this.timeEnabled&&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.visible},ZincObject.prototype.setVisibility=function(visible){this.morph.visible=visible},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?void 0:this.morph.material.color.getHexString()},ZincObject.prototype.setColourHex=function(hex){this.morph.material.color.setHex(hex),this.secondaryMesh&&this.secondaryMesh.material&&this.secondaryMesh.material.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(){var position=new THREE.Vector3;if(-1==this.markerVertexIndex&&(this.markerVertexIndex=this.getClosestVertexIndex()),0<=this.markerVertexIndex){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.markerVertexIndex),position.add(this._vertex.multiplyScalar(influences[i])));if(found)return position}else return position.fromArray(this.morph.geometry.attributes.position.array,3*this.markerVertexIndex),position}return this.getBoundingBox().getCenter(position),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.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.updateMarker=function(playAnimation,options){if(!(!1==playAnimation&&options&&options.displayMarkers))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();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.render=function(delta,playAnimation,options){if(!0==playAnimation){if(this.clipAction&&1==this.timeEnabled)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;
198
198
 
199
199
  /***/ }),
200
200
  /* 5 */
@@ -207,16 +207,16 @@ __webpack_require__.r(__webpack_exports__);
207
207
  /* harmony import */ var three__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
208
208
  /* harmony import */ var three__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(three__WEBPACK_IMPORTED_MODULE_0__);
209
209
  var _m1=new three__WEBPACK_IMPORTED_MODULE_0__["Matrix4"],_obj=new three__WEBPACK_IMPORTED_MODULE_0__["Object3D"],_offset=new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"];function Geometry(){// update flags
210
- this.uuid=three__WEBPACK_IMPORTED_MODULE_0__["MathUtils"].generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}Geometry.prototype=Object.assign(Object.create(three__WEBPACK_IMPORTED_MODULE_0__["EventDispatcher"].prototype),{constructor:Geometry,isGeometry:!0,applyMatrix4:function applyMatrix4(matrix){for(var vertex,normalMatrix=new three__WEBPACK_IMPORTED_MODULE_0__["Matrix3"]().getNormalMatrix(matrix),i=0,il=this.vertices.length;i<il;i++)vertex=this.vertices[i],vertex.applyMatrix4(matrix);for(var face,_i=0,_il=this.faces.length;_i<_il;_i++){face=this.faces[_i],face.normal.applyMatrix3(normalMatrix).normalize();for(var j=0,jl=face.vertexNormals.length;j<jl;j++)face.vertexNormals[j].applyMatrix3(normalMatrix).normalize()}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function rotateX(angle){return _m1.makeRotationX(angle),this.applyMatrix4(_m1),this},rotateY:function rotateY(angle){return _m1.makeRotationY(angle),this.applyMatrix4(_m1),this},rotateZ:function rotateZ(angle){return _m1.makeRotationZ(angle),this.applyMatrix4(_m1),this},translate:function translate(x,y,z){return _m1.makeTranslation(x,y,z),this.applyMatrix4(_m1),this},scale:function scale(x,y,z){return _m1.makeScale(x,y,z),this.applyMatrix4(_m1),this},lookAt:function lookAt(vector){return _obj.lookAt(vector),_obj.updateMatrix(),this.applyMatrix4(_obj.matrix),this},fromBufferGeometry:function fromBufferGeometry(geometry){function addFace(a,b,c,materialIndex){var vertexColors=void 0===color?[]:[scope.colors[a].clone(),scope.colors[b].clone(),scope.colors[c].clone()],vertexNormals=void 0===normal?[]:[new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]().fromBufferAttribute(normal,a),new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]().fromBufferAttribute(normal,b),new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]().fromBufferAttribute(normal,c)],face=new Face3(a,b,c,vertexNormals,vertexColors,materialIndex);scope.faces.push(face),void 0!==uv&&scope.faceVertexUvs[0].push([new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"]().fromBufferAttribute(uv,a),new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"]().fromBufferAttribute(uv,b),new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"]().fromBufferAttribute(uv,c)]),void 0!==uv2&&scope.faceVertexUvs[1].push([new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"]().fromBufferAttribute(uv2,a),new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"]().fromBufferAttribute(uv2,b),new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"]().fromBufferAttribute(uv2,c)])}var scope=this,index=null===geometry.index?void 0:geometry.index,attributes=geometry.attributes;if(void 0===attributes.position)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;var position=attributes.position,normal=attributes.normal,color=attributes.color,uv=attributes.uv,uv2=attributes.uv2;void 0!==uv2&&(this.faceVertexUvs[1]=[]);for(var i=0;i<position.count;i++)scope.vertices.push(new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]().fromBufferAttribute(position,i)),void 0!==color&&scope.colors.push(new three__WEBPACK_IMPORTED_MODULE_0__["Color"]().fromBufferAttribute(color,i));var groups=geometry.groups;if(0<groups.length)for(var _i2=0;_i2<groups.length;_i2++)for(var group=groups[_i2],start=group.start,count=group.count,j=start;j<start+count;j+=3)void 0===index?addFace(j,j+1,j+2,group.materialIndex):addFace(index.getX(j),index.getX(j+1),index.getX(j+2),group.materialIndex);else if(void 0!==index)for(var _i3=0;_i3<index.count;_i3+=3)addFace(index.getX(_i3),index.getX(_i3+1),index.getX(_i3+2));else for(var _i4=0;_i4<position.count;_i4+=3)addFace(_i4,_i4+1,_i4+2);return this.computeFaceNormals(),null!==geometry.boundingBox&&(this.boundingBox=geometry.boundingBox.clone()),null!==geometry.boundingSphere&&(this.boundingSphere=geometry.boundingSphere.clone()),this},center:function center(){return this.computeBoundingBox(),this.boundingBox.getCenter(_offset).negate(),this.translate(_offset.x,_offset.y,_offset.z),this},normalize:function normalize(){this.computeBoundingSphere();var center=this.boundingSphere.center,radius=this.boundingSphere.radius,s=0===radius?1:1/radius,matrix=new three__WEBPACK_IMPORTED_MODULE_0__["Matrix4"];return matrix.set(s,0,0,-s*center.x,0,s,0,-s*center.y,0,0,s,-s*center.z,0,0,0,1),this.applyMatrix4(matrix),this},computeFaceNormals:function computeFaceNormals(){for(var cb=new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"],ab=new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"],f=0,fl=this.faces.length;f<fl;f++){var face=this.faces[f],vA=this.vertices[face.a],vB=this.vertices[face.b],vC=this.vertices[face.c];cb.subVectors(vC,vB),ab.subVectors(vA,vB),cb.cross(ab),cb.normalize(),face.normal.copy(cb)}},computeVertexNormals:function computeVertexNormals(){for(var areaWeighted=!(0<arguments.length&&arguments[0]!==void 0)||arguments[0],vertices=Array(this.vertices.length),v=0,vl=this.vertices.length;v<vl;v++)vertices[v]=new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"];if(areaWeighted)// vertex normals weighted by triangle areas
210
+ this.uuid=three__WEBPACK_IMPORTED_MODULE_0__["MathUtils"].generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.normals=[],this.uvs=[],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}Geometry.prototype=Object.assign(Object.create(three__WEBPACK_IMPORTED_MODULE_0__["EventDispatcher"].prototype),{constructor:Geometry,isGeometry:!0,applyMatrix4:function applyMatrix4(matrix){for(var vertex,normalMatrix=new three__WEBPACK_IMPORTED_MODULE_0__["Matrix3"]().getNormalMatrix(matrix),i=0,il=this.vertices.length;i<il;i++)vertex=this.vertices[i],vertex.applyMatrix4(matrix);for(var face,_i=0,_il=this.faces.length;_i<_il;_i++){face=this.faces[_i],face.normal.applyMatrix3(normalMatrix).normalize();for(var j=0,jl=face.vertexNormals.length;j<jl;j++)face.vertexNormals[j].applyMatrix3(normalMatrix).normalize()}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function rotateX(angle){return _m1.makeRotationX(angle),this.applyMatrix4(_m1),this},rotateY:function rotateY(angle){return _m1.makeRotationY(angle),this.applyMatrix4(_m1),this},rotateZ:function rotateZ(angle){return _m1.makeRotationZ(angle),this.applyMatrix4(_m1),this},translate:function translate(x,y,z){return _m1.makeTranslation(x,y,z),this.applyMatrix4(_m1),this},scale:function scale(x,y,z){return _m1.makeScale(x,y,z),this.applyMatrix4(_m1),this},lookAt:function lookAt(vector){return _obj.lookAt(vector),_obj.updateMatrix(),this.applyMatrix4(_obj.matrix),this},fromBufferGeometry:function fromBufferGeometry(geometry){function addFace(a,b,c,materialIndex){var vertexColors=void 0===color?[]:[scope.colors[a].clone(),scope.colors[b].clone(),scope.colors[c].clone()],vertexNormals=void 0===normal?[]:[new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]().fromBufferAttribute(normal,a),new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]().fromBufferAttribute(normal,b),new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]().fromBufferAttribute(normal,c)],face=new Face3(a,b,c,vertexNormals,vertexColors,materialIndex);scope.faces.push(face),void 0!==uv&&scope.faceVertexUvs[0].push([new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"]().fromBufferAttribute(uv,a),new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"]().fromBufferAttribute(uv,b),new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"]().fromBufferAttribute(uv,c)]),void 0!==uv2&&scope.faceVertexUvs[1].push([new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"]().fromBufferAttribute(uv2,a),new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"]().fromBufferAttribute(uv2,b),new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"]().fromBufferAttribute(uv2,c)])}var scope=this,index=null===geometry.index?void 0:geometry.index,attributes=geometry.attributes;if(void 0===attributes.position)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;var position=attributes.position,normal=attributes.normal,color=attributes.color,uv=attributes.uv,uv2=attributes.uv2;void 0!==uv2&&(this.faceVertexUvs[1]=[]);for(var i=0;i<position.count;i++)scope.vertices.push(new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]().fromBufferAttribute(position,i)),void 0!==color&&scope.colors.push(new three__WEBPACK_IMPORTED_MODULE_0__["Color"]().fromBufferAttribute(color,i));var groups=geometry.groups;if(0<groups.length)for(var _i2=0;_i2<groups.length;_i2++)for(var group=groups[_i2],start=group.start,count=group.count,j=start;j<start+count;j+=3)void 0===index?addFace(j,j+1,j+2,group.materialIndex):addFace(index.getX(j),index.getX(j+1),index.getX(j+2),group.materialIndex);else if(void 0!==index)for(var _i3=0;_i3<index.count;_i3+=3)addFace(index.getX(_i3),index.getX(_i3+1),index.getX(_i3+2));else for(var _i4=0;_i4<position.count;_i4+=3)addFace(_i4,_i4+1,_i4+2);return this.computeFaceNormals(),null!==geometry.boundingBox&&(this.boundingBox=geometry.boundingBox.clone()),null!==geometry.boundingSphere&&(this.boundingSphere=geometry.boundingSphere.clone()),this},center:function center(){return this.computeBoundingBox(),this.boundingBox.getCenter(_offset).negate(),this.translate(_offset.x,_offset.y,_offset.z),this},normalize:function normalize(){this.computeBoundingSphere();var center=this.boundingSphere.center,radius=this.boundingSphere.radius,s=0===radius?1:1/radius,matrix=new three__WEBPACK_IMPORTED_MODULE_0__["Matrix4"];return matrix.set(s,0,0,-s*center.x,0,s,0,-s*center.y,0,0,s,-s*center.z,0,0,0,1),this.applyMatrix4(matrix),this},computeFaceNormals:function computeFaceNormals(){for(var cb=new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"],ab=new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"],f=0,fl=this.faces.length;f<fl;f++){var face=this.faces[f],vA=this.vertices[face.a],vB=this.vertices[face.b],vC=this.vertices[face.c];cb.subVectors(vC,vB),ab.subVectors(vA,vB),cb.cross(ab),cb.normalize(),face.normal.copy(cb)}},computeVertexNormals:function computeVertexNormals(){for(var areaWeighted=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],vertices=Array(this.vertices.length),v=0,vl=this.vertices.length;v<vl;v++)vertices[v]=new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"];if(areaWeighted)// vertex normals weighted by triangle areas
211
211
  // http://www.iquilezles.org/www/articles/normals/normals.htm
212
- for(var cb=new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"],ab=new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"],f=0,fl=this.faces.length;f<fl;f++){var face=this.faces[f],vA=this.vertices[face.a],vB=this.vertices[face.b],vC=this.vertices[face.c];cb.subVectors(vC,vB),ab.subVectors(vA,vB),cb.cross(ab),vertices[face.a].add(cb),vertices[face.b].add(cb),vertices[face.c].add(cb)}else{this.computeFaceNormals();for(var _face,_f=0,_fl=this.faces.length;_f<_fl;_f++)_face=this.faces[_f],vertices[_face.a].add(_face.normal),vertices[_face.b].add(_face.normal),vertices[_face.c].add(_face.normal)}for(var _v=0,_vl=this.vertices.length;_v<_vl;_v++)vertices[_v].normalize();for(var _f2=0,_fl2=this.faces.length;_f2<_fl2;_f2++){var _face2=this.faces[_f2],vertexNormals=_face2.vertexNormals;3===vertexNormals.length?(vertexNormals[0].copy(vertices[_face2.a]),vertexNormals[1].copy(vertices[_face2.b]),vertexNormals[2].copy(vertices[_face2.c])):(vertexNormals[0]=vertices[_face2.a].clone(),vertexNormals[1]=vertices[_face2.b].clone(),vertexNormals[2]=vertices[_face2.c].clone())}0<this.faces.length&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function computeFlatVertexNormals(){this.computeFaceNormals();for(var f=0,fl=this.faces.length;f<fl;f++){var face=this.faces[f],vertexNormals=face.vertexNormals;3===vertexNormals.length?(vertexNormals[0].copy(face.normal),vertexNormals[1].copy(face.normal),vertexNormals[2].copy(face.normal)):(vertexNormals[0]=face.normal.clone(),vertexNormals[1]=face.normal.clone(),vertexNormals[2]=face.normal.clone())}0<this.faces.length&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function computeMorphNormals(){// save original normals
212
+ for(var cb=new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"],ab=new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"],f=0,fl=this.faces.length;f<fl;f++){var face=this.faces[f],vA=this.vertices[face.a],vB=this.vertices[face.b],vC=this.vertices[face.c];cb.subVectors(vC,vB),ab.subVectors(vA,vB),cb.cross(ab),vertices[face.a].add(cb),vertices[face.b].add(cb),vertices[face.c].add(cb)}else{this.computeFaceNormals();for(var _face,_f=0,_fl=this.faces.length;_f<_fl;_f++)_face=this.faces[_f],vertices[_face.a].add(_face.normal),vertices[_face.b].add(_face.normal),vertices[_face.c].add(_face.normal)}for(var _v=0,_vl=this.vertices.length;_v<_vl;_v++)vertices[_v].normalize();for(var _f2=0,_fl2=this.faces.length;_f2<_fl2;_f2++){var _face2=this.faces[_f2],vertexNormals=_face2.vertexNormals;3===vertexNormals.length?(vertexNormals[0].copy(vertices[_face2.a]),vertexNormals[1].copy(vertices[_face2.b]),vertexNormals[2].copy(vertices[_face2.c])):(vertexNormals[0]=vertices[_face2.a].clone(),vertexNormals[1]=vertices[_face2.b].clone(),vertexNormals[2]=vertices[_face2.c].clone())}return 0<this.faces.length&&(this.normalsNeedUpdate=!0),vertices},computeFlatVertexNormals:function computeFlatVertexNormals(){this.computeFaceNormals();for(var f=0,fl=this.faces.length;f<fl;f++){var face=this.faces[f],vertexNormals=face.vertexNormals;3===vertexNormals.length?(vertexNormals[0].copy(face.normal),vertexNormals[1].copy(face.normal),vertexNormals[2].copy(face.normal)):(vertexNormals[0]=face.normal.clone(),vertexNormals[1]=face.normal.clone(),vertexNormals[2]=face.normal.clone())}0<this.faces.length&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function computeMorphNormals(){// save original normals
213
213
  // - create temp variables on first access
214
214
  // otherwise just copy (for faster repeated calls)
215
215
  for(var face,f=0,fl=this.faces.length;f<fl;f++){face=this.faces[f],face.__originalFaceNormal?face.__originalFaceNormal.copy(face.normal):face.__originalFaceNormal=face.normal.clone(),face.__originalVertexNormals||(face.__originalVertexNormals=[]);for(var i=0,il=face.vertexNormals.length;i<il;i++)face.__originalVertexNormals[i]?face.__originalVertexNormals[i].copy(face.vertexNormals[i]):face.__originalVertexNormals[i]=face.vertexNormals[i].clone()}// use temp geometry to compute face and vertex normals for each morph
216
216
  var tmpGeo=new Geometry;tmpGeo.faces=this.faces;for(var _i5=0,_il2=this.morphTargets.length;_i5<_il2;_i5++){// create on first access
217
- if(!this.morphNormals[_i5]){this.morphNormals[_i5]={},this.morphNormals[_i5].faceNormals=[],this.morphNormals[_i5].vertexNormals=[];for(var dstNormalsFace=this.morphNormals[_i5].faceNormals,dstNormalsVertex=this.morphNormals[_i5].vertexNormals,_f3=0,_fl3=this.faces.length;_f3<_fl3;_f3++){var faceNormal=new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"],vertexNormals={a:new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"],b:new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"],c:new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]};dstNormalsFace.push(faceNormal),dstNormalsVertex.push(vertexNormals)}}var morphNormals=this.morphNormals[_i5];// set vertices to morph target
218
- tmpGeo.vertices=this.morphTargets[_i5].vertices,tmpGeo.computeFaceNormals(),tmpGeo.computeVertexNormals();// store morph normals
219
- for(var _f4=0,_fl4=this.faces.length;_f4<_fl4;_f4++){var _face3=this.faces[_f4],_faceNormal=morphNormals.faceNormals[_f4],_vertexNormals=morphNormals.vertexNormals[_f4];_faceNormal.copy(_face3.normal),_vertexNormals.a.copy(_face3.vertexNormals[0]),_vertexNormals.b.copy(_face3.vertexNormals[1]),_vertexNormals.c.copy(_face3.vertexNormals[2])}}// restore original normals
217
+ if(!this.morphNormals[_i5]){this.morphNormals[_i5]={},this.morphNormals[_i5].faceNormals=[],this.morphNormals[_i5].vertexNormals=[];for(var dstNormalsFace=this.morphNormals[_i5].faceNormals,dstNormalsVertex=this.morphNormals[_i5].vertexNormals,_f3=0,_fl3=this.faces.length;_f3<_fl3;_f3++){var faceNormal=new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"],_vertexNormals={a:new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"],b:new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"],c:new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"]};dstNormalsFace.push(faceNormal),dstNormalsVertex.push(_vertexNormals)}}var morphNormals=this.morphNormals[_i5];// set vertices to morph target
218
+ tmpGeo.vertices=this.morphTargets[_i5].vertices,tmpGeo.computeFaceNormals();var vertexNormals=tmpGeo.computeVertexNormals();if(vertexNormals&&0<vertexNormals.length){this.morphTargets[_i5].normals=Array(this.vertices.length);for(var v=0;v<vertexNormals.length;v++)this.morphTargets[_i5].normals[v]=vertexNormals[v].clone()}// store morph normals
219
+ for(var _f4=0,_fl4=this.faces.length;_f4<_fl4;_f4++){var _face3=this.faces[_f4],_faceNormal=morphNormals.faceNormals[_f4],_vertexNormals2=morphNormals.vertexNormals[_f4];_faceNormal.copy(_face3.normal),_vertexNormals2.a.copy(_face3.vertexNormals[0]),_vertexNormals2.b.copy(_face3.vertexNormals[1]),_vertexNormals2.c.copy(_face3.vertexNormals[2])}}// restore original normals
220
220
  for(var _face4,_f5=0,_fl5=this.faces.length;_f5<_fl5;_f5++)_face4=this.faces[_f5],_face4.normal=_face4.__originalFaceNormal,_face4.vertexNormals=_face4.__originalVertexNormals},computeBoundingBox:function computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new three__WEBPACK_IMPORTED_MODULE_0__["Box3"]),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new three__WEBPACK_IMPORTED_MODULE_0__["Sphere"]),this.boundingSphere.setFromPoints(this.vertices)},merge:function merge(geometry,matrix){var materialIndexOffset=2<arguments.length&&arguments[2]!==void 0?arguments[2]:0;if(!(geometry&&geometry.isGeometry))return void console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",geometry);var normalMatrix,vertexOffset=this.vertices.length,vertices1=this.vertices,vertices2=geometry.vertices,faces1=this.faces,faces2=geometry.faces,colors1=this.colors,colors2=geometry.colors;matrix!==void 0&&(normalMatrix=new three__WEBPACK_IMPORTED_MODULE_0__["Matrix3"]().getNormalMatrix(matrix));// vertices
221
221
  for(var i=0,il=vertices2.length;i<il;i++){var vertex=vertices2[i],vertexCopy=vertex.clone();matrix!==void 0&&vertexCopy.applyMatrix4(matrix),vertices1.push(vertexCopy)}// colors
222
222
  for(var _i6=0,_il3=colors2.length;_i6<_il3;_i6++)colors1.push(colors2[_i6].clone());// faces
@@ -270,17 +270,26 @@ for(var skinWeights=source.skinWeights,_i18=0,_il12=skinWeights.length;_i18<_il1
270
270
  for(var skinIndices=source.skinIndices,_i19=0,_il13=skinIndices.length;_i19<_il13;_i19++)this.skinIndices.push(skinIndices[_i19].clone());// line distances
271
271
  for(var lineDistances=source.lineDistances,_i20=0,_il14=lineDistances.length;_i20<_il14;_i20++)this.lineDistances.push(lineDistances[_i20]);// bounding box
272
272
  var boundingBox=source.boundingBox;null!==boundingBox&&(this.boundingBox=boundingBox.clone());// bounding sphere
273
- var boundingSphere=source.boundingSphere;return null!==boundingSphere&&(this.boundingSphere=boundingSphere.clone()),this.elementsNeedUpdate=source.elementsNeedUpdate,this.verticesNeedUpdate=source.verticesNeedUpdate,this.uvsNeedUpdate=source.uvsNeedUpdate,this.normalsNeedUpdate=source.normalsNeedUpdate,this.colorsNeedUpdate=source.colorsNeedUpdate,this.lineDistancesNeedUpdate=source.lineDistancesNeedUpdate,this.groupsNeedUpdate=source.groupsNeedUpdate,this},toBufferGeometry:function toBufferGeometry(){var geometry=new DirectGeometry().fromGeometry(this),buffergeometry=new three__WEBPACK_IMPORTED_MODULE_0__["BufferGeometry"],positions=new Float32Array(3*geometry.vertices.length);if(buffergeometry.setAttribute("position",new three__WEBPACK_IMPORTED_MODULE_0__["BufferAttribute"](positions,3).copyVector3sArray(geometry.vertices)),0<geometry.normals.length){var normals=new Float32Array(3*geometry.normals.length);buffergeometry.setAttribute("normal",new three__WEBPACK_IMPORTED_MODULE_0__["BufferAttribute"](normals,3).copyVector3sArray(geometry.normals))}if(0<geometry.colors.length){var colors=new Float32Array(3*geometry.colors.length);buffergeometry.setAttribute("color",new three__WEBPACK_IMPORTED_MODULE_0__["BufferAttribute"](colors,3).copyColorsArray(geometry.colors))}if(0<geometry.uvs.length){var uvs=new Float32Array(2*geometry.uvs.length);buffergeometry.setAttribute("uv",new three__WEBPACK_IMPORTED_MODULE_0__["BufferAttribute"](uvs,2).copyVector2sArray(geometry.uvs))}if(0<geometry.uvs2.length){var uvs2=new Float32Array(2*geometry.uvs2.length);buffergeometry.setAttribute("uv2",new three__WEBPACK_IMPORTED_MODULE_0__["BufferAttribute"](uvs2,2).copyVector2sArray(geometry.uvs2))}// groups
273
+ var boundingSphere=source.boundingSphere;return null!==boundingSphere&&(this.boundingSphere=boundingSphere.clone()),this.elementsNeedUpdate=source.elementsNeedUpdate,this.verticesNeedUpdate=source.verticesNeedUpdate,this.uvsNeedUpdate=source.uvsNeedUpdate,this.normalsNeedUpdate=source.normalsNeedUpdate,this.colorsNeedUpdate=source.colorsNeedUpdate,this.lineDistancesNeedUpdate=source.lineDistancesNeedUpdate,this.groupsNeedUpdate=source.groupsNeedUpdate,this},computeGroups(){var group,i,groups=[],materialIndex=void 0,faces=this.faces;for(i=0;i<faces.length;i++){var face=faces[i];// materials
274
+ face.materialIndex!==materialIndex&&(materialIndex=face.materialIndex,void 0!==group&&(group.count=3*i-group.start,groups.push(group)),group={start:3*i,materialIndex:materialIndex})}return void 0!==group&&(group.count=3*i-group.start,groups.push(group)),groups},toBufferGeometry:function toBufferGeometry(){var geometry=new DirectGeometry().fromGeometry(this),buffergeometry=new three__WEBPACK_IMPORTED_MODULE_0__["BufferGeometry"],positions=new Float32Array(3*geometry.vertices.length);if(buffergeometry.setAttribute("position",new three__WEBPACK_IMPORTED_MODULE_0__["BufferAttribute"](positions,3).copyVector3sArray(geometry.vertices)),0<geometry.normals.length){var normals=new Float32Array(3*geometry.normals.length);buffergeometry.setAttribute("normal",new three__WEBPACK_IMPORTED_MODULE_0__["BufferAttribute"](normals,3).copyVector3sArray(geometry.normals))}if(0<geometry.colors.length){var colors=new Float32Array(3*geometry.colors.length);buffergeometry.setAttribute("color",new three__WEBPACK_IMPORTED_MODULE_0__["BufferAttribute"](colors,3).copyColorsArray(geometry.colors))}if(0<geometry.uvs.length){var uvs=new Float32Array(2*geometry.uvs.length);buffergeometry.setAttribute("uv",new three__WEBPACK_IMPORTED_MODULE_0__["BufferAttribute"](uvs,2).copyVector2sArray(geometry.uvs))}if(0<geometry.uvs2.length){var uvs2=new Float32Array(2*geometry.uvs2.length);buffergeometry.setAttribute("uv2",new three__WEBPACK_IMPORTED_MODULE_0__["BufferAttribute"](uvs2,2).copyVector2sArray(geometry.uvs2))}// groups
274
275
  // morphs
275
276
  for(var name in buffergeometry.groups=geometry.groups,geometry.morphTargets){for(var array=[],morphTargets=geometry.morphTargets[name],i=0,l=morphTargets.length;i<l;i++){var morphTarget=morphTargets[i],attribute=new three__WEBPACK_IMPORTED_MODULE_0__["Float32BufferAttribute"](3*morphTarget.data.length,3);attribute.name=morphTarget.name,array.push(attribute.copyVector3sArray(morphTarget.data))}buffergeometry.morphAttributes[name]=array}// skinning
276
277
  if(0<geometry.skinIndices.length){var skinIndices=new three__WEBPACK_IMPORTED_MODULE_0__["Float32BufferAttribute"](4*geometry.skinIndices.length,4);buffergeometry.setAttribute("skinIndex",skinIndices.copyVector4sArray(geometry.skinIndices))}if(0<geometry.skinWeights.length){var skinWeights=new three__WEBPACK_IMPORTED_MODULE_0__["Float32BufferAttribute"](4*geometry.skinWeights.length,4);buffergeometry.setAttribute("skinWeight",skinWeights.copyVector4sArray(geometry.skinWeights))}//
277
- return null!==geometry.boundingSphere&&(buffergeometry.boundingSphere=geometry.boundingSphere.clone()),null!==geometry.boundingBox&&(buffergeometry.boundingBox=geometry.boundingBox.clone()),buffergeometry},computeTangents:function computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")},computeLineDistances:function computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")},applyMatrix:function applyMatrix(matrix){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(matrix)},dispose:function dispose(){this.dispatchEvent({type:"dispose"})}}),Geometry.createBufferGeometryFromObject=function(object){var buffergeometry=new three__WEBPACK_IMPORTED_MODULE_0__["BufferGeometry"],geometry=object.geometry;if(object.isPoints||object.isLine){var positions=new three__WEBPACK_IMPORTED_MODULE_0__["Float32BufferAttribute"](3*geometry.vertices.length,3),colors=new three__WEBPACK_IMPORTED_MODULE_0__["Float32BufferAttribute"](3*geometry.colors.length,3);if(buffergeometry.setAttribute("position",positions.copyVector3sArray(geometry.vertices)),buffergeometry.setAttribute("color",colors.copyColorsArray(geometry.colors)),geometry.lineDistances&&geometry.lineDistances.length===geometry.vertices.length){var lineDistances=new three__WEBPACK_IMPORTED_MODULE_0__["Float32BufferAttribute"](geometry.lineDistances.length,1);buffergeometry.setAttribute("lineDistance",lineDistances.copyArray(geometry.lineDistances))}null!==geometry.boundingSphere&&(buffergeometry.boundingSphere=geometry.boundingSphere.clone()),null!==geometry.boundingBox&&(buffergeometry.boundingBox=geometry.boundingBox.clone())}else object.isMesh&&(buffergeometry=geometry.toBufferGeometry());return buffergeometry};class DirectGeometry{constructor(){// this.lineDistances = [];
278
+ return null!==geometry.boundingSphere&&(buffergeometry.boundingSphere=geometry.boundingSphere.clone()),null!==geometry.boundingBox&&(buffergeometry.boundingBox=geometry.boundingBox.clone()),buffergeometry},toIndexedBufferGeometry:function toIndexedBufferGeometry(){//const geometry = new DirectGeometry().fromGeometry( this );
279
+ var buffergeometry=new three__WEBPACK_IMPORTED_MODULE_0__["BufferGeometry"],positions=new Float32Array(3*this.vertices.length);if(buffergeometry.setAttribute("position",new three__WEBPACK_IMPORTED_MODULE_0__["BufferAttribute"](positions,3).copyVector3sArray(this.vertices)),0<this.normals.length){var normals=new Float32Array(this.normals.length),buffer=new three__WEBPACK_IMPORTED_MODULE_0__["BufferAttribute"](normals,3).copyArray(this.normals);buffergeometry.setAttribute("normal",buffer)}if(0<this.uvs.length&&0<this.uvs[0].length){var uvs=new Float32Array(2*this.uvs[0].length);buffergeometry.setAttribute("uv",new three__WEBPACK_IMPORTED_MODULE_0__["BufferAttribute"](uvs,2).copyArray(this.uvs[0]))}if(1<this.uvs.length&&0<this.uvs[1].length){var uvs2=new Float32Array(2*this.uvs[1].length);buffergeometry.setAttribute("uv2",new three__WEBPACK_IMPORTED_MODULE_0__["BufferAttribute"](uvs2,2).copyArray(this.uvs[1]))}if(0<this.colors.length){for(var colorArray=[],i=0;i<this.colors.length;i++)colorArray.push(new three__WEBPACK_IMPORTED_MODULE_0__["Color"](this.colors[i]));var colors=new Float32Array(3*colorArray.length);buffergeometry.setAttribute("color",new three__WEBPACK_IMPORTED_MODULE_0__["BufferAttribute"](colors,3).copyColorsArray(colorArray))}else{for(var colorsArray=new Float32Array(3*this.vertices.length),_i21=0;_i21<3*this.vertices.length;_i21++)colorsArray[_i21]=1;buffergeometry.setAttribute("color",new three__WEBPACK_IMPORTED_MODULE_0__["BufferAttribute"](colorsArray,3))}// morphs
280
+ if(0<this.morphTargets.length){for(var array=[],normalsArray=[],_i22=0,l=this.morphTargets.length;_i22<l;_i22++){var morphTarget=this.morphTargets[_i22],attribute=new three__WEBPACK_IMPORTED_MODULE_0__["Float32BufferAttribute"](3*morphTarget.vertices.length,3);if(attribute.name=morphTarget.name,array.push(attribute.copyVector3sArray(morphTarget.vertices)),morphTarget.normals){var morphNormal=this.morphNormals[_i22],_attribute=new three__WEBPACK_IMPORTED_MODULE_0__["Float32BufferAttribute"](3*morphTarget.normals.length,3);_attribute.name=morphNormal.name,normalsArray.push(_attribute.copyVector3sArray(morphTarget.normals))}}buffergeometry.morphAttributes.position=array,buffergeometry.morphAttributes.normal=normalsArray}// skinning
281
+ if(0<this.skinIndices.length){var skinIndices=new three__WEBPACK_IMPORTED_MODULE_0__["Float32BufferAttribute"](4*this.skinIndices.length,4);buffergeometry.setAttribute("skinIndex",skinIndices.copyVector4sArray(this.skinIndices))}if(0<this.skinWeights.length){var skinWeights=new three__WEBPACK_IMPORTED_MODULE_0__["Float32BufferAttribute"](4*this.skinWeights.length,4);buffergeometry.setAttribute("skinWeight",skinWeights.copyVector4sArray(this.skinWeights))}//
282
+ if(null!==this.boundingSphere&&(buffergeometry.boundingSphere=this.boundingSphere.clone()),null!==this.boundingBox&&(buffergeometry.boundingBox=this.boundingBox.clone()),0<this.faces.length){for(var _colors=[],indices=[],_i23=0;_i23<this.faces.length;_i23++){indices.push(this.faces[_i23].a,this.faces[_i23].b,this.faces[_i23].c);var vertexColors=this.faces[_i23].vertexColors;if(3===vertexColors.length)_colors.push(vertexColors[0],vertexColors[1],vertexColors[2]);else{var color=this.faces[_i23].color;_colors.push(color,color,color)}}// if ( colors.length > 0 ) {
283
+ // const colorsArray = new Float32Array( colors.length * 3 );
284
+ // buffergeometry.setAttribute( 'color', new BufferAttribute( colorsArray, 3 ).copyColorsArray( colors ) );
285
+ // }
286
+ buffergeometry.setIndex(indices),buffergeometry.groups=this.computeGroups()}return buffergeometry},computeTangents:function computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")},computeLineDistances:function computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")},applyMatrix:function applyMatrix(matrix){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(matrix)},dispose:function dispose(){this.dispatchEvent({type:"dispose"})}}),Geometry.createBufferGeometryFromObject=function(object){var buffergeometry=new three__WEBPACK_IMPORTED_MODULE_0__["BufferGeometry"],geometry=object.geometry;if(object.isPoints||object.isLine){var positions=new three__WEBPACK_IMPORTED_MODULE_0__["Float32BufferAttribute"](3*geometry.vertices.length,3),colors=new three__WEBPACK_IMPORTED_MODULE_0__["Float32BufferAttribute"](3*geometry.colors.length,3);if(buffergeometry.setAttribute("position",positions.copyVector3sArray(geometry.vertices)),buffergeometry.setAttribute("color",colors.copyColorsArray(geometry.colors)),geometry.lineDistances&&geometry.lineDistances.length===geometry.vertices.length){var lineDistances=new three__WEBPACK_IMPORTED_MODULE_0__["Float32BufferAttribute"](geometry.lineDistances.length,1);buffergeometry.setAttribute("lineDistance",lineDistances.copyArray(geometry.lineDistances))}null!==geometry.boundingSphere&&(buffergeometry.boundingSphere=geometry.boundingSphere.clone()),null!==geometry.boundingBox&&(buffergeometry.boundingBox=geometry.boundingBox.clone())}else object.isMesh&&(buffergeometry=geometry.toBufferGeometry());return buffergeometry};class DirectGeometry{constructor(){// this.lineDistances = [];
278
287
  // update flags
279
288
  this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(geometry){var group,i,groups=[],materialIndex=void 0,faces=geometry.faces;for(i=0;i<faces.length;i++){var face=faces[i];// materials
280
- face.materialIndex!==materialIndex&&(materialIndex=face.materialIndex,group!==void 0&&(group.count=3*i-group.start,groups.push(group)),group={start:3*i,materialIndex:materialIndex})}group!==void 0&&(group.count=3*i-group.start,groups.push(group)),this.groups=groups}fromGeometry(geometry){var morphTargetsPosition,faces=geometry.faces,vertices=geometry.vertices,faceVertexUvs=geometry.faceVertexUvs,hasFaceVertexUv=faceVertexUvs[0]&&0<faceVertexUvs[0].length,hasFaceVertexUv2=faceVertexUvs[1]&&0<faceVertexUvs[1].length,morphTargets=geometry.morphTargets,morphTargetsLength=morphTargets.length;if(0<morphTargetsLength){morphTargetsPosition=[];for(var i=0;i<morphTargetsLength;i++)morphTargetsPosition[i]={name:morphTargets[i].name,data:[]};this.morphTargets.position=morphTargetsPosition}var morphTargetsNormal,morphNormals=geometry.morphNormals,morphNormalsLength=morphNormals.length;if(0<morphNormalsLength){morphTargetsNormal=[];for(var _i21=0;_i21<morphNormalsLength;_i21++)morphTargetsNormal[_i21]={name:morphNormals[_i21].name,data:[]};this.morphTargets.normal=morphTargetsNormal}// skins
281
- var skinIndices=geometry.skinIndices,skinWeights=geometry.skinWeights,hasSkinIndices=skinIndices.length===vertices.length,hasSkinWeights=skinWeights.length===vertices.length;0<vertices.length&&0===faces.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(var face,_i22=0;_i22<faces.length;_i22++){face=faces[_i22],this.vertices.push(vertices[face.a],vertices[face.b],vertices[face.c]);var vertexNormals=face.vertexNormals;if(3===vertexNormals.length)this.normals.push(vertexNormals[0],vertexNormals[1],vertexNormals[2]);else{var normal=face.normal;this.normals.push(normal,normal,normal)}var vertexColors=face.vertexColors;if(3===vertexColors.length)this.colors.push(vertexColors[0],vertexColors[1],vertexColors[2]);else{var color=face.color;this.colors.push(color,color,color)}if(!0===hasFaceVertexUv){var vertexUvs=faceVertexUvs[0][_i22];void 0===vertexUvs?(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",_i22),this.uvs.push(new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"],new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"],new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"])):this.uvs.push(vertexUvs[0],vertexUvs[1],vertexUvs[2])}if(!0===hasFaceVertexUv2){var _vertexUvs=faceVertexUvs[1][_i22];void 0===_vertexUvs?(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",_i22),this.uvs2.push(new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"],new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"],new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"])):this.uvs2.push(_vertexUvs[0],_vertexUvs[1],_vertexUvs[2])}// morphs
282
- for(var morphTarget,j=0;j<morphTargetsLength;j++)morphTarget=morphTargets[j].vertices,morphTargetsPosition[j].data.push(morphTarget[face.a],morphTarget[face.b],morphTarget[face.c]);for(var morphNormal,_j7=0;_j7<morphNormalsLength;_j7++)morphNormal=morphNormals[_j7].vertexNormals[_i22],morphTargetsNormal[_j7].data.push(morphNormal.a,morphNormal.b,morphNormal.c);// skins
283
- hasSkinIndices&&this.skinIndices.push(skinIndices[face.a],skinIndices[face.b],skinIndices[face.c]),hasSkinWeights&&this.skinWeights.push(skinWeights[face.a],skinWeights[face.b],skinWeights[face.c])}return this.computeGroups(geometry),this.verticesNeedUpdate=geometry.verticesNeedUpdate,this.normalsNeedUpdate=geometry.normalsNeedUpdate,this.colorsNeedUpdate=geometry.colorsNeedUpdate,this.uvsNeedUpdate=geometry.uvsNeedUpdate,this.groupsNeedUpdate=geometry.groupsNeedUpdate,null!==geometry.boundingSphere&&(this.boundingSphere=geometry.boundingSphere.clone()),null!==geometry.boundingBox&&(this.boundingBox=geometry.boundingBox.clone()),this}}class Face3{constructor(a,b,c,normal,color){var materialIndex=5<arguments.length&&arguments[5]!==void 0?arguments[5]:0;this.a=a,this.b=b,this.c=c,this.normal=normal&&normal.isVector3?normal:new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"],this.vertexNormals=Array.isArray(normal)?normal:[],this.color=color&&color.isColor?color:new three__WEBPACK_IMPORTED_MODULE_0__["Color"],this.vertexColors=Array.isArray(color)?color:[],this.materialIndex=materialIndex}clone(){return new this.constructor().copy(this)}copy(source){this.a=source.a,this.b=source.b,this.c=source.c,this.normal.copy(source.normal),this.color.copy(source.color),this.materialIndex=source.materialIndex;for(var i=0,il=source.vertexNormals.length;i<il;i++)this.vertexNormals[i]=source.vertexNormals[i].clone();for(var _i23=0,_il15=source.vertexColors.length;_i23<_il15;_i23++)this.vertexColors[_i23]=source.vertexColors[_i23].clone();return this}}
289
+ face.materialIndex!==materialIndex&&(materialIndex=face.materialIndex,group!==void 0&&(group.count=3*i-group.start,groups.push(group)),group={start:3*i,materialIndex:materialIndex})}group!==void 0&&(group.count=3*i-group.start,groups.push(group)),this.groups=groups}fromGeometry(geometry){var morphTargetsPosition,faces=geometry.faces,vertices=geometry.vertices,faceVertexUvs=geometry.faceVertexUvs,hasFaceVertexUv=faceVertexUvs[0]&&0<faceVertexUvs[0].length,hasFaceVertexUv2=faceVertexUvs[1]&&0<faceVertexUvs[1].length,morphTargets=geometry.morphTargets,morphTargetsLength=morphTargets.length;if(0<morphTargetsLength){morphTargetsPosition=[];for(var i=0;i<morphTargetsLength;i++)morphTargetsPosition[i]={name:morphTargets[i].name,data:[]};this.morphTargets.position=morphTargetsPosition}var morphTargetsNormal,morphNormals=geometry.morphNormals,morphNormalsLength=morphNormals.length;if(0<morphNormalsLength){morphTargetsNormal=[];for(var _i24=0;_i24<morphNormalsLength;_i24++)morphTargetsNormal[_i24]={name:morphNormals[_i24].name,data:[]};this.morphTargets.normal=morphTargetsNormal}// skins
290
+ var skinIndices=geometry.skinIndices,skinWeights=geometry.skinWeights,hasSkinIndices=skinIndices.length===vertices.length,hasSkinWeights=skinWeights.length===vertices.length;0<vertices.length&&0===faces.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(var face,_i25=0;_i25<faces.length;_i25++){face=faces[_i25],this.vertices.push(vertices[face.a],vertices[face.b],vertices[face.c]);var vertexNormals=face.vertexNormals;if(3===vertexNormals.length)this.normals.push(vertexNormals[0],vertexNormals[1],vertexNormals[2]);else{var normal=face.normal;this.normals.push(normal,normal,normal)}var vertexColors=face.vertexColors;if(3===vertexColors.length)this.colors.push(vertexColors[0],vertexColors[1],vertexColors[2]);else{var color=face.color;this.colors.push(color,color,color)}if(!0===hasFaceVertexUv){var vertexUvs=faceVertexUvs[0][_i25];void 0===vertexUvs?(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",_i25),this.uvs.push(new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"],new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"],new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"])):this.uvs.push(vertexUvs[0],vertexUvs[1],vertexUvs[2])}if(!0===hasFaceVertexUv2){var _vertexUvs=faceVertexUvs[1][_i25];void 0===_vertexUvs?(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",_i25),this.uvs2.push(new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"],new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"],new three__WEBPACK_IMPORTED_MODULE_0__["Vector2"])):this.uvs2.push(_vertexUvs[0],_vertexUvs[1],_vertexUvs[2])}// morphs
291
+ for(var morphTarget,j=0;j<morphTargetsLength;j++)morphTarget=morphTargets[j].vertices,morphTargetsPosition[j].data.push(morphTarget[face.a],morphTarget[face.b],morphTarget[face.c]);for(var morphNormal,_j7=0;_j7<morphNormalsLength;_j7++)morphNormal=morphNormals[_j7].vertexNormals[_i25],morphTargetsNormal[_j7].data.push(morphNormal.a,morphNormal.b,morphNormal.c);// skins
292
+ hasSkinIndices&&this.skinIndices.push(skinIndices[face.a],skinIndices[face.b],skinIndices[face.c]),hasSkinWeights&&this.skinWeights.push(skinWeights[face.a],skinWeights[face.b],skinWeights[face.c])}return this.computeGroups(geometry),this.verticesNeedUpdate=geometry.verticesNeedUpdate,this.normalsNeedUpdate=geometry.normalsNeedUpdate,this.colorsNeedUpdate=geometry.colorsNeedUpdate,this.uvsNeedUpdate=geometry.uvsNeedUpdate,this.groupsNeedUpdate=geometry.groupsNeedUpdate,null!==geometry.boundingSphere&&(this.boundingSphere=geometry.boundingSphere.clone()),null!==geometry.boundingBox&&(this.boundingBox=geometry.boundingBox.clone()),this}}class Face3{constructor(a,b,c,normal,color){var materialIndex=5<arguments.length&&arguments[5]!==void 0?arguments[5]:0;this.a=a,this.b=b,this.c=c,this.normal=normal&&normal.isVector3?normal:new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"],this.vertexNormals=Array.isArray(normal)?normal:[],this.color=color&&color.isColor?color:new three__WEBPACK_IMPORTED_MODULE_0__["Color"],this.vertexColors=Array.isArray(color)?color:[],this.materialIndex=materialIndex}clone(){return new this.constructor().copy(this)}copy(source){this.a=source.a,this.b=source.b,this.c=source.c,this.normal.copy(source.normal),this.color.copy(source.color),this.materialIndex=source.materialIndex;for(var i=0,il=source.vertexNormals.length;i<il;i++)this.vertexNormals[i]=source.vertexNormals[i].clone();for(var _i26=0,_il15=source.vertexColors.length;_i26<_il15;_i26++)this.vertexColors[_i26]=source.vertexColors[_i26].clone();return this}}
284
293
 
285
294
  /***/ }),
286
295
  /* 6 */
@@ -291,7 +300,7 @@ function loadExternalFile(url,data,callback,errorCallback){// Set up an asynchro
291
300
  var request=new XMLHttpRequest;// Hook the event that gets called as the request progresses
292
301
  request.open("GET",resolveURL(url),!0),request.onreadystatechange=()=>{4==request.readyState&&(200==request.status?callback(request.responseText,data):errorCallback(url))},request.send(null)}function loadExternalFiles(urls,callback,errorCallback){// Callback for a single file
293
302
  function partialCallback(text,urlIndex){result[urlIndex]=text,numComplete++,numComplete==numUrls&&callback(result)}for(var numUrls=urls.length,numComplete=0,result=[],i=0;i<numUrls;i++)loadExternalFile(urls[i],i,partialCallback,errorCallback)}//Get the colours at index
294
- exports.getColorsRGB=(colors,index)=>{var index_in_colors=Math.floor(index/3),remainder=index%3,hex_value=0;0==remainder?hex_value=colors[index_in_colors].r:1==remainder?hex_value=colors[index_in_colors].g:2==remainder&&(hex_value=colors[index_in_colors].b);var mycolor=new THREE.Color(hex_value);return[mycolor.r,mycolor.g,mycolor.b]},exports.copyMorphColorsToBufferGeometry=(geometry,bufferGeometry)=>{if(geometry&&geometry.morphColors&&0<geometry.morphColors.length){for(var array=[],morphColors=geometry.morphColors,getColorsRGB=__webpack_require__(6).getColorsRGB,i=0,l=morphColors.length;i<l;i++){for(var morphColor=morphColors[i],colorArray=[],j=0;j<geometry.faces.length;j++){var face=geometry.faces[j],color=getColorsRGB(morphColor.colors,face.a);colorArray.push(color[0],color[1],color[2]),color=getColorsRGB(morphColor.colors,face.b),colorArray.push(color[0],color[1],color[2]),color=getColorsRGB(morphColor.colors,face.c),colorArray.push(color[0],color[1],color[2])}var attribute=new THREE.Float32BufferAttribute(3*(3*geometry.faces.length),3);attribute.name=morphColor.name,array.push(attribute.copyArray(colorArray))}bufferGeometry.morphAttributes.color=array}},exports.mergeVertices=function(geometry){var tolerance=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1e-4;tolerance=Math.max(tolerance,Number.EPSILON);// initialize the arrays
303
+ exports.getColorsRGB=(colors,index)=>{var index_in_colors=Math.floor(index/3),remainder=index%3,hex_value=0;0==remainder?hex_value=colors[index_in_colors].r:1==remainder?hex_value=colors[index_in_colors].g:2==remainder&&(hex_value=colors[index_in_colors].b);var mycolor=new THREE.Color(hex_value);return[mycolor.r,mycolor.g,mycolor.b]},exports.copyMorphColorsToBufferGeometry=(geometry,bufferGeometry)=>{if(geometry&&geometry.morphColors&&0<geometry.morphColors.length){for(var array=[],morphColors=geometry.morphColors,getColorsRGB=__webpack_require__(6).getColorsRGB,i=0,l=morphColors.length;i<l;i++){for(var morphColor=morphColors[i],colorArray=[],j=0;j<geometry.faces.length;j++){var face=geometry.faces[j],color=getColorsRGB(morphColor.colors,face.a);colorArray.push(color[0],color[1],color[2]),color=getColorsRGB(morphColor.colors,face.b),colorArray.push(color[0],color[1],color[2]),color=getColorsRGB(morphColor.colors,face.c),colorArray.push(color[0],color[1],color[2])}var attribute=new THREE.Float32BufferAttribute(3*(3*geometry.faces.length),3);attribute.name=morphColor.name,array.push(attribute.copyArray(colorArray))}bufferGeometry.morphAttributes.color=array}},exports.copyMorphColorsToIndexedBufferGeometry=(geometry,bufferGeometry)=>{if(geometry&&geometry.morphColors&&0<geometry.morphColors.length){for(var array=[],morphColors=geometry.morphColors,getColorsRGB=__webpack_require__(6).getColorsRGB,i=0,l=morphColors.length;i<l;i++){for(var color,morphColor=morphColors[i],colorArray=[],j=0;j<3*morphColor.colors.length;j++)color=getColorsRGB(morphColor.colors,j),colorArray.push(color[0],color[1],color[2]);var attribute=new THREE.Float32BufferAttribute(3*colorArray.length,3);attribute.name=morphColor.name,array.push(attribute.copyArray(colorArray))}bufferGeometry.morphAttributes.color=array}},exports.mergeVertices=function(geometry){var tolerance=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1e-4;tolerance=Math.max(tolerance,Number.EPSILON);// initialize the arrays
295
304
  for(var name,hashToIndex={},indices=geometry.getIndex(),positions=geometry.getAttribute("position"),vertexCount=indices?indices.count:positions.count,nextIndex=0,attributeNames=Object.keys(geometry.attributes),attrArrays={},morphAttrsArrays={},newIndices=[],getters=["getX","getY","getZ","getW"],i=0,l=attributeNames.length;i<l;i++){name=attributeNames[i],attrArrays[name]=[];var morphAttr=geometry.morphAttributes[name];morphAttr&&(morphAttrsArrays[name]=Array(morphAttr.length).fill().map(()=>[]))}// convert the error tolerance to an amount of decimal places to truncate to
296
305
  for(var decimalShift=Math.log10(1/tolerance),shiftMultiplier=Math.pow(10,decimalShift),i=0;i<vertexCount;i++){for(var index=indices?indices.getX(i):i,hash="",j=0,l=attributeNames.length;j<l;j++)for(var name=attributeNames[j],attribute=geometry.getAttribute(name),itemSize=attribute.itemSize,k=0;k<itemSize;k++)// double tilde truncates the decimal value
297
306
  hash+="".concat(~~(attribute[getters[k]](index)*shiftMultiplier),",");// Add another reference to the vertex if it's already
@@ -307,7 +316,7 @@ var cons=Uint8Array;newIndices.length>=Math.pow(2,8)&&(cons=Uint16Array),newIndi
307
316
  /* 7 */
308
317
  /***/ (function(module, exports, __webpack_require__) {
309
318
 
310
- var THREE=__webpack_require__(3),markerImage=new Image(128,128);markerImage.src=__webpack_require__(8);var texture=new THREE.Texture;texture.image=markerImage,texture.needsUpdate=!0;var size=[.015,.02,1],Marker=function(zincObject){__webpack_require__(4).ZincObject.call(this),this.texture=texture;var spriteMaterial=void 0,sprite=void 0;this.morph=new THREE.Group,this.parent=zincObject,this.isMarker=!0;var enabled=!1,vector=new THREE.Vector3,initialise=()=>{spriteMaterial=new THREE.SpriteMaterial({map:texture,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),sprite=new THREE.Sprite(spriteMaterial),sprite.center.set(.5,0),this.morph.add(sprite),this.morph.position.set(0,0,0),this.morph.renderOrder=3,sprite.scale.set(size[0],size[1],size[2]),sprite.userData=this};//this should be handle by scene... check the sync at
319
+ var THREE=__webpack_require__(3),markerImage=new Image(128,128);markerImage.src=__webpack_require__(8);var texture=new THREE.Texture;texture.image=markerImage,texture.needsUpdate=!0;var size=[.015,.02,1],Marker=function(zincObject){__webpack_require__(4).ZincObject.call(this),this.texture=texture;var spriteMaterial=void 0,sprite=void 0;this.morph=new THREE.Group,this.parent=zincObject,this.isMarker=!0;var enabled=!1,vector=new THREE.Vector3,initialise=()=>{spriteMaterial=new THREE.SpriteMaterial({map:texture,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),sprite=new THREE.Sprite(spriteMaterial),sprite.center.set(.5,0),this.morph.add(sprite),this.morph.position.set(0,0,0),this.morph.renderOrder=1e4,sprite.scale.set(size[0],size[1],size[2]),sprite.userData=this};//this should be handle by scene... check the sync at
311
320
  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.isEnabled=()=>enabled,this.enable=()=>{enabled=!0,this.morph.visible=!0},this.disable=()=>{enabled=!1,this.morph.visible=!1},initialise()};//Marker - used to indicate there is a
312
321
  Marker.prototype=Object.create(__webpack_require__(4).ZincObject.prototype),exports.Marker=Marker;
313
322
 
@@ -386,7 +395,7 @@ module.exports = require("three-spritetext");
386
395
  var THREE=__webpack_require__(3),JSONLoader=__webpack_require__(14).JSONLoader,Glyphset=function(){__webpack_require__(4).ZincObject.call(this);var glyphList=[],axis1s=void 0,axis2s=void 0,axis3s=void 0,positions=void 0,scales=void 0,colors=void 0,labels=void 0,numberOfTimeSteps=0,numberOfVertices=0,baseSize=[0,0,0],offset=[0,0,0],scaleFactors=[0,0,0],repeat_mode="NONE";this.ready=!1;var morphColours=!1,morphVertices=!1;this.isGlyphset=!0;for(var _transformMatrix=new THREE.Matrix4,_bot_colour=new THREE.Color,_top_colour=new THREE.Color,_boundingBox1=new THREE.Box3,_boundingBox2=new THREE.Box3,_boundingBox3=new THREE.Box3,_points=[],i=0;8>i;i++)_points[i]=new THREE.Vector3;/**
387
396
  * Get the {@link Three.Group} containing all of the glyphs' meshes.
388
397
  * @returns {Three.Group}
389
- */this.getGroup=()=>this.morph,this.load=(glyphsetData,glyphURL,finishCallback,isInline,displayLabels)=>{axis1s=glyphsetData.axis1,axis2s=glyphsetData.axis2,axis3s=glyphsetData.axis3,positions=glyphsetData.positions,scales=glyphsetData.scale,colors=glyphsetData.colors,labels=glyphsetData.label,morphColours=glyphsetData.metadata.MorphColours,morphVertices=glyphsetData.metadata.MorphVertices,numberOfTimeSteps=glyphsetData.metadata.number_of_time_steps,repeat_mode=glyphsetData.metadata.repeat_mode,numberOfVertices=glyphsetData.metadata.number_of_vertices,"AXES_2D"==repeat_mode||"MIRROR"==repeat_mode?numberOfVertices*=2:"AXES_3D"==repeat_mode&&(numberOfVertices*=3),baseSize=glyphsetData.metadata.base_size,offset=glyphsetData.metadata.offset,scaleFactors=glyphsetData.metadata.scale_factors;var loader=new JSONLoader;if(this.geometry=new THREE.BufferGeometry,this.morph=new THREE.InstancedMesh(this.geometry,void 0,numberOfVertices),isInline){var object=loader.parse(glyphURL);meshloader(finishCallback,displayLabels)(object.geometry,object.materials)}else loader.crossOrigin="Anonymous",loader.load(glyphURL,meshloader(finishCallback,displayLabels))};/**
398
+ */this.getGroup=()=>this.morph,this.load=(glyphsetData,glyphURL,finishCallback,isInline,displayLabels)=>{axis1s=glyphsetData.axis1,axis2s=glyphsetData.axis2,axis3s=glyphsetData.axis3,positions=glyphsetData.positions,scales=glyphsetData.scale,colors=glyphsetData.colors,labels=glyphsetData.label,morphColours=glyphsetData.metadata.MorphColours,morphVertices=glyphsetData.metadata.MorphVertices,numberOfTimeSteps=glyphsetData.metadata.number_of_time_steps,repeat_mode=glyphsetData.metadata.repeat_mode,numberOfVertices=glyphsetData.metadata.number_of_vertices,"AXES_2D"==repeat_mode||"MIRROR"==repeat_mode?numberOfVertices*=2:"AXES_3D"==repeat_mode&&(numberOfVertices*=3),baseSize=glyphsetData.metadata.base_size,offset=glyphsetData.metadata.offset,scaleFactors=glyphsetData.metadata.scale_factors;var loader=new JSONLoader;if(this.geometry=new THREE.BufferGeometry,this.morph=new THREE.InstancedMesh(this.geometry,void 0,numberOfVertices),isInline){var object=loader.parse(glyphURL);meshloader(finishCallback,displayLabels)(object.geometry,object.materials),object.geometry.dispose()}else loader.crossOrigin="Anonymous",loader.load(glyphURL,meshloader(finishCallback,displayLabels))};/**
390
399
  * Calculate the actual transformation value that can be applied
391
400
  * to the transformation matrix.
392
401
  * @returns {Array}
@@ -397,7 +406,7 @@ var THREE=__webpack_require__(3),JSONLoader=__webpack_require__(14).JSONLoader,G
397
406
  */else current_colors=colors[0];updateGlyphsetHexColors(current_colors)}current_positions=null,current_axis1s=null,current_axis2s=null,current_axis3s=null,current_scales=null,current_colors=null};/**
398
407
  * Update transformation for each of the glyph in this glyphset.
399
408
  */this.showLabel=()=>{for(var _i5=0;_i5<glyphList.length;_i5++)glyphList[_i5].showLabel(this.morph.material?this.morph.material.color:void 0)};var createGlyphs=displayLabels=>{if(labels!=null&&displayLabels)for(var glyph,_i6=0;_i6<numberOfVertices;_i6++)glyph=new(__webpack_require__(10).Glyph)(void 0,void 0,_i6,this),null!=labels&&null!=labels[_i6]&&glyph.setLabel(labels[_i6]),0<numberOfTimeSteps&&glyph.setFrustumCulled(!1),glyphList[_i6]=glyph,this.morph.add(glyph.getGroup());//Update the transformation of the glyphs.
400
- labels!=null&&displayLabels&&this.showLabel(this.morph.material?this.morph.material.color:void 0),updateGlyphsetTransformation(positions[0],axis1s[0],axis2s[0],axis3s[0],scales[0]),colors!=null&&updateGlyphsetHexColors(colors[0]),this.ready=!0,this.boundingBoxUpdateRequired=!0};this.addCustomGlyph=glyph=>{glyph.isGlyph&&glyphList.push(glyph),this.ready=!0,this.boundingBoxUpdateRequired=!0},this.addMeshAsGlyph=(mesh,id)=>{if(mesh.isMesh){var glyph=new(__webpack_require__(10).Glyph)(void 0,void 0,id,this);return glyph.fromMesh(mesh),glyphList.push(glyph),this.morph.add(glyph.getGroup()),this.ready=!0,this.boundingBoxUpdateRequired=!0,glyph}},this.forEachGlyph=callbackFunction=>{for(var _i7=0;_i7<glyphList.length;_i7++)callbackFunction(glyphList[_i7])};var meshloader=(finishCallback,displayLabels)=>(geometry,materials)=>{this.geometry.copy(geometry.toBufferGeometry()),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox(),materials&&materials[0]&&(this.morph.material=materials[0]),createGlyphs(displayLabels),this.morph.name=this.groupName,this.morph.userData=this,null!=finishCallback&&"function"==typeof finishCallback&&finishCallback(this)};/**
409
+ labels!=null&&displayLabels&&this.showLabel(this.morph.material?this.morph.material.color:void 0),updateGlyphsetTransformation(positions[0],axis1s[0],axis2s[0],axis3s[0],scales[0]),colors!=null&&updateGlyphsetHexColors(colors[0]),this.ready=!0,this.boundingBoxUpdateRequired=!0};this.addCustomGlyph=glyph=>{glyph.isGlyph&&glyphList.push(glyph),this.ready=!0,this.boundingBoxUpdateRequired=!0},this.addMeshAsGlyph=(mesh,id)=>{if(mesh.isMesh){var glyph=new(__webpack_require__(10).Glyph)(void 0,void 0,id,this);return glyph.fromMesh(mesh),glyphList.push(glyph),this.morph.add(glyph.getGroup()),this.ready=!0,this.boundingBoxUpdateRequired=!0,glyph}},this.forEachGlyph=callbackFunction=>{for(var _i7=0;_i7<glyphList.length;_i7++)callbackFunction(glyphList[_i7])};var meshloader=(finishCallback,displayLabels)=>(geometry,materials)=>{var tempGeometry=geometry.toBufferGeometry();this.geometry.copy(tempGeometry),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox(),tempGeometry.dispose(),materials&&materials[0]&&(this.morph.material=materials[0]),createGlyphs(displayLabels),this.morph.name=this.groupName,this.morph.userData=this,geometry.dispose(),null!=finishCallback&&"function"==typeof finishCallback&&finishCallback(this)};/**
401
410
  * Get the index of the closest vertex to centroid.
402
411
  */ /**
403
412
  * Get the closest vertex to centroid.
@@ -440,8 +449,8 @@ __webpack_require__.r(__webpack_exports__);
440
449
  var THREE=__webpack_require__(3),Loader=__webpack_require__(15).Loader,LoaderUtils=THREE.LoaderUtils,AnimationClip=THREE.AnimationClip,Vector3=THREE.Vector3,Vector4=THREE.Vector4,Color=THREE.Color,Vector2=THREE.Vector2,Face3=__webpack_require__(5).Face3,Geometry=__webpack_require__(5).Geometry,FileLoader=THREE.FileLoader,DefaultLoadingManager=THREE.DefaultLoadingManager;/**
441
450
  * @author mrdoob / http://mrdoob.com/
442
451
  * @author alteredq / http://alteredqualia.com/
443
- */function JSONLoader(manager){"boolean"==typeof manager&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),manager=void 0),this.manager=manager===void 0?DefaultLoadingManager:manager,this.withCredentials=!1}Object.assign(JSONLoader.prototype,{load:function load(url,onLoad,onProgress,onError){var scope=this,texturePath=this.texturePath&&"string"==typeof this.texturePath?this.texturePath:LoaderUtils.extractUrlBase(url),loader=new FileLoader(this.manager);loader.setWithCredentials(this.withCredentials),loader.load(url,function(text){var json=JSON.parse(text),metadata=json.metadata;if(metadata!==void 0){var type=metadata.type;if(type!==void 0&&"object"===type.toLowerCase())return void console.error("THREE.JSONLoader: "+url+" should be loaded with THREE.ObjectLoader instead.")}var object=scope.parse(json,texturePath);onLoad(object.geometry,object.materials)},onProgress,onError)},setTexturePath:function setTexturePath(value){this.texturePath=value},parse:function(){function parseModel(json,geometry){function isBitSet(value,position){return value&1<<position}var i,j,fi,offset,zLength,colorIndex,normalIndex,uvIndex,materialIndex,type,isQuad,hasMaterial,hasFaceVertexUv,hasFaceNormal,hasFaceVertexNormal,hasFaceColor,hasFaceVertexColor,vertex,face,faceA,faceB,hex,normal,uvLayer,uv,u,v,faces=json.faces,vertices=json.vertices,normals=json.normals,colors=json.colors,scale=json.scale,nUvLayers=0;if(json.uvs!==void 0){// disregard empty arrays
444
- for(i=0;i<json.uvs.length;i++)json.uvs[i].length&&nUvLayers++;for(i=0;i<nUvLayers;i++)geometry.faceVertexUvs[i]=[]}for(offset=0,zLength=vertices.length;offset<zLength;)vertex=new Vector3,vertex.x=vertices[offset++]*scale,vertex.y=vertices[offset++]*scale,vertex.z=vertices[offset++]*scale,geometry.vertices.push(vertex);for(offset=0,zLength=faces.length;offset<zLength;)// console.log("type", type, "bits", isQuad, hasMaterial, hasFaceVertexUv, hasFaceNormal, hasFaceVertexNormal, hasFaceColor, hasFaceVertexColor);
452
+ */function JSONLoader(manager){"boolean"==typeof manager&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),manager=void 0),this.manager=manager===void 0?DefaultLoadingManager:manager,this.withCredentials=!1}Object.assign(JSONLoader.prototype,{load:function load(url,onLoad,onProgress,onError){var scope=this,texturePath=this.texturePath&&"string"==typeof this.texturePath?this.texturePath:LoaderUtils.extractUrlBase(url),loader=new FileLoader(this.manager);loader.setWithCredentials(this.withCredentials),loader.load(url,function(text){var json=JSON.parse(text),metadata=json.metadata;if(metadata!==void 0){var type=metadata.type;if(type!==void 0&&"object"===type.toLowerCase())return void console.error("THREE.JSONLoader: "+url+" should be loaded with THREE.ObjectLoader instead.")}var object=scope.parse(json,texturePath);onLoad(object.geometry,object.materials)},onProgress,onError)},setTexturePath:function setTexturePath(value){this.texturePath=value},parse:function(){function parseModel(json,geometry){function isBitSet(value,position){return value&1<<position}var i,j,fi,offset,zLength,colorIndex,normalIndex,uvIndex,materialIndex,type,isQuad,hasMaterial,hasFaceVertexUv,hasFaceNormal,hasFaceVertexNormal,hasFaceColor,hasFaceVertexColor,vertex,face,faceA,faceB,hex,normal,uvLayer,uv,u,v,faces=json.faces,vertices=json.vertices,normals=json.normals,colors=json.colors,scale=json.scale,nUvLayers=0;if(void 0!==json.uvs){// disregard empty arrays
453
+ for(i=0;i<json.uvs.length;i++)json.uvs[i].length&&nUvLayers++;for(i=0;i<nUvLayers;i++)geometry.faceVertexUvs[i]=[]}for(offset=0,zLength=vertices.length;offset<zLength;)vertex=new Vector3,vertex.x=vertices[offset++]*scale,vertex.y=vertices[offset++]*scale,vertex.z=vertices[offset++]*scale,geometry.vertices.push(vertex);if(offset=0,zLength=faces.length,json.uvs)for(i=0;i<json.uvs.length;i++){geometry.uvs[i]=[];for(var k=0;k<json.uvs[i].length;k++)geometry.uvs[i][k]=json.uvs[i][k]}if(normals)for(i=0;i<normals.length;i++)geometry.normals[i]=normals[i];if(colors)for(i=0;i<colors.length;i++)geometry.colors[i]=colors[i];for(;offset<zLength;)// console.log("type", type, "bits", isQuad, hasMaterial, hasFaceVertexUv, hasFaceNormal, hasFaceVertexNormal, hasFaceColor, hasFaceVertexColor);
445
454
  if(type=faces[offset++],isQuad=isBitSet(type,0),hasMaterial=isBitSet(type,1),hasFaceVertexUv=isBitSet(type,3),hasFaceNormal=isBitSet(type,4),hasFaceVertexNormal=isBitSet(type,5),hasFaceColor=isBitSet(type,6),hasFaceVertexColor=isBitSet(type,7),isQuad){if(faceA=new Face3,faceA.a=faces[offset],faceA.b=faces[offset+1],faceA.c=faces[offset+3],faceB=new Face3,faceB.a=faces[offset+1],faceB.b=faces[offset+2],faceB.c=faces[offset+3],offset+=4,hasMaterial&&(materialIndex=faces[offset++],faceA.materialIndex=materialIndex,faceB.materialIndex=materialIndex),fi=geometry.faces.length,hasFaceVertexUv)for(i=0;i<nUvLayers;i++)for(uvLayer=json.uvs[i],geometry.faceVertexUvs[i][fi]=[],geometry.faceVertexUvs[i][fi+1]=[],j=0;4>j;j++)uvIndex=faces[offset++],u=uvLayer[2*uvIndex],v=uvLayer[2*uvIndex+1],uv=new Vector2(u,v),2!==j&&geometry.faceVertexUvs[i][fi].push(uv),0!==j&&geometry.faceVertexUvs[i][fi+1].push(uv);if(hasFaceNormal&&(normalIndex=3*faces[offset++],faceA.normal.set(normals[normalIndex++],normals[normalIndex++],normals[normalIndex]),faceB.normal.copy(faceA.normal)),hasFaceVertexNormal)for(i=0;4>i;i++)normalIndex=3*faces[offset++],normal=new Vector3(normals[normalIndex++],normals[normalIndex++],normals[normalIndex]),2!==i&&faceA.vertexNormals.push(normal),0!==i&&faceB.vertexNormals.push(normal);if(hasFaceColor&&(colorIndex=faces[offset++],hex=colors[colorIndex],faceA.color.setHex(hex),faceB.color.setHex(hex)),hasFaceVertexColor)for(i=0;4>i;i++)colorIndex=faces[offset++],hex=colors[colorIndex],2!==i&&faceA.vertexColors.push(new Color(hex)),0!==i&&faceB.vertexColors.push(new Color(hex));geometry.faces.push(faceA),geometry.faces.push(faceB)}else{if(face=new Face3,face.a=faces[offset++],face.b=faces[offset++],face.c=faces[offset++],hasMaterial&&(materialIndex=faces[offset++],face.materialIndex=materialIndex),fi=geometry.faces.length,hasFaceVertexUv)for(i=0;i<nUvLayers;i++)for(uvLayer=json.uvs[i],geometry.faceVertexUvs[i][fi]=[],j=0;3>j;j++)uvIndex=faces[offset++],u=uvLayer[2*uvIndex],v=uvLayer[2*uvIndex+1],uv=new Vector2(u,v),geometry.faceVertexUvs[i][fi].push(uv);if(hasFaceNormal&&(normalIndex=3*faces[offset++],face.normal.set(normals[normalIndex++],normals[normalIndex++],normals[normalIndex])),hasFaceVertexNormal)for(i=0;3>i;i++)normalIndex=3*faces[offset++],normal=new Vector3(normals[normalIndex++],normals[normalIndex++],normals[normalIndex]),face.vertexNormals.push(normal);if(hasFaceColor&&(colorIndex=faces[offset++],face.color.setHex(colors[colorIndex])),hasFaceVertexColor)for(i=0;3>i;i++)colorIndex=faces[offset++],face.vertexColors.push(new Color(colors[colorIndex]));geometry.faces.push(face)}}function parseSkin(json,geometry){var influencesPerVertex=json.influencesPerVertex===void 0?2:json.influencesPerVertex;if(json.skinWeights)for(var i=0,l=json.skinWeights.length;i<l;i+=influencesPerVertex){var x=json.skinWeights[i],y=1<influencesPerVertex?json.skinWeights[i+1]:0,z=2<influencesPerVertex?json.skinWeights[i+2]:0,w=3<influencesPerVertex?json.skinWeights[i+3]:0;geometry.skinWeights.push(new Vector4(x,y,z,w))}if(json.skinIndices)for(var i=0,l=json.skinIndices.length;i<l;i+=influencesPerVertex){var a=json.skinIndices[i],b=1<influencesPerVertex?json.skinIndices[i+1]:0,c=2<influencesPerVertex?json.skinIndices[i+2]:0,d=3<influencesPerVertex?json.skinIndices[i+3]:0;geometry.skinIndices.push(new Vector4(a,b,c,d))}geometry.bones=json.bones,geometry.bones&&0<geometry.bones.length&&(geometry.skinWeights.length!==geometry.skinIndices.length||geometry.skinIndices.length!==geometry.vertices.length)&&console.warn("When skinning, number of vertices ("+geometry.vertices.length+"), skinIndices ("+geometry.skinIndices.length+"), and skinWeights ("+geometry.skinWeights.length+") should match.")}function parseMorphing(json,geometry){var scale=json.scale;if(json.morphTargets!==void 0)for(var i=0,l=json.morphTargets.length;i<l;i++){geometry.morphTargets[i]={},geometry.morphTargets[i].name=json.morphTargets[i].name,geometry.morphTargets[i].vertices=[];for(var vertex,dstVertices=geometry.morphTargets[i].vertices,srcVertices=json.morphTargets[i].vertices,v=0,vl=srcVertices.length;v<vl;v+=3)vertex=new Vector3,vertex.x=srcVertices[v]*scale,vertex.y=srcVertices[v+1]*scale,vertex.z=srcVertices[v+2]*scale,dstVertices.push(vertex)}if(void 0!==json.morphColors){var i,l,c,cl,dstColors,srcColors,color;for(i=0,l=json.morphColors.length;i<l;i++)for(geometry.morphColors[i]={},geometry.morphColors[i].name=json.morphColors[i].name,geometry.morphColors[i].colors=[],dstColors=geometry.morphColors[i].colors,srcColors=json.morphColors[i].colors,(c=0,cl=srcColors.length);c<cl;c+=3)color=new THREE.Color(16755200),color.setRGB(srcColors[c],srcColors[c+1],srcColors[c+2]),dstColors.push(color)}}function parseAnimations(json,geometry){var outputAnimations=[],animations=[];// parse old style Bone/Hierarchy animations
446
455
  json.animation!==void 0&&animations.push(json.animation),json.animations!==void 0&&(json.animations.length?animations=animations.concat(json.animations):animations.push(json.animations));for(var clip,i=0;i<animations.length;i++)clip=AnimationClip.parseAnimation(animations[i],geometry.bones),clip&&outputAnimations.push(clip);// parse implicit morph animations
447
456
  if(geometry.morphTargets){// TODO: Figure out what an appropraite FPS is for morph target animations -- defaulting to 10, but really it is completely arbitrary.
@@ -501,7 +510,7 @@ module.exports = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABz
501
510
  /* 20 */
502
511
  /***/ (function(module, exports, __webpack_require__) {
503
512
 
504
- var THREE=__webpack_require__(3),Lines=function(){__webpack_require__(4).ZincObject.call(this),this.isLines=!0,this.createLineSegment=(geometryIn,materialIn,options)=>{if(geometryIn&&materialIn){var geometry=this.toBufferGeometry(geometryIn,options),line=new(__webpack_require__(21).LineSegments)(geometry,materialIn);this.setMesh(line,options.localTimeEnabled,options.localMorphColour)}},this.setWidth=width=>{this.morph&&this.morph.material&&(this.morph.material.linewidth=width,this.morph.material.needsUpdate=!0)}};/**
513
+ var THREE=__webpack_require__(3),Lines=function(){__webpack_require__(4).ZincObject.call(this),this.isLines=!0,this.createLineSegment=(geometryIn,materialIn,options)=>{if(geometryIn&&materialIn){var geometry=this.toBufferGeometry(geometryIn,options);options.localMorphColour&&geometry.morphAttributes.color&&(materialIn.onBeforeCompile=__webpack_require__(9).augmentMorphColor());var line=new(__webpack_require__(21).LineSegments)(geometry,materialIn);this.setMesh(line,options.localTimeEnabled,options.localMorphColour)}},this.setWidth=width=>{this.morph&&this.morph.material&&(this.morph.material.linewidth=width,this.morph.material.needsUpdate=!0)}};/**
505
514
  * Provides an object which stores points and provides method which controls its position.
506
515
  * This is created when a valid json file containing point is read into a {@link Zinc.Scene}
507
516
  * object.
@@ -606,7 +615,7 @@ module.exports = require("css-element-queries/src/ResizeSensor");
606
615
  /* 25 */
607
616
  /***/ (function(module, exports, __webpack_require__) {
608
617
 
609
- var THREE=__webpack_require__(3),SceneLoader=__webpack_require__(26).SceneLoader,defaultMetadata=function(){return{Duration:"6 secs",OriginalDuration:"-",TimeStamps:{}}},defaultDuration=6e3;/**
618
+ var THREE=__webpack_require__(3),SceneLoader=__webpack_require__(26).SceneLoader,SceneExporter=__webpack_require__(30).SceneExporter,defaultMetadata=function(){return{Duration:"6 secs",OriginalDuration:"-",TimeStamps:{}}},defaultDuration=6e3;/**
610
619
  * A Zinc.Scene contains {@link Zinc.Geometry}, {@link Zinc.Glyphset} and
611
620
  * {@link Zinc.CameraControls} which controls the viewport and additional features.
612
621
  * It is the main object used for controlling what is and what is not displayed
@@ -617,11 +626,11 @@ var THREE=__webpack_require__(3),SceneLoader=__webpack_require__(26).SceneLoader
617
626
  * @author Alan Wu
618
627
  * @return {Zinc.Scene}
619
628
  */exports.Scene=function(containerIn,rendererIn){var container=containerIn,zincObjects=[],videoHandler=void 0,sceneLoader=new SceneLoader(this),minimap=void 0,scene=new THREE.Scene;this.directionalLight=void 0,this.ambient=void 0,this.camera=void 0;var duration=6e3,zincCameraControls=void 0;this.sceneName=void 0;var stereoEffectFlag=!1,stereoEffect=void 0;this.autoClearFlag=!0,this.displayMarkers=!1,this.displayMinimap=!1,this.minimapScissor={x_offset:16,y_offset:16,width:128,height:128,align:"top-left",updateRequired:!0};var scissor={x:0,y:0},metadata=defaultMetadata(),_markerTarget=new THREE.Vector2,getDrawingWidth=()=>container?"undefined"==typeof container.clientWidth?container.width:container.clientWidth:0,getDrawingHeight=()=>container?"undefined"==typeof container.clientHeight?container.height:container.clientHeight:0;this.getDownloadProgress=()=>sceneLoader.getDownloadProgress(),this.onWindowResize=()=>{zincCameraControls.onResize(),this.camera.aspect=getDrawingWidth()/getDrawingHeight(),this.camera.updateProjectionMatrix(),this.minimapScissor.updateRequired=!0},this.resetView=()=>{this.onWindowResize(),zincCameraControls.resetView()},this.changeZoomByScrollRateUnit=unit=>{zincCameraControls.changeZoomByScrollRateUnit(unit)};//Setup the camera for this scene, it also initialise the lighting
620
- var setupCamera=()=>{this.camera=new THREE.PerspectiveCamera(40,getDrawingWidth()/getDrawingHeight(),0,10),this.ambient=new THREE.AmbientLight(16777215,.2),scene.add(this.ambient),this.directionalLight=new THREE.DirectionalLight(16777215,.8),scene.add(this.directionalLight),zincCameraControls=new(__webpack_require__(29).CameraControls)(this.camera,rendererIn.domElement,rendererIn,this),zincCameraControls.setDirectionalLight(this.directionalLight),zincCameraControls.resetView(),minimap=new(__webpack_require__(30).Minimap)(this)};setupCamera(),this.loadView=(_ref)=>{var{nearPlane,farPlane,eyePosition,targetPosition,upVector}=_ref,viewPort=new(__webpack_require__(29).Viewport);return viewPort.nearPlane=nearPlane,viewPort.farPlane=farPlane,viewPort.eyePosition=eyePosition,viewPort.targetPosition=targetPosition,viewPort.upVector=upVector,zincCameraControls.setDefaultCameraSettings(viewPort),zincCameraControls.resetView(),!0},this.getBoundingBox=()=>{for(var boundingBox1=void 0,boundingBox2=void 0,i=0;i<zincObjects.length;i++)boundingBox2=zincObjects[i].getBoundingBox(),null==boundingBox1?boundingBox1=boundingBox2:boundingBox2&&boundingBox1.union(boundingBox2);return boundingBox1},this.viewAllWithBoundingBox=boundingBox=>{if(boundingBox){// enlarge radius to keep image within edge of window
621
- var radius=boundingBox.min.distanceTo(boundingBox.max)/2,centreX=(boundingBox.min.x+boundingBox.max.x)/2,centreY=(boundingBox.min.y+boundingBox.max.y)/2,centreZ=(boundingBox.min.z+boundingBox.max.z)/2,viewport=zincCameraControls.getViewportFromCentreAndRadius(centreX,centreY,centreZ,radius,40,radius*4);zincCameraControls.setCurrentCameraSettings(viewport)}},this.viewAll=()=>{var boundingBox=this.getBoundingBox();this.viewAllWithBoundingBox(boundingBox)},this.forEachGeometry=callbackFunction=>{for(var i=zincObjects.length-1;0<=i;i--)zincObjects[i].isGeometry&&callbackFunction(zincObjects[i])},this.forEachGlyphset=callbackFunction=>{for(var i=zincObjects.length-1;0<=i;i--)zincObjects[i].isGlyphset&&callbackFunction(zincObjects[i])},this.forEachPointset=callbackFunction=>{for(var i=zincObjects.length-1;0<=i;i--)zincObjects[i].isPointset&&callbackFunction(zincObjects[i])},this.forEachLine=callbackFunction=>{for(var i=zincObjects.length-1;0<=i;i--)zincObjects[i].isLines&&callbackFunction(zincObjects[i])},this.findGeometriesWithGroupName=GroupName=>{for(var geometriesArray=[],i=0;i<zincObjects.length;i++)zincObjects[i].isGeometry&&zincObjects[i].groupName==GroupName&&geometriesArray.push(zincObjects[i]);return geometriesArray},this.findPointsetsWithGroupName=GroupName=>{for(var pointsetsArray=[],i=0;i<zincObjects.length;i++)zincObjects[i].isPointset&&zincObjects[i].groupName==GroupName&&pointsetsArray.push(zincObjects[i]);return pointsetsArray},this.findGlyphsetsWithGroupName=GroupName=>{for(var glyphsetsArray=[],i=0;i<zincObjects.length;i++)zincObjects[i].isGlyphset&&zincObjects[i].groupName==GroupName&&glyphsetsArray.push(zincObjects[i]);return glyphsetsArray},this.findLinesWithGroupName=GroupName=>{for(var linesArray=[],i=0;i<zincObjects.length;i++)zincObjects[i].isLines&&zincObjects[i].groupName==GroupName&&linesArray.push(zincObjects[i]);return linesArray},this.findObjectsWithGroupName=GroupName=>{for(var objectsArray=[],i=0;i<zincObjects.length;i++)zincObjects[i].groupName==GroupName&&objectsArray.push(zincObjects[i]);return objectsArray},this.findObjectsWithAnatomicalId=anatomicalId=>{for(var objectsArray=[],i=0;i<zincObjects.length;i++)zincObjects[i].anatomicalId==anatomicalId&&objectsArray.push(zincObjects[i]);return objectsArray},this.getBoundingBoxOfZincObjects=objectsArray=>{for(var box,boundingBox=void 0,i=0;i<objectsArray.length;i++)box=objectsArray[i].getBoundingBox(),box&&(boundingBox?boundingBox.union(box):boundingBox=box);return boundingBox},this.vectorToScreenXY=point=>{point.project(this.camera);var width=getDrawingWidth(),height=getDrawingHeight(),widthHalf=width/2,heightHalf=height/2;return point.x=point.x*widthHalf+widthHalf,point.y=-(point.y*heightHalf)+heightHalf,point},this.getObjectsScreenXY=zincObjects=>{if(zincObjects&&0<zincObjects.length){var boundingBox=this.getBoundingBoxOfZincObjects(zincObjects),center=new THREE.Vector3;return boundingBox.getCenter(center),this.vectorToScreenXY(center)}},this.getNamedObjectsScreenXY=name=>{var zincObjects=this.findObjectsWithGroupName(name);return this.getObjectsScreenXY(zincObjects)},this.addZincObject=zincObject=>{zincObject&&(scene.add(zincObject.morph),zincObjects.push(zincObject))},this.loadGlyphsetURL=(metaurl,glyphurl,groupName,finishCallback)=>{sceneLoader.loadGlyphsetURL(metaurl,glyphurl,groupName,finishCallback)},this.loadPointsetURL=(url,timeEnabled,morphColour,groupName,finishCallback)=>{sceneLoader.loadPointsetURL(url,timeEnabled,morphColour,groupName,finishCallback)},this.loadLinesURL=(url,timeEnabled,morphColour,groupName,finishCallback)=>{sceneLoader.loadLinesURL(url,timeEnabled,morphColour,groupName,finishCallback)},this.loadSTL=(url,groupName,finishCallback)=>{sceneLoader.loadSTL(url,groupName,finishCallback)},this.loadOBJ=(url,groupName,finishCallback)=>{sceneLoader.loadOBJ(url,groupName,finishCallback)},this.loadMetadataURL=(url,finishCallback,allCompletedCallback)=>{sceneLoader.loadMetadataURL(url,finishCallback,allCompletedCallback)},this.loadModelsURL=(urls,colours,opacities,timeEnabled,morphColour,finishCallback)=>{sceneLoader.loadModelsURL(urls,colours,opacities,timeEnabled,morphColour,finishCallback)},this.loadViewURL=url=>{sceneLoader.loadViewURL(url)},this.loadFromViewURL=(jsonFilePrefix,finishCallback)=>{sceneLoader.loadFromViewURL(jsonFilePrefix,finishCallback)},this.addZincGeometry=(geometryIn,colour,opacity,localTimeEnabled,localMorphColour,finishCallback,materialIn,groupName)=>{var newGeometry=new(__webpack_require__(2).Geometry);return newGeometry.createMesh(geometryIn,materialIn,{colour:colour,opacity:opacity,localTimeEnabled:localTimeEnabled,localMorphColour:localMorphColour}),newGeometry.morph?(newGeometry.setName(groupName),this.addZincObject(newGeometry),newGeometry.setDuration(duration),null!=finishCallback&&"function"==typeof finishCallback&&finishCallback(newGeometry),!videoHandler&&newGeometry.videoHandler&&(videoHandler=newGeometry.videoHandler),newGeometry):void 0},this.updateDirectionalLight=()=>{zincCameraControls.updateDirectionalLight()},this.addObject=object=>{scene.add(object)},this.removeObject=object=>{scene.remove(object)},this.getCurrentTime=()=>null==videoHandler?null==zincObjects[0]?0:zincObjects[0].getCurrentTime():videoHandler.getCurrentTime(duration),this.setMorphsTime=time=>{videoHandler!=null&&videoHandler.setMorphTime(time,duration);for(var i=0;i<zincObjects.length;i++)zincObjects[i].setMorphTime(time)},this.isTimeVarying=()=>{for(var i=0;i<zincObjects.length;i++)if(zincObjects[i].isTimeVarying())return!0;return!!(videoHandler&&videoHandler.video&&!videoHandler.video.error)},this.renderGeometries=(playRate,delta,playAnimation)=>{// Let video dictates the progress if one is present
629
+ var setupCamera=()=>{this.camera=new THREE.PerspectiveCamera(40,getDrawingWidth()/getDrawingHeight(),0,10),this.ambient=new THREE.AmbientLight(16777215,.2),scene.add(this.ambient),this.directionalLight=new THREE.DirectionalLight(16777215,.8),scene.add(this.directionalLight),zincCameraControls=new(__webpack_require__(32).CameraControls)(this.camera,rendererIn.domElement,rendererIn,this),zincCameraControls.setDirectionalLight(this.directionalLight),zincCameraControls.resetView(),minimap=new(__webpack_require__(33).Minimap)(this)};setupCamera(),this.loadView=(_ref)=>{var{nearPlane,farPlane,eyePosition,targetPosition,upVector}=_ref,viewPort=new(__webpack_require__(32).Viewport);return viewPort.nearPlane=nearPlane,viewPort.farPlane=farPlane,viewPort.eyePosition=eyePosition,viewPort.targetPosition=targetPosition,viewPort.upVector=upVector,zincCameraControls.setDefaultCameraSettings(viewPort),zincCameraControls.resetView(),!0},this.getBoundingBox=()=>{for(var boundingBox1=void 0,boundingBox2=void 0,i=0;i<zincObjects.length;i++)boundingBox2=zincObjects[i].getBoundingBox(),null==boundingBox1?boundingBox1=boundingBox2:boundingBox2&&boundingBox1.union(boundingBox2);return boundingBox1},this.viewAllWithBoundingBox=boundingBox=>{if(boundingBox){// enlarge radius to keep image within edge of window
630
+ var radius=boundingBox.min.distanceTo(boundingBox.max)/2,centreX=(boundingBox.min.x+boundingBox.max.x)/2,centreY=(boundingBox.min.y+boundingBox.max.y)/2,centreZ=(boundingBox.min.z+boundingBox.max.z)/2,viewport=zincCameraControls.getViewportFromCentreAndRadius(centreX,centreY,centreZ,radius,40,radius*4);zincCameraControls.setCurrentCameraSettings(viewport)}},this.viewAll=()=>{var boundingBox=this.getBoundingBox();this.viewAllWithBoundingBox(boundingBox)},this.forEachGeometry=callbackFunction=>{for(var i=zincObjects.length-1;0<=i;i--)zincObjects[i].isGeometry&&callbackFunction(zincObjects[i])},this.forEachGlyphset=callbackFunction=>{for(var i=zincObjects.length-1;0<=i;i--)zincObjects[i].isGlyphset&&callbackFunction(zincObjects[i])},this.forEachPointset=callbackFunction=>{for(var i=zincObjects.length-1;0<=i;i--)zincObjects[i].isPointset&&callbackFunction(zincObjects[i])},this.forEachLine=callbackFunction=>{for(var i=zincObjects.length-1;0<=i;i--)zincObjects[i].isLines&&callbackFunction(zincObjects[i])},this.findGeometriesWithGroupName=GroupName=>{for(var geometriesArray=[],i=0;i<zincObjects.length;i++)zincObjects[i].isGeometry&&zincObjects[i].groupName==GroupName&&geometriesArray.push(zincObjects[i]);return geometriesArray},this.findPointsetsWithGroupName=GroupName=>{for(var pointsetsArray=[],i=0;i<zincObjects.length;i++)zincObjects[i].isPointset&&zincObjects[i].groupName==GroupName&&pointsetsArray.push(zincObjects[i]);return pointsetsArray},this.findGlyphsetsWithGroupName=GroupName=>{for(var glyphsetsArray=[],i=0;i<zincObjects.length;i++)zincObjects[i].isGlyphset&&zincObjects[i].groupName==GroupName&&glyphsetsArray.push(zincObjects[i]);return glyphsetsArray},this.findLinesWithGroupName=GroupName=>{for(var linesArray=[],i=0;i<zincObjects.length;i++)zincObjects[i].isLines&&zincObjects[i].groupName==GroupName&&linesArray.push(zincObjects[i]);return linesArray},this.findObjectsWithGroupName=GroupName=>{for(var objectsArray=[],i=0;i<zincObjects.length;i++)zincObjects[i].groupName==GroupName&&objectsArray.push(zincObjects[i]);return objectsArray},this.findObjectsWithAnatomicalId=anatomicalId=>{for(var objectsArray=[],i=0;i<zincObjects.length;i++)zincObjects[i].anatomicalId==anatomicalId&&objectsArray.push(zincObjects[i]);return objectsArray},this.getBoundingBoxOfZincObjects=objectsArray=>{for(var box,boundingBox=void 0,i=0;i<objectsArray.length;i++)box=objectsArray[i].getBoundingBox(),box&&(boundingBox?boundingBox.union(box):boundingBox=box);return boundingBox},this.vectorToScreenXY=point=>{point.project(this.camera);var width=getDrawingWidth(),height=getDrawingHeight(),widthHalf=width/2,heightHalf=height/2;return point.x=point.x*widthHalf+widthHalf,point.y=-(point.y*heightHalf)+heightHalf,point},this.getObjectsScreenXY=zincObjects=>{if(zincObjects&&0<zincObjects.length){var boundingBox=this.getBoundingBoxOfZincObjects(zincObjects),center=new THREE.Vector3;return boundingBox.getCenter(center),this.vectorToScreenXY(center)}},this.getNamedObjectsScreenXY=name=>{var zincObjects=this.findObjectsWithGroupName(name);return this.getObjectsScreenXY(zincObjects)},this.addZincObject=zincObject=>{zincObject&&(scene.add(zincObject.morph),zincObjects.push(zincObject),zincCameraControls&&zincCameraControls.calculateMaxAllowedDistance(this))},this.loadGlyphsetURL=(metaurl,glyphurl,groupName,finishCallback)=>{sceneLoader.loadGlyphsetURL(metaurl,glyphurl,groupName,finishCallback)},this.loadPointsetURL=(url,timeEnabled,morphColour,groupName,finishCallback)=>{sceneLoader.loadPointsetURL(url,timeEnabled,morphColour,groupName,finishCallback)},this.loadLinesURL=(url,timeEnabled,morphColour,groupName,finishCallback)=>{sceneLoader.loadLinesURL(url,timeEnabled,morphColour,groupName,finishCallback)},this.loadSTL=(url,groupName,finishCallback)=>{sceneLoader.loadSTL(url,groupName,finishCallback)},this.loadOBJ=(url,groupName,finishCallback)=>{sceneLoader.loadOBJ(url,groupName,finishCallback)},this.loadMetadataURL=(url,finishCallback,allCompletedCallback)=>{sceneLoader.loadMetadataURL(url,finishCallback,allCompletedCallback)},this.loadModelsURL=(urls,colours,opacities,timeEnabled,morphColour,finishCallback)=>{sceneLoader.loadModelsURL(urls,colours,opacities,timeEnabled,morphColour,finishCallback)},this.loadViewURL=url=>{sceneLoader.loadViewURL(url)},this.loadFromViewURL=(jsonFilePrefix,finishCallback)=>{sceneLoader.loadFromViewURL(jsonFilePrefix,finishCallback)},this.loadGLTF=(url,finishCallback,options)=>{sceneLoader.loadGLTF(url,finishCallback,options)},this.addZincGeometry=(geometryIn,colour,opacity,localTimeEnabled,localMorphColour,finishCallback,materialIn,groupName)=>{var newGeometry=new(__webpack_require__(2).Geometry);return newGeometry.createMesh(geometryIn,materialIn,{colour:colour,opacity:opacity,localTimeEnabled:localTimeEnabled,localMorphColour:localMorphColour}),newGeometry.morph?(newGeometry.setName(groupName),this.addZincObject(newGeometry),newGeometry.setDuration(duration),null!=finishCallback&&"function"==typeof finishCallback&&finishCallback(newGeometry),!videoHandler&&newGeometry.videoHandler&&(videoHandler=newGeometry.videoHandler),newGeometry):void 0},this.updateDirectionalLight=()=>{zincCameraControls.updateDirectionalLight()},this.addObject=object=>{scene.add(object)},this.removeObject=object=>{scene.remove(object)},this.getCurrentTime=()=>null==videoHandler?null==zincObjects[0]?0:zincObjects[0].getCurrentTime():videoHandler.getCurrentTime(duration),this.setMorphsTime=time=>{videoHandler!=null&&videoHandler.setMorphTime(time,duration);for(var i=0;i<zincObjects.length;i++)zincObjects[i].setMorphTime(time)},this.isTimeVarying=()=>{for(var i=0;i<zincObjects.length;i++)if(zincObjects[i].isTimeVarying())return!0;return!!(videoHandler&&videoHandler.video&&!videoHandler.video.error)},this.renderGeometries=(playRate,delta,playAnimation)=>{// Let video dictates the progress if one is present
622
631
  var options={camera:zincCameraControls,displayMarkers:this.displayMarkers,markerDepths:[]};if(videoHandler){if(videoHandler.isReadyToPlay()){playAnimation?videoHandler.video.play():videoHandler.video.pause();var currentTime=videoHandler.video.currentTime/videoHandler.getVideoDuration()*duration;if(0==sceneLoader.toBeDownloaded){zincCameraControls.setTime(currentTime),zincCameraControls.update(0);for(var i=0;i<zincObjects.length;i++)zincObjects[i].setMorphTime(currentTime),zincObjects[i].render(0,playAnimation)}else zincCameraControls.update(0);//console.log(videoHandler.video.currentTime / videoHandler.getVideoDuration() * 6000);
623
632
  }else myPlayRate=0;}else if(0==sceneLoader.toBeDownloaded){zincCameraControls.update(delta);for(var _i=0;_i<zincObjects.length;_i++)zincObjects[_i].render(playRate*delta,playAnimation,options)}else zincCameraControls.update(0);//process markers visibility and size
624
- if(this.displayMarkers&&!1===playAnimation&&0<options.markerDepths.length)for(var min=Math.min(...options.markerDepths),max=Math.max(...options.markerDepths),_i2=0;_i2<zincObjects.length;_i2++)zincObjects[_i2].processMarkerVisual(min,max,options)},this.getThreeJSScene=()=>scene,this.setAdditionalScenesGroup=scenesGroup=>{scene.add(scenesGroup)};var getWindowsPosition=(align,x_offset,y_offset,width,height,renderer_width,renderer_height)=>{var x=0,y=0;return y=align.includes("top")?renderer_height-height-y_offset:align.includes("bottom")?y_offset:Math.floor((renderer_height-height)/2),x=align.includes("left")?x_offset:align.includes("right")?renderer_width-x_offset-width:Math.floor((renderer_width-width)/2),{x:x,y:y}},renderMinimap=renderer=>{!0===this.displayMinimap&&(renderer.setScissorTest(!0),renderer.getSize(_markerTarget),this.minimapScissor.updateRequired&&(scissor=getWindowsPosition(this.minimapScissor.align,this.minimapScissor.x_offset,this.minimapScissor.y_offset,this.minimapScissor.width,this.minimapScissor.height,_markerTarget.x,_markerTarget.y),this.minimapScissor.updateRequired=!1),renderer.setScissor(scissor.x,scissor.y,this.minimapScissor.width,this.minimapScissor.height),renderer.setViewport(scissor.x,scissor.y,this.minimapScissor.width,this.minimapScissor.height),minimap.updateCamera(),scene.add(minimap.mask),renderer.render(scene,minimap.camera),scene.remove(minimap.mask),renderer.setScissorTest(!1),renderer.setViewport(0,0,_markerTarget.x,_markerTarget.y))};this.render=renderer=>{this.autoClearFlag&&renderer.clear(),stereoEffectFlag&&stereoEffect?stereoEffect.render(scene,this.camera):(renderer.render(scene,this.camera),renderMinimap(renderer))},this.setInteractiveControlEnable=flag=>{!0==flag?zincCameraControls.enable():zincCameraControls.disable()},this.getZincCameraControls=()=>zincCameraControls,this.getThreeJSScene=()=>scene,this.setDuration=durationIn=>{duration=durationIn;for(var i=0;i<zincObjects.length;i++)zincObjects[i].setDuration(duration);zincCameraControls.setPathDuration(durationIn)},this.getDuration=()=>duration,this.setStereoEffectEnable=stereoFlag=>{!0!=stereoFlag||stereoEffect||(stereoEffect=new __webpack_require__(29).StereoEffect(rendererIn)),rendererIn.setSize(getDrawingWidth(),getDrawingHeight()),this.camera.updateProjectionMatrix(),stereoEffectFlag=stereoFlag},this.objectIsInScene=zincObject=>{for(var i=0;i<zincObjects.length;i++)if(zincObject===zincObjects[i])return!0;return!1},this.alignBoundingBoxToCameraView=(boundingBox,transitionTime)=>{if(boundingBox){var center=new THREE.Vector3;boundingBox.getCenter(center);var viewport=this.getZincCameraControls().getCurrentViewport(),target=new THREE.Vector3(viewport.targetPosition[0],viewport.targetPosition[1],viewport.targetPosition[2]),eyePosition=new THREE.Vector3(viewport.eyePosition[0],viewport.eyePosition[1],viewport.eyePosition[2]),upVector=new THREE.Vector3(viewport.upVector[0],viewport.upVector[1],viewport.upVector[2]),newVec1=new THREE.Vector3,newVec2=new THREE.Vector3;newVec1.subVectors(target,eyePosition).normalize(),newVec2.subVectors(target,center).normalize();var newVec3=new THREE.Vector3;newVec3.crossVectors(newVec1,newVec2);var angle=newVec1.angleTo(newVec2);0<transitionTime?(this.getZincCameraControls().rotateCameraTransition(newVec3,angle,transitionTime),this.getZincCameraControls().enableCameraTransition()):this.getZincCameraControls().rotateAboutLookAtpoint(newVec3,angle)}},this.alignObjectToCameraView=(zincObject,transitionTime)=>{if(this.objectIsInScene(zincObject)){var boundingBox=zincObject.getBoundingBox();this.alignBoundingBoxToCameraView(boundingBox,transitionTime)}},this.setCameraTargetToObject=zincObject=>{if(this.objectIsInScene(zincObject)){var center=new THREE.Vector3,boundingBox=zincObject.getBoundingBox(),viewport=this.getZincCameraControls().getCurrentViewport();boundingBox.getCenter(center);var target=new THREE.Vector3(viewport.targetPosition[0],viewport.targetPosition[1],viewport.targetPosition[2]),eyePosition=new THREE.Vector3(viewport.eyePosition[0],viewport.eyePosition[1],viewport.eyePosition[2]),newVec1=new THREE.Vector3,newVec2=new THREE.Vector3;newVec1.subVectors(eyePosition,target),newVec2.addVectors(center,newVec1),viewport.eyePosition[0]=newVec2.x,viewport.eyePosition[1]=newVec2.y,viewport.eyePosition[2]=newVec2.z,viewport.targetPosition[0]=center.x,viewport.targetPosition[1]=center.y,viewport.targetPosition[2]=center.z,this.getZincCameraControls().setCurrentCameraSettings(viewport)}},this.isStereoEffectEnable=()=>stereoEffectFlag,this.removeZincObject=zincObject=>{for(var i=0;i<zincObjects.length;i++)if(zincObject===zincObjects[i])return scene.remove(zincObject.morph),zincObjects.splice(i,1),void zincObject.dispose()},this.getPickableThreeJSObjects=()=>{for(var returnedObjects=[],i=zincObjects.length-1;0<=i;i--)if(zincObjects[i].morph&&!0===zincObjects[i].morph.visible)if(this.displayMarkers){var marker=zincObjects[i].marker;marker&&marker.isEnabled()&&returnedObjects.push(marker.morph)}else returnedObjects.push(zincObjects[i].morph);return returnedObjects},this.getNormalisedMinimapCoordinates=(renderer,event)=>{if(this.displayMinimap){var target=new THREE.Vector2;renderer.getSize(target);var offsetY=target.y-event.clientY;if(scissor.x+this.minimapScissor.width>event.clientX&&event.clientX>scissor.x&&scissor.y+this.minimapScissor.height>offsetY&&offsetY>scissor.y){var x=2*((event.clientX-scissor.x)/this.minimapScissor.width)-1,y=2*((offsetY-scissor.y)/this.minimapScissor.height)-1;return{x:x,y:y}}}},this.getMinimapDiffFromNormalised=(x,y)=>minimap?minimap.getDiffFromNormalised(x,y):void 0,this.clearAll=()=>{for(var i=zincObjects.length-1;0<=i;i--)scene.remove(zincObjects[i].morph),zincObjects[i].dispose();zincObjects=[],sceneLoader.toBeDwonloaded=0},this.addMetadataTimeStamp=(key,time)=>{metadata.TimeStamps[key]=convertDurationObjectTomSec(time)},this.getMetadataTag=key=>metadata[key],this.getMetadata=()=>metadata,this.setMetadataTag=(key,value)=>{metadata[key]=value},this.removeMetadataTag=key=>{delete metadata[key]},this.resetMetadata=()=>{metadata=defaultMetadata()},this.resetDuration=()=>{this.setDuration(defaultDuration)};// Turn the object into a readable string {years: years,months: months,
633
+ if(this.displayMarkers&&!1===playAnimation&&0<options.markerDepths.length)for(var min=Math.min(...options.markerDepths),max=Math.max(...options.markerDepths),_i2=0;_i2<zincObjects.length;_i2++)zincObjects[_i2].processMarkerVisual(min,max,options)},this.getThreeJSScene=()=>scene,this.setAdditionalScenesGroup=scenesGroup=>{scene.add(scenesGroup)};var getWindowsPosition=(align,x_offset,y_offset,width,height,renderer_width,renderer_height)=>{var x=0,y=0;return y=align.includes("top")?renderer_height-height-y_offset:align.includes("bottom")?y_offset:Math.floor((renderer_height-height)/2),x=align.includes("left")?x_offset:align.includes("right")?renderer_width-x_offset-width:Math.floor((renderer_width-width)/2),{x:x,y:y}},renderMinimap=renderer=>{!0===this.displayMinimap&&(renderer.setScissorTest(!0),renderer.getSize(_markerTarget),this.minimapScissor.updateRequired&&(scissor=getWindowsPosition(this.minimapScissor.align,this.minimapScissor.x_offset,this.minimapScissor.y_offset,this.minimapScissor.width,this.minimapScissor.height,_markerTarget.x,_markerTarget.y),this.minimapScissor.updateRequired=!1),renderer.setScissor(scissor.x,scissor.y,this.minimapScissor.width,this.minimapScissor.height),renderer.setViewport(scissor.x,scissor.y,this.minimapScissor.width,this.minimapScissor.height),minimap.updateCamera(),scene.add(minimap.mask),renderer.render(scene,minimap.camera),scene.remove(minimap.mask),renderer.setScissorTest(!1),renderer.setViewport(0,0,_markerTarget.x,_markerTarget.y))};this.render=renderer=>{this.autoClearFlag&&renderer.clear(),stereoEffectFlag&&stereoEffect?stereoEffect.render(scene,this.camera):(renderer.render(scene,this.camera),renderMinimap(renderer))},this.setInteractiveControlEnable=flag=>{!0==flag?zincCameraControls.enable():zincCameraControls.disable()},this.getZincCameraControls=()=>zincCameraControls,this.getThreeJSScene=()=>scene,this.setDuration=durationIn=>{duration=durationIn;for(var i=0;i<zincObjects.length;i++)zincObjects[i].setDuration(duration);zincCameraControls.setPathDuration(durationIn)},this.getDuration=()=>duration,this.setStereoEffectEnable=stereoFlag=>{!0!=stereoFlag||stereoEffect||(stereoEffect=new __webpack_require__(32).StereoEffect(rendererIn)),rendererIn.setSize(getDrawingWidth(),getDrawingHeight()),this.camera.updateProjectionMatrix(),stereoEffectFlag=stereoFlag},this.objectIsInScene=zincObject=>{for(var i=0;i<zincObjects.length;i++)if(zincObject===zincObjects[i])return!0;return!1},this.alignBoundingBoxToCameraView=(boundingBox,transitionTime)=>{if(boundingBox){var center=new THREE.Vector3;boundingBox.getCenter(center);var viewport=this.getZincCameraControls().getCurrentViewport(),target=new THREE.Vector3(viewport.targetPosition[0],viewport.targetPosition[1],viewport.targetPosition[2]),eyePosition=new THREE.Vector3(viewport.eyePosition[0],viewport.eyePosition[1],viewport.eyePosition[2]),upVector=new THREE.Vector3(viewport.upVector[0],viewport.upVector[1],viewport.upVector[2]),newVec1=new THREE.Vector3,newVec2=new THREE.Vector3;newVec1.subVectors(target,eyePosition).normalize(),newVec2.subVectors(target,center).normalize();var newVec3=new THREE.Vector3;newVec3.crossVectors(newVec1,newVec2);var angle=newVec1.angleTo(newVec2);0<transitionTime?(this.getZincCameraControls().rotateCameraTransition(newVec3,angle,transitionTime),this.getZincCameraControls().enableCameraTransition()):this.getZincCameraControls().rotateAboutLookAtpoint(newVec3,angle)}},this.alignObjectToCameraView=(zincObject,transitionTime)=>{if(this.objectIsInScene(zincObject)){var boundingBox=zincObject.getBoundingBox();this.alignBoundingBoxToCameraView(boundingBox,transitionTime)}},this.setCameraTargetToObject=zincObject=>{if(this.objectIsInScene(zincObject)){var center=new THREE.Vector3,boundingBox=zincObject.getBoundingBox(),viewport=this.getZincCameraControls().getCurrentViewport();boundingBox.getCenter(center);var target=new THREE.Vector3(viewport.targetPosition[0],viewport.targetPosition[1],viewport.targetPosition[2]),eyePosition=new THREE.Vector3(viewport.eyePosition[0],viewport.eyePosition[1],viewport.eyePosition[2]),newVec1=new THREE.Vector3,newVec2=new THREE.Vector3;newVec1.subVectors(eyePosition,target),newVec2.addVectors(center,newVec1),viewport.eyePosition[0]=newVec2.x,viewport.eyePosition[1]=newVec2.y,viewport.eyePosition[2]=newVec2.z,viewport.targetPosition[0]=center.x,viewport.targetPosition[1]=center.y,viewport.targetPosition[2]=center.z,this.getZincCameraControls().setCurrentCameraSettings(viewport)}},this.isStereoEffectEnable=()=>stereoEffectFlag,this.removeZincObject=zincObject=>{for(var i=0;i<zincObjects.length;i++)if(zincObject===zincObjects[i])return scene.remove(zincObject.morph),zincObjects.splice(i,1),zincObject.dispose(),void(zincCameraControls&&zincCameraControls.calculateMaxAllowedDistance(this))},this.getPickableThreeJSObjects=()=>{for(var returnedObjects=[],i=zincObjects.length-1;0<=i;i--)if(zincObjects[i].morph&&!0===zincObjects[i].morph.visible)if(this.displayMarkers){var marker=zincObjects[i].marker;marker&&marker.isEnabled()&&returnedObjects.push(marker.morph)}else returnedObjects.push(zincObjects[i].morph);return returnedObjects},this.getNormalisedMinimapCoordinates=(renderer,event)=>{if(this.displayMinimap){var target=new THREE.Vector2;renderer.getSize(target);var offsetY=target.y-event.clientY;if(scissor.x+this.minimapScissor.width>event.clientX&&event.clientX>scissor.x&&scissor.y+this.minimapScissor.height>offsetY&&offsetY>scissor.y){var x=2*((event.clientX-scissor.x)/this.minimapScissor.width)-1,y=2*((offsetY-scissor.y)/this.minimapScissor.height)-1;return{x:x,y:y}}}},this.getMinimapDiffFromNormalised=(x,y)=>minimap?minimap.getDiffFromNormalised(x,y):void 0,this.clearAll=()=>{for(var i=zincObjects.length-1;0<=i;i--)scene.remove(zincObjects[i].morph),zincObjects[i].dispose();zincObjects=[],sceneLoader.toBeDwonloaded=0,zincCameraControls&&zincCameraControls.calculateMaxAllowedDistance(this)},this.addMetadataTimeStamp=(key,time)=>{metadata.TimeStamps[key]=convertDurationObjectTomSec(time)},this.getMetadataTag=key=>metadata[key],this.getMetadata=()=>metadata,this.setMetadataTag=(key,value)=>{metadata[key]=value},this.removeMetadataTag=key=>{delete metadata[key]},this.resetMetadata=()=>{metadata=defaultMetadata()},this.resetDuration=()=>{this.setDuration(defaultDuration)};// Turn the object into a readable string {years: years,months: months,
625
634
  // weeks: weeks, days: days, hours: hours, mins: mins, secs: secs }
626
635
  var convertDurationObjectToString=duration=>[...(duration.years?["".concat(duration.years,"years")]:[]),...(duration.months?["".concat(duration.months,"months")]:[]),...(duration.weeks?["".concat(duration.weeks,"weeks")]:[]),...(duration.days?["".concat(duration.days,"days")]:[]),...(duration.hours?["".concat(duration.hours,"hours")]:[]),...(duration.mins?["".concat(duration.mins,"mins")]:[]),...(duration.secs?["".concat(duration.secs,"secs")]:[])].join(" "),convertDurationObjectTomSec=duration=>duration.years?31536e6*duration.years:0+duration.months?2592e6*duration.months:0+duration.weeks?6048e5*duration.weeks:0+duration.days?864e5*duration.days:0+duration.hours?36e5*duration.hours:0+duration.mins?6e4*duration.mins:0+duration.secs?1e3*duration.secs:0;// Turn the object into a number representing milliesecond {years: years,months: months,
627
636
  // weeks: weeks, days: days, hours: hours, mins: mins, secs: secs }
@@ -631,14 +640,14 @@ var convertDurationObjectToString=duration=>[...(duration.years?["".concat(durat
631
640
  // Set the readable original duration using an object
632
641
  // with the following format {years: years,months: months, weeks: weeks, days: days,
633
642
  // hours: hours, mins: mins, secs: secs }
634
- this.setDurationFromObject=duration=>{var string=convertDurationObjectToString(duration),millisec=convertDurationObjectTomSec(duration);this.setMetadataTag("Duration",string),this.setDuration(millisec)},this.setOriginalDurationFromObject=duration=>{var string=convertDurationObjectToString(duration);this.setMetadataTag("OriginalDuration",string)}};
643
+ this.setDurationFromObject=duration=>{var string=convertDurationObjectToString(duration),millisec=convertDurationObjectTomSec(duration);this.setMetadataTag("Duration",string),this.setDuration(millisec)},this.setOriginalDurationFromObject=duration=>{var string=convertDurationObjectToString(duration);this.setMetadataTag("OriginalDuration",string)},this.exportGLTF=binary=>{var exporter=new SceneExporter(this);return exporter.exportGLTF(binary)}};
635
644
 
636
645
  /***/ }),
637
646
  /* 26 */
638
647
  /***/ (function(module, exports, __webpack_require__) {
639
648
 
640
- var THREE=__webpack_require__(3),resolveURL=__webpack_require__(6).resolveURL,JSONLoader=__webpack_require__(14).JSONLoader,STLLoader=__webpack_require__(27).STLLoader,OBJLoader=__webpack_require__(28).OBJLoader;exports.SceneLoader=function(sceneIn){var scene=sceneIn;this.toBeDownloaded=0,this.progressMap=[];var viewLoaded=!1,errorDownload=!1;this.getDownloadProgress=()=>{var totalSize=0,totalLoaded=0,unknownFound=!1;for(var key in this.progressMap){var progress=this.progressMap[key];totalSize+=progress[1],totalLoaded+=progress[0],0==progress[1]&&(unknownFound=!0)}return unknownFound&&(totalSize=0),[totalSize,totalLoaded,errorDownload]},this.onProgress=id=>xhr=>{this.progressMap[id]=[xhr.loaded,xhr.total]},this.onError=()=>{--this.toBeDownloaded,errorDownload=!0},this.loadViewURL=(url,finishCallback)=>{this.toBeDownloaded+=1;var xmlhttp=new XMLHttpRequest;xmlhttp.onreadystatechange=()=>{if(4==xmlhttp.readyState){if(200==xmlhttp.status){var viewData=JSON.parse(xmlhttp.responseText);scene.loadView(viewData)&&(viewLoaded=!0),finishCallback!=null&&"function"==typeof finishCallback&&finishCallback()}--this.toBeDownloaded}},requestURL=resolveURL(url),xmlhttp.open("GET",requestURL,!0),xmlhttp.send()},this.loadModelsURL=(urls,colours,opacities,timeEnabled,morphColour,finishCallback)=>{var number=urls.length;this.toBeDownloaded+=number;for(var _i=0;_i<number;_i++){var filename=urls[_i],loader=new JSONLoader,colour=__webpack_require__(0).defaultMaterialColor,opacity=__webpack_require__(0).defaultOpacity;colours!=null&&colours[_i]!=null&&(colour=!!colours[_i]),opacities!=null&&opacities[_i]!=null&&(opacity=opacities[_i]);var localTimeEnabled=0;timeEnabled!=null&&timeEnabled[_i]!=null&&(localTimeEnabled=!!timeEnabled[_i]);var localMorphColour=0;morphColour!=null&&morphColour[_i]!=null&&(localMorphColour=!!morphColour[_i]),loader.crossOrigin="Anonymous",loader.load(resolveURL(filename),meshloader(colour,opacity,localTimeEnabled,localMorphColour,void 0,void 0,finishCallback),this.onProgress(_i),this.onError)}},this.loadFromViewURL=(jsonFilePrefix,finishCallback)=>{var xmlhttp=new XMLHttpRequest;xmlhttp.onreadystatechange=()=>{if(4==xmlhttp.readyState&&200==xmlhttp.status){var viewData=JSON.parse(xmlhttp.responseText);scene.loadView(viewData);for(var filename,urls=[],_i2=0;_i2<viewData.numberOfResources;_i2++)filename=jsonFilePrefix+"_"+(_i2+1)+".json",urls.push(filename);this.loadModelsURL(urls,viewData.colour,viewData.opacity,viewData.timeEnabled,viewData.morphColour,finishCallback)}},requestURL=resolveURL(jsonFilePrefix+"_view.json"),xmlhttp.open("GET",requestURL,!0),xmlhttp.send()};//Internal loader for a regular zinc geometry.
641
- var linesloader=(localTimeEnabled,localMorphColour,groupName,anatomicalId,finishCallback)=>(geometry,materials)=>{var newLines=new(__webpack_require__(20).Lines),material=void 0;materials&&materials[0]&&(material=new THREE.LineBasicMaterial({color:materials[0].color.clone()}),1>materials[0].opacity&&(material.transparent=!0),material.opacity=materials[0].opacity,material.morphTargets=localTimeEnabled,material.vertexColors=materials[0].vertexColors);var options={};options.localTimeEnabled=localTimeEnabled,options.localMorphColour=localMorphColour,newLines&&(newLines.createLineSegment(geometry,material,options),newLines.setName(groupName),newLines.anatomicalId=anatomicalId,scene.addZincObject(newLines),newLines.setDuration(scene.getDuration())),--this.toBeDownloaded,null!=finishCallback&&"function"==typeof finishCallback&&finishCallback(newLines)};/**
649
+ var THREE=__webpack_require__(3),resolveURL=__webpack_require__(6).resolveURL,JSONLoader=__webpack_require__(14).JSONLoader,STLLoader=__webpack_require__(27).STLLoader,OBJLoader=__webpack_require__(28).OBJLoader,GLTFLoader=__webpack_require__(29).GLTFLoader;exports.SceneLoader=function(sceneIn){var scene=sceneIn;this.toBeDownloaded=0,this.progressMap=[];var viewLoaded=!1,errorDownload=!1;this.getDownloadProgress=()=>{var totalSize=0,totalLoaded=0,unknownFound=!1;for(var key in this.progressMap){var progress=this.progressMap[key];totalSize+=progress[1],totalLoaded+=progress[0],0==progress[1]&&(unknownFound=!0)}return unknownFound&&(totalSize=0),[totalSize,totalLoaded,errorDownload]},this.onProgress=id=>xhr=>{this.progressMap[id]=[xhr.loaded,xhr.total]},this.onError=()=>{--this.toBeDownloaded,errorDownload=!0},this.loadViewURL=(url,finishCallback)=>{this.toBeDownloaded+=1;var xmlhttp=new XMLHttpRequest;xmlhttp.onreadystatechange=()=>{if(4==xmlhttp.readyState){if(200==xmlhttp.status){var viewData=JSON.parse(xmlhttp.responseText);scene.loadView(viewData)&&(viewLoaded=!0),finishCallback!=null&&"function"==typeof finishCallback&&finishCallback()}--this.toBeDownloaded}},requestURL=resolveURL(url),xmlhttp.open("GET",requestURL,!0),xmlhttp.send()},this.loadModelsURL=(urls,colours,opacities,timeEnabled,morphColour,finishCallback)=>{var number=urls.length;this.toBeDownloaded+=number;for(var _i=0;_i<number;_i++){var filename=urls[_i],loader=new JSONLoader,colour=__webpack_require__(0).defaultMaterialColor,opacity=__webpack_require__(0).defaultOpacity;colours!=null&&colours[_i]!=null&&(colour=!!colours[_i]),opacities!=null&&opacities[_i]!=null&&(opacity=opacities[_i]);var localTimeEnabled=0;timeEnabled!=null&&timeEnabled[_i]!=null&&(localTimeEnabled=!!timeEnabled[_i]);var localMorphColour=0;morphColour!=null&&morphColour[_i]!=null&&(localMorphColour=!!morphColour[_i]),loader.crossOrigin="Anonymous",loader.load(resolveURL(filename),meshloader(colour,opacity,localTimeEnabled,localMorphColour,void 0,void 0,void 0,finishCallback),this.onProgress(_i),this.onError)}},this.loadFromViewURL=(jsonFilePrefix,finishCallback)=>{var xmlhttp=new XMLHttpRequest;xmlhttp.onreadystatechange=()=>{if(4==xmlhttp.readyState&&200==xmlhttp.status){var viewData=JSON.parse(xmlhttp.responseText);scene.loadView(viewData);for(var filename,urls=[],_i2=0;_i2<viewData.numberOfResources;_i2++)filename=jsonFilePrefix+"_"+(_i2+1)+".json",urls.push(filename);this.loadModelsURL(urls,viewData.colour,viewData.opacity,viewData.timeEnabled,viewData.morphColour,finishCallback)}},requestURL=resolveURL(jsonFilePrefix+"_view.json"),xmlhttp.open("GET",requestURL,!0),xmlhttp.send()};//Internal loader for a regular zinc geometry.
650
+ var linesloader=(localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,finishCallback)=>(geometry,materials)=>{var newLines=new(__webpack_require__(20).Lines),material=void 0;materials&&materials[0]&&(material=new THREE.LineBasicMaterial({color:materials[0].color.clone()}),1>materials[0].opacity&&(material.transparent=!0),material.opacity=materials[0].opacity,material.morphTargets=localTimeEnabled,material.vertexColors=materials[0].vertexColors);var options={};options.localTimeEnabled=localTimeEnabled,options.localMorphColour=localMorphColour,newLines&&(newLines.createLineSegment(geometry,material,options),newLines.setName(groupName),newLines.anatomicalId=anatomicalId,newLines.setRenderOrder=renderOrder,scene.addZincObject(newLines),newLines.setDuration(scene.getDuration())),--this.toBeDownloaded,geometry.dispose(),null!=finishCallback&&"function"==typeof finishCallback&&finishCallback(newLines)};/**
642
651
  * Load lines into this scene object.
643
652
  *
644
653
  * @param {String} metaurl - Provide informations such as transformations, colours
@@ -648,9 +657,9 @@ var linesloader=(localTimeEnabled,localMorphColour,groupName,anatomicalId,finish
648
657
  * @param {STRING} groupName - name to assign the pointset's groupname to.
649
658
  * @param {Function} finishCallback - Callback function which will be called
650
659
  * once the glyphset is succssfully load in.
651
- */this.loadLinesURL=(url,timeEnabled,morphColour,groupName,finishCallback,options)=>{var localTimeEnabled=0;this.toBeDownloaded+=1;var isInline=!!(options&&options.isInline)&&options.isInline,anatomicalId=options&&options.anatomicalId?options.anatomicalId:void 0;timeEnabled!=null&&(localTimeEnabled=!!timeEnabled);var localMorphColour=0;morphColour!=null&&(localMorphColour=!!morphColour);var loader=new JSONLoader;if(isInline){var object=loader.parse(url);linesloader(localTimeEnabled,localMorphColour,groupName,anatomicalId,finishCallback)(object.geometry,object.materials)}else loader.crossOrigin="Anonymous",loader.load(url,linesloader(localTimeEnabled,localMorphColour,groupName,anatomicalId,finishCallback),this.onProgress(i),this.onError)};var loadGlyphset=(glyphsetData,glyphurl,groupName,finishCallback,options)=>{var isInline=options&&options.isInline?options.isInline:void 0,anatomicalId=options&&options.anatomicalId?options.anatomicalId:void 0,displayLabels=options&&options.displayLabels?options.displayLabels:void 0,newGlyphset=new(__webpack_require__(13).Glyphset);newGlyphset.setDuration(scene.getDuration()),newGlyphset.groupName=groupName;var myCallback=()=>{--this.toBeDownloaded,finishCallback!=null&&"function"==typeof finishCallback&&finishCallback(newGlyphset)};++this.toBeDownloaded,isInline?newGlyphset.load(glyphsetData,glyphurl,myCallback,isInline,displayLabels):newGlyphset.load(glyphsetData,resolveURL(glyphurl),myCallback,isInline,displayLabels),newGlyphset.anatomicalId=anatomicalId,scene.addZincObject(newGlyphset)},onLoadGlyphsetReady=(xmlhttp,glyphurl,groupName,finishCallback,options)=>()=>{if(4==xmlhttp.readyState&&200==xmlhttp.status){var glyphsetData=JSON.parse(xmlhttp.responseText);loadGlyphset(glyphsetData,glyphurl,groupName,finishCallback,options)}},pointsetloader=(localTimeEnabled,localMorphColour,groupName,anatomicalId,finishCallback)=>(geometry,materials)=>{var newPointset=new(__webpack_require__(17).Pointset),material=new THREE.PointsMaterial({alphaTest:.5,size:5,sizeAttenuation:!1});materials&&materials[0]&&(1>materials[0].opacity&&(material.transparent=!0),material.opacity=materials[0].opacity,material.color=materials[0].color,material.morphTargets=localTimeEnabled,material.vertexColors=materials[0].vertexColors);var options={};options.localTimeEnabled=localTimeEnabled,options.localMorphColour=localMorphColour,newPointset&&(newPointset.createMesh(geometry,material,options),newPointset.setName(groupName),newPointset.anatomicalId=anatomicalId,scene.addZincObject(newPointset),newPointset.setDuration(scene.getDuration())),--this.toBeDownloaded,null!=finishCallback&&"function"==typeof finishCallback&&finishCallback(newPointset)};//Load a glyphset into this scene.
652
- this.loadSTL=(url,groupName,finishCallback)=>{this.toBeDownloaded+=1;var colour=__webpack_require__(0).defaultMaterialColor,opacity=__webpack_require__(0).defaultOpacity,loader=new STLLoader;loader.crossOrigin="Anonymous",loader.load(resolveURL(url),meshloader(colour,opacity,!1,!1,groupName,void 0,finishCallback))},this.loadOBJ=(url,groupName,finishCallback)=>{this.toBeDownloaded+=1;var colour=__webpack_require__(0).defaultMaterialColor,opacity=__webpack_require__(0).defaultOpacity,loader=new OBJLoader;loader.crossOrigin="Anonymous",loader.load(resolveURL(url),meshloader(colour,opacity,!1,!1,groupName,void 0,finishCallback))};//Loader for the OBJ format,
653
- var objloader=(colour,opacity,localTimeEnabled,localMorphColour,groupName,finishCallback)=>object=>{this.toBeDownloaded--,object.traverse(child=>{if(child instanceof THREE.Mesh){var zincGeometry=addMeshToZincGeometry(child,localTimeEnabled,localMorphColour);scene.addZincObject(zincGeometry),zincGeometry.morph&&(zincGeometry.morph.name=groupName),zincGeometry.groupName=groupName,null!=finishCallback&&"function"==typeof finishCallback&&finishCallback(zincGeometry)}})},loadSurfaceURL=(url,timeEnabled,morphColour,groupName,finishCallback,options)=>{this.toBeDownloaded+=1;var colour=__webpack_require__(0).defaultMaterialColor,opacity=__webpack_require__(0).defaultOpacity,localTimeEnabled=0,isInline=!!(options&&options.isInline)&&options.isInline,fileFormat=options&&options.fileFormat?options.fileFormat:void 0,anatomicalId=options&&options.anatomicalId?options.anatomicalId:void 0;timeEnabled!=null&&(localTimeEnabled=!!timeEnabled);var localMorphColour=0;morphColour!=null&&(localMorphColour=!!morphColour);var loader=new JSONLoader;if(fileFormat!==void 0)if("STL"==fileFormat)loader=new STLLoader;else if("OBJ"==fileFormat)return loader=new OBJLoader,loader.crossOrigin="Anonymous",void loader.load(url,objloader(colour,opacity,localTimeEnabled,localMorphColour,groupName,anatomicalId,finishCallback),this.onProgress(i),this.onError);if(isInline){var object=loader.parse(url);meshloader(colour,opacity,localTimeEnabled,localMorphColour,groupName,anatomicalId,finishCallback)(object.geometry,object.materials)}else loader.crossOrigin="Anonymous",loader.load(url,meshloader(colour,opacity,localTimeEnabled,localMorphColour,groupName,anatomicalId,finishCallback),this.onProgress(i),this.onError)},metaFinishCallback=function(numberOfDownloaded,finishCallback,allCompletedCallback){var downloadedItem=0;return zincGeometry=>{++downloadedItem,zincGeometry&&finishCallback!=null&&"function"==typeof finishCallback&&finishCallback(zincGeometry),downloadedItem==numberOfDownloaded&&(!1===viewLoaded&&scene.viewAll(),allCompletedCallback!=null&&"function"==typeof allCompletedCallback&&allCompletedCallback())}};/**
660
+ */this.loadLinesURL=(url,timeEnabled,morphColour,groupName,finishCallback,options)=>{var localTimeEnabled=0;this.toBeDownloaded+=1;var isInline=!!(options&&options.isInline)&&options.isInline,anatomicalId=options&&options.anatomicalId?options.anatomicalId:void 0,renderOrder=options&&options.renderOrder?options.renderOrder:void 0;timeEnabled!=null&&(localTimeEnabled=!!timeEnabled);var localMorphColour=0;morphColour!=null&&(localMorphColour=!!morphColour);var loader=new JSONLoader;if(isInline){var object=loader.parse(url);linesloader(localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,finishCallback)(object.geometry,object.materials)}else loader.crossOrigin="Anonymous",loader.load(url,linesloader(localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,finishCallback),this.onProgress(i),this.onError)};var loadGlyphset=(glyphsetData,glyphurl,groupName,finishCallback,options)=>{var isInline=options&&options.isInline?options.isInline:void 0,anatomicalId=options&&options.anatomicalId?options.anatomicalId:void 0,displayLabels=options&&options.displayLabels?options.displayLabels:void 0,renderOrder=options&&options.renderOrder?options.renderOrder:void 0,newGlyphset=new(__webpack_require__(13).Glyphset);newGlyphset.setDuration(scene.getDuration()),newGlyphset.groupName=groupName;var myCallback=()=>{--this.toBeDownloaded,finishCallback!=null&&"function"==typeof finishCallback&&finishCallback(newGlyphset)};++this.toBeDownloaded,isInline?newGlyphset.load(glyphsetData,glyphurl,myCallback,isInline,displayLabels):newGlyphset.load(glyphsetData,resolveURL(glyphurl),myCallback,isInline,displayLabels),newGlyphset.anatomicalId=anatomicalId,newGlyphset.setRenderOrder(renderOrder),scene.addZincObject(newGlyphset)},onLoadGlyphsetReady=(xmlhttp,glyphurl,groupName,finishCallback,options)=>()=>{if(4==xmlhttp.readyState&&200==xmlhttp.status){var glyphsetData=JSON.parse(xmlhttp.responseText);loadGlyphset(glyphsetData,glyphurl,groupName,finishCallback,options)}},pointsetloader=(localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,finishCallback)=>(geometry,materials)=>{var newPointset=new(__webpack_require__(17).Pointset),material=new THREE.PointsMaterial({alphaTest:.5,size:5,sizeAttenuation:!1});materials&&materials[0]&&(1>materials[0].opacity&&(material.transparent=!0),material.opacity=materials[0].opacity,material.color=materials[0].color,material.morphTargets=localTimeEnabled,material.vertexColors=materials[0].vertexColors);var options={};options.localTimeEnabled=localTimeEnabled,options.localMorphColour=localMorphColour,newPointset&&(newPointset.createMesh(geometry,material,options),newPointset.setName(groupName),newPointset.anatomicalId=anatomicalId,scene.addZincObject(newPointset),newPointset.setDuration(scene.getDuration()),newPointset.setRenderOrder(renderOrder)),geometry.dispose(),--this.toBeDownloaded,null!=finishCallback&&"function"==typeof finishCallback&&finishCallback(newPointset)};//Load a glyphset into this scene.
661
+ this.loadSTL=(url,groupName,finishCallback)=>{this.toBeDownloaded+=1;var colour=__webpack_require__(0).defaultMaterialColor,opacity=__webpack_require__(0).defaultOpacity,loader=new STLLoader;loader.crossOrigin="Anonymous",loader.load(resolveURL(url),meshloader(colour,opacity,!1,!1,groupName,void 0,void 0,finishCallback))},this.loadOBJ=(url,groupName,finishCallback)=>{this.toBeDownloaded+=1;var colour=__webpack_require__(0).defaultMaterialColor,opacity=__webpack_require__(0).defaultOpacity,loader=new OBJLoader;loader.crossOrigin="Anonymous",loader.load(resolveURL(url),meshloader(colour,opacity,!1,!1,groupName,void 0,void 0,finishCallback))};//Loader for the OBJ format,
662
+ var objloader=(colour,opacity,localTimeEnabled,localMorphColour,groupName,finishCallback)=>object=>{this.toBeDownloaded--,object.traverse(child=>{if(child instanceof THREE.Mesh){var zincGeometry=addMeshToZincGeometry(child,localTimeEnabled,localMorphColour);scene.addZincObject(zincGeometry),zincGeometry.morph&&(zincGeometry.morph.name=groupName),zincGeometry.groupName=groupName,null!=finishCallback&&"function"==typeof finishCallback&&finishCallback(zincGeometry)}})},loadSurfaceURL=(url,timeEnabled,morphColour,groupName,finishCallback,options)=>{this.toBeDownloaded+=1;var colour=__webpack_require__(0).defaultMaterialColor,opacity=__webpack_require__(0).defaultOpacity,localTimeEnabled=0,isInline=!!(options&&options.isInline)&&options.isInline,fileFormat=options&&options.fileFormat?options.fileFormat:void 0,anatomicalId=options&&options.anatomicalId?options.anatomicalId:void 0,renderOrder=options&&options.renderOrder?options.renderOrder:void 0;timeEnabled!=null&&(localTimeEnabled=!!timeEnabled);var localMorphColour=0;morphColour!=null&&(localMorphColour=!!morphColour);var loader=new JSONLoader;if(fileFormat!==void 0)if("STL"==fileFormat)loader=new STLLoader;else if("OBJ"==fileFormat)return loader=new OBJLoader,loader.crossOrigin="Anonymous",void loader.load(url,objloader(colour,opacity,localTimeEnabled,localMorphColour,groupName,anatomicalId,finishCallback),this.onProgress(i),this.onError);if(isInline){var object=loader.parse(url);meshloader(colour,opacity,localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,finishCallback)(object.geometry,object.materials)}else loader.crossOrigin="Anonymous",loader.load(url,meshloader(colour,opacity,localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,finishCallback),this.onProgress(i),this.onError)},metaFinishCallback=function(numberOfDownloaded,finishCallback,allCompletedCallback){var downloadedItem=0;return zincGeometry=>{++downloadedItem,zincGeometry&&finishCallback!=null&&"function"==typeof finishCallback&&finishCallback(zincGeometry),downloadedItem==numberOfDownloaded&&(!1===viewLoaded&&scene.viewAll(),allCompletedCallback!=null&&"function"==typeof allCompletedCallback&&allCompletedCallback())}};/**
654
663
  * Load a geometry into this scene, this is a subsequent called from
655
664
  * {@link Zinc.Scene#loadMetadataURL}, although it can be used to read
656
665
  * in geometry into the scene externally.
@@ -662,136 +671,295 @@ var objloader=(colour,opacity,localTimeEnabled,localMorphColour,groupName,finish
662
671
  * @param {STRING} fileFormat - name supported formats are STL, OBJ and JSON.
663
672
  * @param {Function} finishCallback - Callback function which will be called
664
673
  * once the geometry is succssfully loaded in.
665
- */this.loadPointsetURL=(url,timeEnabled,morphColour,groupName,finishCallback,options)=>{var localTimeEnabled=0;this.toBeDownloaded+=1,timeEnabled!=null&&(localTimeEnabled=!!timeEnabled);var localMorphColour=0;morphColour!=null&&(localMorphColour=!!morphColour);var loader=new JSONLoader,isInline=!!(options&&options.isInline)&&options.isInline,anatomicalId=options&&options.anatomicalId?options.anatomicalId:void 0;if(isInline){var object=loader.parse(url);pointsetloader(localTimeEnabled,localMorphColour,groupName,anatomicalId,finishCallback)(object.geometry,object.materials)}else loader.crossOrigin="Anonymous",loader.load(url,pointsetloader(localTimeEnabled,localMorphColour,groupName,anatomicalId,finishCallback),this.onProgress(i),this.onError)},this.loadGlyphsetURL=(metaurl,glyphurl,groupName,finishCallback,options)=>{var isInline=!!(options&&options.isInline)&&options.isInline;if(isInline)loadGlyphset(metaurl,glyphurl,groupName,finishCallback,options);else{var xmlhttp=new XMLHttpRequest;xmlhttp.onreadystatechange=onLoadGlyphsetReady(xmlhttp,glyphurl,groupName,finishCallback,options),xmlhttp.open("GET",resolveURL(metaurl),!0),xmlhttp.send()}};//Internal loader for a regular zinc geometry.
666
- var meshloader=(colour,opacity,localTimeEnabled,localMorphColour,groupName,anatomicalId,finishCallback)=>(geometry,materials)=>{var material;materials&&materials[0]&&(material=materials[0]);var zincGeometry=scene.addZincGeometry(geometry,colour,opacity,localTimeEnabled,localMorphColour,void 0,material,groupName);zincGeometry.anatomicalId=anatomicalId,--this.toBeDownloaded,null!=finishCallback&&"function"==typeof finishCallback&&finishCallback(zincGeometry)},parseDuration=durationString=>{var regex=/P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/,[,years,months,weeks,days,hours,mins,secs]=durationString.match(regex);return{years:years,months:months,weeks:weeks,days:days,hours:hours,mins:mins,secs:secs}};//Turn ISO 8601 duration string into an array.
674
+ */this.loadPointsetURL=(url,timeEnabled,morphColour,groupName,finishCallback,options)=>{var localTimeEnabled=0;this.toBeDownloaded+=1,timeEnabled!=null&&(localTimeEnabled=!!timeEnabled);var localMorphColour=0;morphColour!=null&&(localMorphColour=!!morphColour);var loader=new JSONLoader,isInline=!!(options&&options.isInline)&&options.isInline,anatomicalId=options&&options.anatomicalId?options.anatomicalId:void 0,renderOrder=options&&options.renderOrder?options.renderOrder:void 0;if(isInline){var object=loader.parse(url);pointsetloader(localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,finishCallback)(object.geometry,object.materials)}else loader.crossOrigin="Anonymous",loader.load(url,pointsetloader(localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,finishCallback),this.onProgress(i),this.onError)},this.loadGlyphsetURL=(metaurl,glyphurl,groupName,finishCallback,options)=>{var isInline=!!(options&&options.isInline)&&options.isInline,renderOrder=!!(options&&options.renderOrder)&&options.renderOrder;if(isInline)loadGlyphset(metaurl,glyphurl,groupName,finishCallback,options);else{var xmlhttp=new XMLHttpRequest;xmlhttp.onreadystatechange=onLoadGlyphsetReady(xmlhttp,glyphurl,groupName,finishCallback,options),xmlhttp.open("GET",resolveURL(metaurl),!0),xmlhttp.send()}};//Internal loader for a regular zinc geometry.
675
+ var meshloader=(colour,opacity,localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,finishCallback)=>(geometry,materials)=>{var material;materials&&materials[0]&&(material=materials[0]);var zincGeometry=scene.addZincGeometry(geometry,colour,opacity,localTimeEnabled,localMorphColour,void 0,material,groupName,renderOrder);zincGeometry.anatomicalId=anatomicalId,zincGeometry.setRenderOrder(renderOrder),--this.toBeDownloaded,geometry.dispose(),null!=finishCallback&&"function"==typeof finishCallback&&finishCallback(zincGeometry)},parseDuration=durationString=>{var regex=/P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/,[,years,months,weeks,days,hours,mins,secs]=durationString.match(regex);return{years:years,months:months,weeks:weeks,days:days,hours:hours,mins:mins,secs:secs}};//Turn ISO 8601 duration string into an array.
667
676
  this.loadSettings=item=>{if(item){//duration uses the ISO 8601 standard - PnYnMnDTnHnMnS
668
677
  if(item.Duration){var duration=parseDuration(item.Duration);scene.setDurationFromObject(duration)}if(item.OriginalDuration){var _duration=parseDuration(item.OriginalDuration);scene.setOriginalDurationFromObject(_duration)}if(item.TimeStamps)for(var key in item.TimeStamps){var time=parseDuration(item.TimeStamps[key]);scene.addMetadataTimeStamp(key,time)}}};//Function to process each of the graphical metadata item except for view and
669
678
  //settings.
670
- var readPrimitivesItem=(referenceURL,item,finishCallback)=>{if(item){var newURL=void 0,isInline=!1;item.URL?(newURL=item.URL,referenceURL&&(newURL=new URL(item.URL,referenceURL).href)):item.Inline&&(newURL=item.Inline.URL,isInline=!0);var options={isInline:isInline,fileFormat:item.FileFormat,anatomicalId:item.AnatomicalId};switch(item.Type){case"Surfaces":loadSurfaceURL(newURL,item.MorphVertices,item.MorphColours,item.GroupName,finishCallback,options);break;case"Glyph":var newGeometryURL;isInline?newGeometryURL=item.Inline.GlyphGeometriesURL:(newGeometryURL=item.GlyphGeometriesURL,newGeometryURL=new URL(item.GlyphGeometriesURL,referenceURL).href),item.DisplayLabels&&(options.displayLabels=!0),this.loadGlyphsetURL(newURL,newGeometryURL,item.GroupName,finishCallback,options);break;case"Points":this.loadPointsetURL(newURL,item.MorphVertices,item.MorphColours,item.GroupName,finishCallback,options);break;case"Lines":this.loadLinesURL(newURL,item.MorphVertices,item.MorphColours,item.GroupName,finishCallback,options);break;default:}}},readViewAndSettingsItem=(referenceURL,item,finishCallback)=>{if(item){var newURL=void 0,isInline=!1;switch(item.URL?(newURL=item.URL,referenceURL&&(newURL=new URL(item.URL,referenceURL).href)):item.Inline&&(newURL=item.Inline.URL,isInline=!0),item.Type){case"View":isInline?(scene.loadView(newURL)&&(viewLoaded=!0),null!=finishCallback&&"function"==typeof finishCallback&&finishCallback()):this.loadViewURL(newURL,finishCallback);break;case"Settings":this.loadSettings(item),null!=finishCallback&&"function"==typeof finishCallback&&finishCallback();break;default:}}};//Function to read the view item first
679
+ var readPrimitivesItem=(referenceURL,item,order,finishCallback)=>{if(item){var newURL=void 0,isInline=!1;item.URL?(newURL=item.URL,referenceURL&&(newURL=new URL(item.URL,referenceURL).href)):item.Inline&&(newURL=item.Inline.URL,isInline=!0);var options={isInline:isInline,fileFormat:item.FileFormat,anatomicalId:item.AnatomicalId,compression:item.compression,renderOrder:order};switch(item.Type){case"Surfaces":loadSurfaceURL(newURL,item.MorphVertices,item.MorphColours,item.GroupName,finishCallback,options);break;case"Glyph":var newGeometryURL;isInline?newGeometryURL=item.Inline.GlyphGeometriesURL:(newGeometryURL=item.GlyphGeometriesURL,newGeometryURL=new URL(item.GlyphGeometriesURL,referenceURL).href),item.DisplayLabels&&(options.displayLabels=!0),this.loadGlyphsetURL(newURL,newGeometryURL,item.GroupName,finishCallback,options);break;case"Points":this.loadPointsetURL(newURL,item.MorphVertices,item.MorphColours,item.GroupName,finishCallback,options);break;case"Lines":this.loadLinesURL(newURL,item.MorphVertices,item.MorphColours,item.GroupName,finishCallback,options);break;default:}}},readViewAndSettingsItem=(referenceURL,item,finishCallback)=>{if(item){var newURL=void 0,isInline=!1;switch(item.URL?(newURL=item.URL,referenceURL&&(newURL=new URL(item.URL,referenceURL).href)):item.Inline&&(newURL=item.Inline.URL,isInline=!0),item.Type){case"View":isInline?(scene.loadView(newURL)&&(viewLoaded=!0),null!=finishCallback&&"function"==typeof finishCallback&&finishCallback()):this.loadViewURL(newURL,finishCallback);break;case"Settings":this.loadSettings(item),null!=finishCallback&&"function"==typeof finishCallback&&finishCallback();break;default:}}};//Function to read the view item first
671
680
  /**
681
+ * Load GLTF into this scene object.
682
+ *
683
+ * @param {String} url - URL to the GLTF file
684
+ * @param {Function} finishCallback - Callback function which will be called
685
+ * once the glyphset is succssfully load in.
686
+ */ /**
672
687
  * Load a metadata file from the provided URL into this scene. Once
673
688
  * succssful scene proceeds to read each items into scene for visualisations.
674
689
  *
675
690
  * @param {String} url - Location of the metafile
676
691
  * @param {Function} finishCallback - Callback function which will be called
677
692
  * for each glyphset and geometry that has been written in.
678
- */this.loadMetadataURL=(url,finishCallback,allCompletedCallback)=>{var xmlhttp=new XMLHttpRequest,requestURL=resolveURL(url);xmlhttp.onreadystatechange=()=>{if(4==xmlhttp.readyState&&200==xmlhttp.status){scene.resetMetadata(),scene.resetDuration(),viewLoaded=!1;var referenceURL=xmlhttp.responseURL;referenceURL===void 0&&(referenceURL=new URL(requestURL).href);// Prioritise the view file and settings before loading anything else
679
- for(var metadata=JSON.parse(xmlhttp.responseText),numberOfObjects=metadata.length,callback=new metaFinishCallback(numberOfObjects,finishCallback,allCompletedCallback),i=0;i<metadata.length;i++)readViewAndSettingsItem(referenceURL,metadata[i],callback);for(var i=0;i<metadata.length;i++)readPrimitivesItem(referenceURL,metadata[i],callback)}},xmlhttp.open("GET",requestURL,!0),xmlhttp.send()}};
693
+ */this.loadGLTF=(url,finishCallback)=>{var path=url.substring(0,url.lastIndexOf("/")+1),filename=url.substring(url.lastIndexOf("/")+1,url.length),loader=new GLTFLoader().setPath(path);loader.load(filename,function(gltf){console.log(gltf),gltf.scene.children.forEach(child=>{console.log(child);var localTimeEnabled=!1,localMorphColour=!1;child.geometry&&child.geometry.morphAttributes&&(localTimeEnabled=!!child.geometry.morphAttributes.position,localMorphColour=!!child.geometry.morphAttributes.color);var zincGeometry=new(__webpack_require__(2).Geometry);zincGeometry.setMesh(child.clone(),localTimeEnabled,localMorphColour),scene.addZincObject(zincGeometry),zincGeometry.groupName=zincGeometry.morph.name,console.log(zincGeometry),finishCallback!=null&&"function"==typeof finishCallback&&finishCallback(zincGeometry)})})},this.loadMetadataURL=(url,finishCallback,allCompletedCallback)=>{var xmlhttp=new XMLHttpRequest,requestURL=resolveURL(url);xmlhttp.onreadystatechange=()=>{if(4==xmlhttp.readyState&&200==xmlhttp.status){scene.resetMetadata(),scene.resetDuration(),viewLoaded=!1;var referenceURL=xmlhttp.responseURL;referenceURL===void 0&&(referenceURL=new URL(requestURL).href);// Prioritise the view file and settings before loading anything else
694
+ for(var metadata=JSON.parse(xmlhttp.responseText),numberOfObjects=metadata.length,callback=new metaFinishCallback(numberOfObjects,finishCallback,allCompletedCallback),i=0;i<metadata.length;i++)readViewAndSettingsItem(referenceURL,metadata[i],callback);for(var i=0;i<metadata.length;i++)//Render order is set to i * 2 to account for front and back rendering
695
+ readPrimitivesItem(referenceURL,metadata[i],2*i,callback)}},xmlhttp.open("GET",requestURL,!0),xmlhttp.send()}};
680
696
 
681
697
  /***/ }),
682
698
  /* 27 */
699
+ /***/ (function(module, exports) {
700
+
701
+ module.exports = require("three/examples/jsm/loaders/STLLoader");
702
+
703
+ /***/ }),
704
+ /* 28 */
705
+ /***/ (function(module, exports) {
706
+
707
+ module.exports = require("three/examples/jsm/loaders/OBJLoader");
708
+
709
+ /***/ }),
710
+ /* 29 */
711
+ /***/ (function(module, exports) {
712
+
713
+ module.exports = require("three/examples/jsm/loaders/GLTFLoader");
714
+
715
+ /***/ }),
716
+ /* 30 */
717
+ /***/ (function(module, exports, __webpack_require__) {
718
+
719
+ var GLTFExporter=__webpack_require__(31).GLTFExporter,SceneExporter=function(sceneIn){this.exportGLTF=binary=>{var exporter=new GLTFExporter,options={binary};return new Promise(resolve=>{exporter.parse(sceneIn.getThreeJSScene(),function(gltf){resolve(gltf)},options)})}};/**
720
+ * Provides an object which uses for exporting the scene
721
+ *
722
+ * @class
723
+ * @author Alan Wu
724
+ * @return {Zinc.Lines}
725
+ */exports.SceneExporter=SceneExporter;
726
+
727
+ /***/ }),
728
+ /* 31 */
683
729
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
684
730
 
685
731
  "use strict";
686
732
  __webpack_require__.r(__webpack_exports__);
687
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "STLLoader", function() { return STLLoader; });
688
- var THREE=__webpack_require__(3);/**
689
- * @author aleeper / http://adamleeper.com/
690
- * @author mrdoob / http://mrdoob.com/
691
- * @author gero3 / https://github.com/gero3
692
- * @author Mugen87 / https://github.com/Mugen87
733
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GLTFExporter", function() { return GLTFExporter; });
734
+ /* harmony import */ var three__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
735
+ /* harmony import */ var three__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(three__WEBPACK_IMPORTED_MODULE_0__);
736
+ class GLTFExporter{constructor(){this.pluginCallbacks=[],this.register(function(writer){return new GLTFLightExtension(writer)}),this.register(function(writer){return new GLTFMaterialsUnlitExtension(writer)}),this.register(function(writer){return new GLTFMaterialsPBRSpecularGlossiness(writer)})}register(callback){return-1===this.pluginCallbacks.indexOf(callback)&&this.pluginCallbacks.push(callback),this}unregister(callback){return-1!==this.pluginCallbacks.indexOf(callback)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(callback),1),this}/**
737
+ * Parse scenes and generate GLTF output
738
+ * @param {Scene or [THREE.Scenes]} input Scene or Array of THREE.Scenes
739
+ * @param {Function} onDone Callback on completed
740
+ * @param {Object} options options
741
+ */parse(input,onDone,options){for(var writer=new GLTFWriter,plugins=[],i=0,il=this.pluginCallbacks.length;i<il;i++)plugins.push(this.pluginCallbacks[i](writer));writer.setPlugins(plugins),writer.write(input,onDone,options)}}//------------------------------------------------------------------------------
742
+ // Constants
743
+ //------------------------------------------------------------------------------
744
+ var WEBGL_CONSTANTS={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123,FLOAT:5126,UNSIGNED_INT:5125,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},THREE_TO_WEBGL={};THREE_TO_WEBGL[three__WEBPACK_IMPORTED_MODULE_0__["NearestFilter"]]=WEBGL_CONSTANTS.NEAREST,THREE_TO_WEBGL[three__WEBPACK_IMPORTED_MODULE_0__["NearestMipmapNearestFilter"]]=WEBGL_CONSTANTS.NEAREST_MIPMAP_NEAREST,THREE_TO_WEBGL[three__WEBPACK_IMPORTED_MODULE_0__["NearestMipmapLinearFilter"]]=WEBGL_CONSTANTS.NEAREST_MIPMAP_LINEAR,THREE_TO_WEBGL[three__WEBPACK_IMPORTED_MODULE_0__["LinearFilter"]]=WEBGL_CONSTANTS.LINEAR,THREE_TO_WEBGL[three__WEBPACK_IMPORTED_MODULE_0__["LinearMipmapNearestFilter"]]=WEBGL_CONSTANTS.LINEAR_MIPMAP_NEAREST,THREE_TO_WEBGL[three__WEBPACK_IMPORTED_MODULE_0__["LinearMipmapLinearFilter"]]=WEBGL_CONSTANTS.LINEAR_MIPMAP_LINEAR,THREE_TO_WEBGL[three__WEBPACK_IMPORTED_MODULE_0__["ClampToEdgeWrapping"]]=WEBGL_CONSTANTS.CLAMP_TO_EDGE,THREE_TO_WEBGL[three__WEBPACK_IMPORTED_MODULE_0__["RepeatWrapping"]]=WEBGL_CONSTANTS.REPEAT,THREE_TO_WEBGL[three__WEBPACK_IMPORTED_MODULE_0__["MirroredRepeatWrapping"]]=WEBGL_CONSTANTS.MIRRORED_REPEAT;var PATH_PROPERTIES={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},GLB_HEADER_BYTES=12,GLB_HEADER_MAGIC=1179937895,GLB_VERSION=2,GLB_CHUNK_PREFIX_BYTES=8,GLB_CHUNK_TYPE_JSON=1313821514,GLB_CHUNK_TYPE_BIN=5130562;// GLB constants
745
+ // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#glb-file-format-specification
746
+ //------------------------------------------------------------------------------
747
+ // Utility functions
748
+ //------------------------------------------------------------------------------
749
+ /**
750
+ * Compare two arrays
751
+ * @param {Array} array1 Array 1 to compare
752
+ * @param {Array} array2 Array 2 to compare
753
+ * @return {Boolean} Returns true if both arrays are equal
754
+ */function equalArray(array1,array2){return array1.length===array2.length&&array1.every(function(element,index){return element===array2[index]})}/**
755
+ * Converts a string to an ArrayBuffer.
756
+ * @param {string} text
757
+ * @return {ArrayBuffer}
758
+ */function stringToArrayBuffer(text){if(window.TextEncoder!==void 0)return new TextEncoder().encode(text).buffer;for(var value,array=new Uint8Array(new ArrayBuffer(text.length)),i=0,il=text.length;i<il;i++)// Replacing multi-byte character with space(0x20).
759
+ value=text.charCodeAt(i),array[i]=255<value?32:value;return array.buffer}/**
760
+ * Is identity matrix
693
761
  *
694
- * Description: A THREE loader for STL ASCII files, as created by Solidworks and other CAD programs.
762
+ * @param {Matrix4} matrix
763
+ * @returns {Boolean} Returns true, if parameter is identity matrix
764
+ */function isIdentityMatrix(matrix){return equalArray(matrix.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}/**
765
+ * Get the min and max vectors from the given attribute
766
+ * @param {BufferAttribute} attribute Attribute to find the min/max in range from start to start + count
767
+ * @param {Integer} start
768
+ * @param {Integer} count
769
+ * @return {Object} Object containing the `min` and `max` values (As an array of attribute.itemSize components)
770
+ */function getMinMax(attribute,start,count){for(var output={min:Array(attribute.itemSize).fill(Number.POSITIVE_INFINITY),max:Array(attribute.itemSize).fill(Number.NEGATIVE_INFINITY)},i=start;i<start+count;i++)for(var value,a=0;a<attribute.itemSize;a++)value=void 0,4<attribute.itemSize?value=attribute.array[i*attribute.itemSize+a]:0===a?value=attribute.getX(i):1===a?value=attribute.getY(i):2===a?value=attribute.getZ(i):3==a&&(value=attribute.getW(i)),output.min[a]=Math.min(output.min[a],value),output.max[a]=Math.max(output.max[a],value);return output}/**
771
+ * Get the required size + padding for a buffer, rounded to the next 4-byte boundary.
772
+ * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#data-alignment
695
773
  *
696
- * Supports both binary and ASCII encoded files, with automatic detection of type.
774
+ * @param {Integer} bufferSize The size the original buffer.
775
+ * @returns {Integer} new buffer size with required padding.
697
776
  *
698
- * The loader returns a non-indexed buffer geometry.
777
+ */function getPaddedBufferSize(bufferSize){return 4*Math.ceil(bufferSize/4)}/**
778
+ * Returns a buffer aligned to 4-byte boundary.
699
779
  *
700
- * Limitations:
701
- * Binary decoding supports "Magics" color format (http://en.wikipedia.org/wiki/STL_(file_format)#Color_in_binary_STL).
702
- * There is perhaps some question as to how valid it is to always assume little-endian-ness.
703
- * ASCII decoding assumes file is UTF-8.
780
+ * @param {ArrayBuffer} arrayBuffer Buffer to pad
781
+ * @param {Integer} paddingByte (Optional)
782
+ * @returns {ArrayBuffer} The same buffer if it's already aligned to 4-byte boundary or a new buffer
783
+ */function getPaddedArrayBuffer(arrayBuffer){var paddingByte=1<arguments.length&&arguments[1]!==void 0?arguments[1]:0,paddedLength=getPaddedBufferSize(arrayBuffer.byteLength);if(paddedLength!==arrayBuffer.byteLength){var array=new Uint8Array(paddedLength);if(array.set(new Uint8Array(arrayBuffer)),0!==paddingByte)for(var i=arrayBuffer.byteLength;i<paddedLength;i++)array[i]=paddingByte;return array.buffer}return arrayBuffer}var cachedCanvas=null;/**
784
+ * Writer
785
+ */class GLTFWriter{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(plugins){this.plugins=plugins}/**
786
+ * Parse scenes and generate GLTF output
787
+ * @param {Scene or [THREE.Scenes]} input Scene or Array of THREE.Scenes
788
+ * @param {Function} onDone Callback on completed
789
+ * @param {Object} options options
790
+ */write(input,onDone,options){this.options=Object.assign({},{// default options
791
+ binary:!1,trs:!1,onlyVisible:!0,truncateDrawRange:!0,embedImages:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},options),0<this.options.animations.length&&(this.options.trs=!0),this.processInput(input);var writer=this;Promise.all(this.pending).then(function(){var buffers=writer.buffers,json=writer.json,options=writer.options,extensionsUsed=writer.extensionsUsed,blob=new Blob(buffers,{type:"application/octet-stream"}),extensionsUsedList=Object.keys(extensionsUsed);if(0<extensionsUsedList.length&&(json.extensionsUsed=extensionsUsedList),json.buffers&&0<json.buffers.length&&(json.buffers[0].byteLength=blob.size),!0===options.binary){// https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#glb-file-format-specification
792
+ var reader=new window.FileReader;reader.readAsArrayBuffer(blob),reader.onloadend=function(){// Binary chunk.
793
+ var binaryChunk=getPaddedArrayBuffer(reader.result),binaryChunkPrefix=new DataView(new ArrayBuffer(GLB_CHUNK_PREFIX_BYTES));binaryChunkPrefix.setUint32(0,binaryChunk.byteLength,!0),binaryChunkPrefix.setUint32(4,GLB_CHUNK_TYPE_BIN,!0);// JSON chunk.
794
+ var jsonChunk=getPaddedArrayBuffer(stringToArrayBuffer(JSON.stringify(json)),32),jsonChunkPrefix=new DataView(new ArrayBuffer(GLB_CHUNK_PREFIX_BYTES));jsonChunkPrefix.setUint32(0,jsonChunk.byteLength,!0),jsonChunkPrefix.setUint32(4,GLB_CHUNK_TYPE_JSON,!0);// GLB header.
795
+ var header=new ArrayBuffer(GLB_HEADER_BYTES),headerView=new DataView(header);headerView.setUint32(0,GLB_HEADER_MAGIC,!0),headerView.setUint32(4,GLB_VERSION,!0);var totalByteLength=GLB_HEADER_BYTES+jsonChunkPrefix.byteLength+jsonChunk.byteLength+binaryChunkPrefix.byteLength+binaryChunk.byteLength;headerView.setUint32(8,totalByteLength,!0);var glbBlob=new Blob([header,jsonChunkPrefix,jsonChunk,binaryChunkPrefix,binaryChunk],{type:"application/octet-stream"}),glbReader=new window.FileReader;glbReader.readAsArrayBuffer(glbBlob),glbReader.onloadend=function(){onDone(glbReader.result)}}}else if(json.buffers&&0<json.buffers.length){var _reader=new window.FileReader;_reader.readAsDataURL(blob),_reader.onloadend=function(){var base64data=_reader.result;json.buffers[0].uri=base64data,onDone(json)}}else onDone(json)})}/**
796
+ * Serializes a userData.
797
+ *
798
+ * @param {THREE.Object3D|THREE.Material} object
799
+ * @param {Object} objectDef
800
+ */serializeUserData(object,objectDef){if(!(object.userData&&object.userData.isZincObject)&&0!==Object.keys(object.userData).length){var options=this.options,extensionsUsed=this.extensionsUsed;try{var json=JSON.parse(JSON.stringify(object.userData));if(options.includeCustomExtensions&&json.gltfExtensions){for(var extensionName in void 0===objectDef.extensions&&(objectDef.extensions={}),json.gltfExtensions)objectDef.extensions[extensionName]=json.gltfExtensions[extensionName],extensionsUsed[extensionName]=!0;delete json.gltfExtensions}0<Object.keys(json).length&&(objectDef.extras=json)}catch(error){console.warn("THREE.GLTFExporter: userData of '"+object.name+"' "+"won't be serialized because of JSON.stringify error - "+error.message)}}}/**
801
+ * Assign and return a temporal unique id for an object
802
+ * especially which doesn't have .uuid
803
+ * @param {Object} object
804
+ * @return {Integer}
805
+ */getUID(object){return this.uids.has(object)||this.uids.set(object,this.uid++),this.uids.get(object)}/**
806
+ * Checks if normal attribute values are normalized.
807
+ *
808
+ * @param {BufferAttribute} normal
809
+ * @returns {Boolean}
810
+ */isNormalizedNormalAttribute(normal){var cache=this.cache;if(cache.attributesNormalized.has(normal))return!1;for(var v=new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"],i=0,il=normal.count;i<il;i++)// 0.0005 is from glTF-validator
811
+ if(5e-4<Math.abs(v.fromBufferAttribute(normal,i).length()-1))return!1;return!0}/**
812
+ * Creates normalized normal buffer attribute.
813
+ *
814
+ * @param {BufferAttribute} normal
815
+ * @returns {BufferAttribute}
816
+ *
817
+ */createNormalizedNormalAttribute(normal){var cache=this.cache;if(cache.attributesNormalized.has(normal))return cache.attributesNormalized.get(normal);for(var attribute=normal.clone(),v=new three__WEBPACK_IMPORTED_MODULE_0__["Vector3"],i=0,il=attribute.count;i<il;i++)v.fromBufferAttribute(attribute,i),0===v.x&&0===v.y&&0===v.z?v.setX(1):v.normalize(),attribute.setXYZ(i,v.x,v.y,v.z);return cache.attributesNormalized.set(normal,attribute),attribute}/**
818
+ * Applies a texture transform, if present, to the map definition. Requires
819
+ * the KHR_texture_transform extension.
820
+ *
821
+ * @param {Object} mapDef
822
+ * @param {THREE.Texture} texture
823
+ */applyTextureTransform(mapDef,texture){var didTransform=!1,transformDef={};(0!==texture.offset.x||0!==texture.offset.y)&&(transformDef.offset=texture.offset.toArray(),didTransform=!0),0!==texture.rotation&&(transformDef.rotation=texture.rotation,didTransform=!0),(1!==texture.repeat.x||1!==texture.repeat.y)&&(transformDef.scale=texture.repeat.toArray(),didTransform=!0),didTransform&&(mapDef.extensions=mapDef.extensions||{},mapDef.extensions.KHR_texture_transform=transformDef,this.extensionsUsed.KHR_texture_transform=!0)}/**
824
+ * Process a buffer to append to the default one.
825
+ * @param {ArrayBuffer} buffer
826
+ * @return {Integer}
827
+ */processBuffer(buffer){var json=this.json,buffers=this.buffers;return json.buffers||(json.buffers=[{byteLength:0}]),buffers.push(buffer),0}/**
828
+ * Process and generate a BufferView
829
+ * @param {BufferAttribute} attribute
830
+ * @param {number} componentType
831
+ * @param {number} start
832
+ * @param {number} count
833
+ * @param {number} target (Optional) Target usage of the BufferView
834
+ * @return {Object}
835
+ */processBufferView(attribute,componentType,start,count,target){var json=this.json;json.bufferViews||(json.bufferViews=[]);// Create a new dataview and dump the attribute's array into it
836
+ var componentSize=componentType===WEBGL_CONSTANTS.UNSIGNED_BYTE?1:componentType===WEBGL_CONSTANTS.UNSIGNED_SHORT?2:4;for(var byteLength=getPaddedBufferSize(count*attribute.itemSize*componentSize),dataView=new DataView(new ArrayBuffer(byteLength)),offset=0,i=start;i<start+count;i++)for(var value,a=0;a<attribute.itemSize;a++)value=void 0,4<attribute.itemSize?value=attribute.array[i*attribute.itemSize+a]:0===a?value=attribute.getX(i):1===a?value=attribute.getY(i):2===a?value=attribute.getZ(i):3==a&&(value=attribute.getW(i)),componentType===WEBGL_CONSTANTS.FLOAT?dataView.setFloat32(offset,value,!0):componentType===WEBGL_CONSTANTS.UNSIGNED_INT?dataView.setUint32(offset,value,!0):componentType===WEBGL_CONSTANTS.UNSIGNED_SHORT?dataView.setUint16(offset,value,!0):componentType===WEBGL_CONSTANTS.UNSIGNED_BYTE&&dataView.setUint8(offset,value),offset+=componentSize;var bufferViewDef={buffer:this.processBuffer(dataView.buffer),byteOffset:this.byteOffset,byteLength:byteLength};target!==void 0&&(bufferViewDef.target=target),target===WEBGL_CONSTANTS.ARRAY_BUFFER&&(bufferViewDef.byteStride=attribute.itemSize*componentSize),this.byteOffset+=byteLength,json.bufferViews.push(bufferViewDef);// @TODO Merge bufferViews where possible.
837
+ var output={id:json.bufferViews.length-1,byteLength:0};return output}/**
838
+ * Process and generate a BufferView from an image Blob.
839
+ * @param {Blob} blob
840
+ * @return {Promise<Integer>}
841
+ */processBufferViewImage(blob){var writer=this,json=writer.json;return json.bufferViews||(json.bufferViews=[]),new Promise(function(resolve){var reader=new window.FileReader;reader.readAsArrayBuffer(blob),reader.onloadend=function(){var buffer=getPaddedArrayBuffer(reader.result),bufferViewDef={buffer:writer.processBuffer(buffer),byteOffset:writer.byteOffset,byteLength:buffer.byteLength};writer.byteOffset+=buffer.byteLength,resolve(json.bufferViews.push(bufferViewDef)-1)}})}/**
842
+ * Process attribute to generate an accessor
843
+ * @param {BufferAttribute} attribute Attribute to process
844
+ * @param {THREE.BufferGeometry} geometry (Optional) Geometry used for truncated draw range
845
+ * @param {Integer} start (Optional)
846
+ * @param {Integer} count (Optional)
847
+ * @return {Integer|null} Index of the processed accessor on the "accessors" array
848
+ */processAccessor(attribute,geometry,start,count){var componentType,options=this.options,json=this.json;// Detect the component type of the attribute array (float, uint or ushort)
849
+ if(attribute.array.constructor===Float32Array)componentType=WEBGL_CONSTANTS.FLOAT;else if(attribute.array.constructor===Uint32Array)componentType=WEBGL_CONSTANTS.UNSIGNED_INT;else if(attribute.array.constructor===Uint16Array)componentType=WEBGL_CONSTANTS.UNSIGNED_SHORT;else if(attribute.array.constructor===Uint8Array)componentType=WEBGL_CONSTANTS.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type.");// @TODO Indexed buffer geometry with drawRange not supported yet
850
+ if(void 0===start&&(start=0),void 0===count&&(count=attribute.count),options.truncateDrawRange&&void 0!==geometry&&null===geometry.index){var end=start+count,end2=geometry.drawRange.count===1/0?attribute.count:geometry.drawRange.start+geometry.drawRange.count;start=Math.max(start,geometry.drawRange.start),count=Math.min(end,end2)-start,0>count&&(count=0)}// Skip creating an accessor if the attribute doesn't have data to export
851
+ if(0===count)return null;var bufferViewTarget,minMax=getMinMax(attribute,start,count);void 0!==geometry&&(bufferViewTarget=attribute===geometry.index?WEBGL_CONSTANTS.ELEMENT_ARRAY_BUFFER:WEBGL_CONSTANTS.ARRAY_BUFFER);var bufferView=this.processBufferView(attribute,componentType,start,count,bufferViewTarget),accessorDef={bufferView:bufferView.id,byteOffset:bufferView.byteOffset,componentType:componentType,count:count,max:minMax.max,min:minMax.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"}[attribute.itemSize]};return!0===attribute.normalized&&(accessorDef.normalized=!0),json.accessors||(json.accessors=[]),json.accessors.push(accessorDef)-1}/**
852
+ * Process image
853
+ * @param {Image} image to process
854
+ * @param {Integer} format of the image (e.g. RGBFormat, RGBAFormat etc)
855
+ * @param {Boolean} flipY before writing out the image
856
+ * @return {Integer} Index of the processed texture in the "images" array
857
+ */processImage(image,format,flipY){var writer=this,cache=writer.cache,json=writer.json,options=writer.options,pending=writer.pending;cache.images.has(image)||cache.images.set(image,{});var cachedImages=cache.images.get(image),mimeType=format===three__WEBPACK_IMPORTED_MODULE_0__["RGBAFormat"]?"image/png":"image/jpeg",key=mimeType+":flipY/"+flipY.toString();if(void 0!==cachedImages[key])return cachedImages[key];json.images||(json.images=[]);var imageDef={mimeType:mimeType};if(options.embedImages){var canvas=cachedCanvas=cachedCanvas||document.createElement("canvas");canvas.width=Math.min(image.width,options.maxTextureSize),canvas.height=Math.min(image.height,options.maxTextureSize);var ctx=canvas.getContext("2d");if(!0===flipY&&(ctx.translate(0,canvas.height),ctx.scale(1,-1)),"undefined"!=typeof HTMLImageElement&&image instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&image instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&image instanceof OffscreenCanvas||"undefined"!=typeof ImageBitmap&&image instanceof ImageBitmap)ctx.drawImage(image,0,0,canvas.width,canvas.height);else{format!==three__WEBPACK_IMPORTED_MODULE_0__["RGBAFormat"]&&format!==three__WEBPACK_IMPORTED_MODULE_0__["RGBFormat"]&&console.error("GLTFExporter: Only RGB and RGBA formats are supported."),(image.width>options.maxTextureSize||image.height>options.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",image);var data=new Uint8ClampedArray(4*(image.height*image.width));if(format===three__WEBPACK_IMPORTED_MODULE_0__["RGBAFormat"])for(var i=0;i<data.length;i+=4)data[i+0]=image.data[i+0],data[i+1]=image.data[i+1],data[i+2]=image.data[i+2],data[i+3]=image.data[i+3];else for(var _i=0,j=0;_i<data.length;_i+=4,j+=3)data[_i+0]=image.data[j+0],data[_i+1]=image.data[j+1],data[_i+2]=image.data[j+2],data[_i+3]=255;ctx.putImageData(new ImageData(data,image.width,image.height),0,0)}!0===options.binary?pending.push(new Promise(function(resolve){canvas.toBlob(function(blob){writer.processBufferViewImage(blob).then(function(bufferViewIndex){imageDef.bufferView=bufferViewIndex,resolve()})},mimeType)})):imageDef.uri=canvas.toDataURL(mimeType)}else imageDef.uri=image.src;var index=json.images.push(imageDef)-1;return cachedImages[key]=index,index}/**
858
+ * Process sampler
859
+ * @param {Texture} map Texture to process
860
+ * @return {Integer} Index of the processed texture in the "samplers" array
861
+ */processSampler(map){var json=this.json;json.samplers||(json.samplers=[]);var samplerDef={magFilter:THREE_TO_WEBGL[map.magFilter],minFilter:THREE_TO_WEBGL[map.minFilter],wrapS:THREE_TO_WEBGL[map.wrapS],wrapT:THREE_TO_WEBGL[map.wrapT]};return json.samplers.push(samplerDef)-1}/**
862
+ * Process texture
863
+ * @param {Texture} map Map to process
864
+ * @return {Integer} Index of the processed texture in the "textures" array
865
+ */processTexture(map){var cache=this.cache,json=this.json;if(cache.textures.has(map))return cache.textures.get(map);json.textures||(json.textures=[]);var textureDef={sampler:this.processSampler(map),source:this.processImage(map.image,map.format,map.flipY)};map.name&&(textureDef.name=map.name),this._invokeAll(function(ext){ext.writeTexture&&ext.writeTexture(map,textureDef)});var index=json.textures.push(textureDef)-1;return cache.textures.set(map,index),index}/**
866
+ * Process material
867
+ * @param {THREE.Material} material Material to process
868
+ * @return {Integer|null} Index of the processed material in the "materials" array
869
+ */processMaterial(material){var cache=this.cache,json=this.json;if(cache.materials.has(material))return cache.materials.get(material);if(material.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;json.materials||(json.materials=[]);// @QUESTION Should we avoid including any attribute that has the default value?
870
+ var materialDef={pbrMetallicRoughness:{}};!0!==material.isMeshStandardMaterial&&!0!==material.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");// pbrMetallicRoughness.baseColorFactor
871
+ var color=material.color.toArray().concat([material.opacity]);// pbrMetallicRoughness.metallicRoughnessTexture
872
+ if(equalArray(color,[1,1,1,1])||(materialDef.pbrMetallicRoughness.baseColorFactor=color),material.isMeshStandardMaterial?(materialDef.pbrMetallicRoughness.metallicFactor=material.metalness,materialDef.pbrMetallicRoughness.roughnessFactor=material.roughness):(materialDef.pbrMetallicRoughness.metallicFactor=.5,materialDef.pbrMetallicRoughness.roughnessFactor=.5),material.metalnessMap||material.roughnessMap)if(material.metalnessMap===material.roughnessMap){var metalRoughMapDef={index:this.processTexture(material.metalnessMap)};this.applyTextureTransform(metalRoughMapDef,material.metalnessMap),materialDef.pbrMetallicRoughness.metallicRoughnessTexture=metalRoughMapDef}else console.warn("THREE.GLTFExporter: Ignoring metalnessMap and roughnessMap because they are not the same Texture.");// pbrMetallicRoughness.baseColorTexture or pbrSpecularGlossiness diffuseTexture
873
+ if(material.map){var baseColorMapDef={index:this.processTexture(material.map)};this.applyTextureTransform(baseColorMapDef,material.map),materialDef.pbrMetallicRoughness.baseColorTexture=baseColorMapDef}if(material.emissive){// note: emissive components are limited to stay within the 0 - 1 range to accommodate glTF spec. see #21849 and #22000.
874
+ var emissive=material.emissive.clone().multiplyScalar(material.emissiveIntensity),maxEmissiveComponent=Math.max(emissive.r,emissive.g,emissive.b);// emissiveTexture
875
+ if(1<maxEmissiveComponent&&(emissive.multiplyScalar(1/maxEmissiveComponent),console.warn("THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),0<maxEmissiveComponent&&(materialDef.emissiveFactor=emissive.toArray()),material.emissiveMap){var emissiveMapDef={index:this.processTexture(material.emissiveMap)};this.applyTextureTransform(emissiveMapDef,material.emissiveMap),materialDef.emissiveTexture=emissiveMapDef}}// normalTexture
876
+ if(material.normalMap){var normalMapDef={index:this.processTexture(material.normalMap)};material.normalScale&&-1!==material.normalScale.x&&(material.normalScale.x!==material.normalScale.y&&console.warn("THREE.GLTFExporter: Normal scale components are different, ignoring Y and exporting X."),normalMapDef.scale=material.normalScale.x),this.applyTextureTransform(normalMapDef,material.normalMap),materialDef.normalTexture=normalMapDef}// occlusionTexture
877
+ if(material.aoMap){var occlusionMapDef={index:this.processTexture(material.aoMap),texCoord:1};1!==material.aoMapIntensity&&(occlusionMapDef.strength=material.aoMapIntensity),this.applyTextureTransform(occlusionMapDef,material.aoMap),materialDef.occlusionTexture=occlusionMapDef}// alphaMode
878
+ material.transparent?materialDef.alphaMode="BLEND":0<material.alphaTest&&(materialDef.alphaMode="MASK",materialDef.alphaCutoff=material.alphaTest),material.side===three__WEBPACK_IMPORTED_MODULE_0__["DoubleSide"]&&(materialDef.doubleSided=!0),""!==material.name&&(materialDef.name=material.name),this.serializeUserData(material,materialDef),this._invokeAll(function(ext){ext.writeMaterial&&ext.writeMaterial(material,materialDef)});var index=json.materials.push(materialDef)-1;return cache.materials.set(material,index),index}/**
879
+ * Process mesh
880
+ * @param {THREE.Mesh} mesh Mesh to process
881
+ * @return {Integer|null} Index of the processed mesh in the "meshes" array
882
+ */processMesh(mesh){var cache=this.cache,json=this.json,meshCacheKeyParts=[mesh.geometry.uuid];if(Array.isArray(mesh.material))for(var i=0,l=mesh.material.length;i<l;i++)meshCacheKeyParts.push(mesh.material[i].uuid);else meshCacheKeyParts.push(mesh.material.uuid);var meshCacheKey=meshCacheKeyParts.join(":");if(cache.meshes.has(meshCacheKey))return cache.meshes.get(meshCacheKey);var mode,geometry=mesh.geometry;if(mode=mesh.isLineSegments?WEBGL_CONSTANTS.LINES:mesh.isLineLoop?WEBGL_CONSTANTS.LINE_LOOP:mesh.isLine?WEBGL_CONSTANTS.LINE_STRIP:mesh.isPoints?WEBGL_CONSTANTS.POINTS:mesh.material.wireframe?WEBGL_CONSTANTS.LINES:WEBGL_CONSTANTS.TRIANGLES,!0!==geometry.isBufferGeometry)throw new Error("THREE.GLTFExporter: Geometry is not of type THREE.BufferGeometry.");var meshDef={},attributes={},primitives=[],targets=[],nameConversion={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},originalNormal=geometry.getAttribute("normal");void 0===originalNormal||this.isNormalizedNormalAttribute(originalNormal)||(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),geometry.setAttribute("normal",this.createNormalizedNormalAttribute(originalNormal)));// @QUESTION Detect if .vertexColors = true?
883
+ // For every attribute create an accessor
884
+ var modifiedAttribute=null;for(var attributeName in geometry.attributes)// Ignore morph target attributes, which are exported later.
885
+ if("morph"!==attributeName.substr(0,5)){var attribute=geometry.attributes[attributeName];attributeName=nameConversion[attributeName]||attributeName.toUpperCase();// Prefix all geometry attributes except the ones specifically
886
+ // listed in the spec; non-spec attributes are considered custom.
887
+ var validVertexAttributes=/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/;if(validVertexAttributes.test(attributeName)||(attributeName="_"+attributeName),cache.attributes.has(this.getUID(attribute))){attributes[attributeName]=cache.attributes.get(this.getUID(attribute));continue}// JOINTS_0 must be UNSIGNED_BYTE or UNSIGNED_SHORT.
888
+ modifiedAttribute=null;var array=attribute.array;"JOINTS_0"!==attributeName||array instanceof Uint16Array||array instanceof Uint8Array||(console.warn("GLTFExporter: Attribute \"skinIndex\" converted to type UNSIGNED_SHORT."),modifiedAttribute=new three__WEBPACK_IMPORTED_MODULE_0__["BufferAttribute"](new Uint16Array(array),attribute.itemSize,attribute.normalized));var accessor=this.processAccessor(modifiedAttribute||attribute,geometry);null!==accessor&&(attributes[attributeName]=accessor,cache.attributes.set(this.getUID(attribute),accessor))}// Skip if no exportable attributes found
889
+ if(void 0!==originalNormal&&geometry.setAttribute("normal",originalNormal),0===Object.keys(attributes).length)return null;// Morph targets
890
+ if(void 0!==mesh.morphTargetInfluences&&0<mesh.morphTargetInfluences.length){var weights=[],targetNames=[],reverseDictionary={};if(void 0!==mesh.morphTargetDictionary)for(var key in mesh.morphTargetDictionary)reverseDictionary[mesh.morphTargetDictionary[key]]=key;for(var _i2=0;_i2<mesh.morphTargetInfluences.length;++_i2){var target={},warned=!1;for(var _attributeName in geometry.morphAttributes){// glTF 2.0 morph supports only POSITION/NORMAL/TANGENT.
891
+ // Three.js doesn't support TANGENT yet.
892
+ if("position"!=_attributeName&&"normal"!==_attributeName){warned||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),warned=!0);continue}var _attribute=geometry.morphAttributes[_attributeName][_i2],gltfAttributeName=_attributeName.toUpperCase(),baseAttribute=geometry.attributes[_attributeName];if(cache.attributes.has(this.getUID(_attribute))){target[gltfAttributeName]=cache.attributes.get(this.getUID(_attribute));continue}// Clones attribute not to override
893
+ var relativeAttribute=_attribute.clone();if(!geometry.morphTargetsRelative)for(var j=0,jl=_attribute.count;j<jl;j++)relativeAttribute.setXYZ(j,_attribute.getX(j)-baseAttribute.getX(j),_attribute.getY(j)-baseAttribute.getY(j),_attribute.getZ(j)-baseAttribute.getZ(j));target[gltfAttributeName]=this.processAccessor(relativeAttribute,geometry),cache.attributes.set(this.getUID(baseAttribute),target[gltfAttributeName])}targets.push(target),weights.push(mesh.morphTargetInfluences[_i2]),void 0!==mesh.morphTargetDictionary&&targetNames.push(reverseDictionary[_i2])}meshDef.weights=weights,0<targetNames.length&&(meshDef.extras={},meshDef.extras.targetNames=targetNames)}var isMultiMaterial=Array.isArray(mesh.material);if(isMultiMaterial&&0===geometry.groups.length)return null;for(var primitive,materials=isMultiMaterial?mesh.material:[mesh.material],groups=isMultiMaterial?geometry.groups:[{materialIndex:0,start:void 0,count:void 0}],_i3=0,il=groups.length;_i3<il;_i3++){if(primitive={mode:mode,attributes:attributes},this.serializeUserData(geometry,primitive),0<targets.length&&(primitive.targets=targets),null!==geometry.index){var cacheKey=this.getUID(geometry.index);(void 0!==groups[_i3].start||void 0!==groups[_i3].count)&&(cacheKey+=":"+groups[_i3].start+":"+groups[_i3].count),cache.attributes.has(cacheKey)?primitive.indices=cache.attributes.get(cacheKey):(primitive.indices=this.processAccessor(geometry.index,geometry,groups[_i3].start,groups[_i3].count),cache.attributes.set(cacheKey,primitive.indices)),null===primitive.indices&&delete primitive.indices}var material=this.processMaterial(materials[groups[_i3].materialIndex]);null!==material&&(primitive.material=material),primitives.push(primitive)}meshDef.primitives=primitives,json.meshes||(json.meshes=[]),this._invokeAll(function(ext){ext.writeMesh&&ext.writeMesh(mesh,meshDef)});var index=json.meshes.push(meshDef)-1;return cache.meshes.set(meshCacheKey,index),index}/**
894
+ * Process camera
895
+ * @param {THREE.Camera} camera Camera to process
896
+ * @return {Integer} Index of the processed mesh in the "camera" array
897
+ */processCamera(camera){var json=this.json;json.cameras||(json.cameras=[]);var isOrtho=camera.isOrthographicCamera,cameraDef={type:isOrtho?"orthographic":"perspective"};return isOrtho?cameraDef.orthographic={xmag:2*camera.right,ymag:2*camera.top,zfar:0>=camera.far?.001:camera.far,znear:0>camera.near?0:camera.near}:cameraDef.perspective={aspectRatio:camera.aspect,yfov:three__WEBPACK_IMPORTED_MODULE_0__["MathUtils"].degToRad(camera.fov),zfar:0>=camera.far?.001:camera.far,znear:0>camera.near?0:camera.near},""!==camera.name&&(cameraDef.name=camera.type),json.cameras.push(cameraDef)-1}/**
898
+ * Creates glTF animation entry from AnimationClip object.
899
+ *
900
+ * Status:
901
+ * - Only properties listed in PATH_PROPERTIES may be animated.
902
+ *
903
+ * @param {THREE.AnimationClip} clip
904
+ * @param {THREE.Object3D} root
905
+ * @return {number|null}
906
+ */processAnimation(clip,root){var json=this.json,nodeMap=this.nodeMap;json.animations||(json.animations=[]),clip=GLTFExporter.Utils.mergeMorphTargetTracks(clip.clone(),root);for(var tracks=clip.tracks,channels=[],samplers=[],i=0;i<tracks.length;++i){var track=tracks[i],trackBinding=three__WEBPACK_IMPORTED_MODULE_0__["PropertyBinding"].parseTrackName(track.name),trackNode=three__WEBPACK_IMPORTED_MODULE_0__["PropertyBinding"].findNode(root,trackBinding.nodeName),trackProperty=PATH_PROPERTIES[trackBinding.propertyName];if("bones"===trackBinding.objectName&&(!0===trackNode.isSkinnedMesh?trackNode=trackNode.skeleton.getBoneByName(trackBinding.objectIndex):trackNode=void 0),!trackNode||!trackProperty)return console.warn("THREE.GLTFExporter: Could not export animation track \"%s\".",track.name),null;var outputItemSize=track.values.length/track.times.length;trackProperty===PATH_PROPERTIES.morphTargetInfluences&&(outputItemSize/=trackNode.morphTargetInfluences.length);var interpolation=void 0;// @TODO export CubicInterpolant(InterpolateSmooth) as CUBICSPLINE
907
+ // Detecting glTF cubic spline interpolant by checking factory method's special property
908
+ // GLTFCubicSplineInterpolant is a custom interpolant and track doesn't return
909
+ // valid value from .getInterpolation().
910
+ !0===track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(interpolation="CUBICSPLINE",outputItemSize/=3):track.getInterpolation()===three__WEBPACK_IMPORTED_MODULE_0__["InterpolateDiscrete"]?interpolation="STEP":interpolation="LINEAR",samplers.push({input:this.processAccessor(new three__WEBPACK_IMPORTED_MODULE_0__["BufferAttribute"](track.times,1)),output:this.processAccessor(new three__WEBPACK_IMPORTED_MODULE_0__["BufferAttribute"](track.values,outputItemSize)),interpolation:interpolation}),channels.push({sampler:samplers.length-1,target:{node:nodeMap.get(trackNode),path:trackProperty}})}return json.animations.push({name:clip.name||"clip_"+json.animations.length,samplers:samplers,channels:channels}),json.animations.length-1}/**
911
+ * @param {THREE.Object3D} object
912
+ * @return {number|null}
913
+ */processSkin(object){var json=this.json,nodeMap=this.nodeMap,node=json.nodes[nodeMap.get(object)],skeleton=object.skeleton;if(skeleton===void 0)return null;var rootJoint=object.skeleton.bones[0];if(rootJoint===void 0)return null;for(var joints=[],inverseBindMatrices=new Float32Array(16*skeleton.bones.length),temporaryBoneInverse=new three__WEBPACK_IMPORTED_MODULE_0__["Matrix4"],i=0;i<skeleton.bones.length;++i)joints.push(nodeMap.get(skeleton.bones[i])),temporaryBoneInverse.copy(skeleton.boneInverses[i]),temporaryBoneInverse.multiply(object.bindMatrix).toArray(inverseBindMatrices,16*i);json.skins===void 0&&(json.skins=[]),json.skins.push({inverseBindMatrices:this.processAccessor(new three__WEBPACK_IMPORTED_MODULE_0__["BufferAttribute"](inverseBindMatrices,16)),joints:joints,skeleton:nodeMap.get(rootJoint)});var skinIndex=node.skin=json.skins.length-1;return skinIndex}/**
914
+ * Process Object3D node
915
+ * @param {THREE.Object3D} node Object3D to processNode
916
+ * @return {Integer} Index of the node in the nodes list
917
+ */processNode(object){var json=this.json,options=this.options,nodeMap=this.nodeMap;json.nodes||(json.nodes=[]);var nodeDef={};if(options.trs){var rotation=object.quaternion.toArray(),position=object.position.toArray(),scale=object.scale.toArray();equalArray(rotation,[0,0,0,1])||(nodeDef.rotation=rotation),equalArray(position,[0,0,0])||(nodeDef.translation=position),equalArray(scale,[1,1,1])||(nodeDef.scale=scale)}else object.matrixAutoUpdate&&object.updateMatrix(),!1===isIdentityMatrix(object.matrix)&&(nodeDef.matrix=object.matrix.elements);// We don't export empty strings name because it represents no-name in Three.js.
918
+ if(""!==object.name&&(nodeDef.name=object.name+""),this.serializeUserData(object,nodeDef),object.isMesh||object.isLine||object.isPoints){var meshIndex=this.processMesh(object);null!==meshIndex&&(nodeDef.mesh=meshIndex)}else object.isCamera&&(nodeDef.camera=this.processCamera(object));if(object.isSkinnedMesh&&this.skins.push(object),0<object.children.length){for(var child,children=[],i=0,l=object.children.length;i<l;i++)if(child=object.children[i],child.visible||!1===options.onlyVisible){var _nodeIndex=this.processNode(child);null!==_nodeIndex&&children.push(_nodeIndex)}0<children.length&&(nodeDef.children=children)}this._invokeAll(function(ext){ext.writeNode&&ext.writeNode(object,nodeDef)});var nodeIndex=json.nodes.push(nodeDef)-1;return nodeMap.set(object,nodeIndex),nodeIndex}/**
919
+ * Process Scene
920
+ * @param {Scene} node Scene to process
921
+ */processScene(scene){var json=this.json,options=this.options;json.scenes||(json.scenes=[],json.scene=0);var sceneDef={};""!==scene.name&&(sceneDef.name=scene.name),json.scenes.push(sceneDef);for(var child,nodes=[],i=0,l=scene.children.length;i<l;i++)if(child=scene.children[i],child.visible||!1===options.onlyVisible){var nodeIndex=this.processNode(child);null!==nodeIndex&&nodes.push(nodeIndex)}0<nodes.length&&(sceneDef.nodes=nodes),this.serializeUserData(scene,sceneDef)}/**
922
+ * Creates a Scene to hold a list of objects and parse it
923
+ * @param {Array} objects List of objects to process
924
+ */processObjects(objects){var scene=new three__WEBPACK_IMPORTED_MODULE_0__["Scene"];scene.name="AuxScene";for(var i=0;i<objects.length;i++)// We push directly to children instead of calling `add` to prevent
925
+ // modify the .parent and break its original scene and hierarchy
926
+ scene.children.push(objects[i]);this.processScene(scene)}/**
927
+ * @param {THREE.Object3D|Array<THREE.Object3D>} input
928
+ */processInput(input){var options=this.options;input=input instanceof Array?input:[input],this._invokeAll(function(ext){ext.beforeParse&&ext.beforeParse(input)});for(var objectsWithoutScene=[],i=0;i<input.length;i++)input[i]instanceof three__WEBPACK_IMPORTED_MODULE_0__["Scene"]?this.processScene(input[i]):objectsWithoutScene.push(input[i]);0<objectsWithoutScene.length&&this.processObjects(objectsWithoutScene);for(var _i4=0;_i4<this.skins.length;++_i4)this.processSkin(this.skins[_i4]);for(var _i5=0;_i5<options.animations.length;++_i5)this.processAnimation(options.animations[_i5],input[0]);this._invokeAll(function(ext){ext.afterParse&&ext.afterParse(input)})}_invokeAll(func){for(var i=0,il=this.plugins.length;i<il;i++)func(this.plugins[i])}}/**
929
+ * Punctual Lights Extension
704
930
  *
705
- * Usage:
706
- * var loader = new THREE.STLLoader();
707
- * loader.load( './models/stl/slotted_disk.stl', function ( geometry ) {
708
- * scene.add( new THREE.Mesh( geometry ) );
709
- * });
931
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual
932
+ */class GLTFLightExtension{constructor(writer){this.writer=writer,this.name="KHR_lights_punctual"}writeNode(light,nodeDef){if(light.isLight){if(!light.isDirectionalLight&&!light.isPointLight&&!light.isSpotLight)return void console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",light);var writer=this.writer,json=writer.json,extensionsUsed=writer.extensionsUsed,lightDef={};light.name&&(lightDef.name=light.name),lightDef.color=light.color.toArray(),lightDef.intensity=light.intensity,light.isDirectionalLight?lightDef.type="directional":light.isPointLight?(lightDef.type="point",0<light.distance&&(lightDef.range=light.distance)):light.isSpotLight&&(lightDef.type="spot",0<light.distance&&(lightDef.range=light.distance),lightDef.spot={},lightDef.spot.innerConeAngle=-1*((light.penumbra-1)*light.angle),lightDef.spot.outerConeAngle=light.angle),void 0!==light.decay&&2!==light.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, "+"and expects light.decay=2."),light.target&&(light.target.parent!==light||0!==light.target.position.x||0!==light.target.position.y||-1!==light.target.position.z)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, "+"make light.target a child of the light with position 0,0,-1."),extensionsUsed[this.name]||(json.extensions=json.extensions||{},json.extensions[this.name]={lights:[]},extensionsUsed[this.name]=!0);var lights=json.extensions[this.name].lights;lights.push(lightDef),nodeDef.extensions=nodeDef.extensions||{},nodeDef.extensions[this.name]={light:lights.length-1}}}}/**
933
+ * Unlit Materials Extension
710
934
  *
711
- * For binary STLs geometry might contain colors for vertices. To use it:
712
- * // use the same code to load STL as above
713
- * if (geometry.hasColors) {
714
- * material = new THREE.MeshPhongMaterial({ opacity: geometry.alpha, vertexColors: THREE.VertexColors });
715
- * } else { .... }
716
- * var mesh = new THREE.Mesh( geometry, material );
717
- */function STLLoader(manager){this.manager=manager===void 0?THREE.DefaultLoadingManager:manager}STLLoader.prototype={constructor:STLLoader,load:function load(url,onLoad,onProgress,onError){var scope=this,loader=new THREE.FileLoader(scope.manager);loader.setResponseType("arraybuffer"),loader.load(url,function(text){try{onLoad(scope.parse(text))}catch(exception){onError&&onError(exception)}},onProgress,onError)},parse:function parse(data){// start
718
- var binData=function(buffer){if("string"==typeof buffer){for(var array_buffer=new Uint8Array(buffer.length),i=0;i<buffer.length;i++)array_buffer[i]=255&buffer.charCodeAt(i);// implicitly assumes little-endian
719
- return array_buffer.buffer||array_buffer}return buffer}(data);return function(data){var expect,face_size,n_faces,reader;if(reader=new DataView(data),face_size=3*(32/8)+3*(3*(32/8))+16/8,n_faces=reader.getUint32(80,!0),expect=80+32/8+n_faces*face_size,expect===reader.byteLength)return!0;// An ASCII STL data must begin with 'solid ' as the first six bytes.
720
- // However, ASCII STLs lacking the SPACE after the 'd' are known to be
721
- // plentiful. So, check the first 5 bytes for 'solid'.
722
- // US-ASCII ordinal values for 's', 'o', 'l', 'i', 'd'
723
- for(var solid=[115,111,108,105,100],i=0;5>i;i++)// If solid[ i ] does not match the i-th byte, then it is not an
724
- // ASCII STL; hence, it is binary and return true.
725
- if(solid[i]!=reader.getUint8(i,!1))return!0;// First 5 bytes read "solid"; declare it to be an ASCII STL
726
- return!1}(binData)?function(data){// process STL header
727
- // check for default color in header ("COLOR=rgba" sequence).
728
- for(var r,g,b,colors,defaultR,defaultG,defaultB,alpha,reader=new DataView(data),faces=reader.getUint32(80,!0),hasColors=!1,index=0;index<80-10;index++)1129270351==reader.getUint32(index,!1)/*COLO*/&&82==reader.getUint8(index+4)/*'R'*/&&61==reader.getUint8(index+5)/*'='*/&&(hasColors=!0,colors=[],defaultR=reader.getUint8(index+6)/255,defaultG=reader.getUint8(index+7)/255,defaultB=reader.getUint8(index+8)/255,alpha=reader.getUint8(index+9)/255);for(var geometry=new THREE.BufferGeometry,vertices=[],normals=[],face=0;face<faces;face++){var start=84+face*(12*4+2),normalX=reader.getFloat32(start,!0),normalY=reader.getFloat32(start+4,!0),normalZ=reader.getFloat32(start+8,!0);if(hasColors){var packedColor=reader.getUint16(start+48,!0);0==(32768&packedColor)?(r=(31&packedColor)/31,g=(31&packedColor>>5)/31,b=(31&packedColor>>10)/31):(r=defaultR,g=defaultG,b=defaultB)}for(var vertexstart,i=1;3>=i;i++)vertexstart=start+12*i,vertices.push(reader.getFloat32(vertexstart,!0)),vertices.push(reader.getFloat32(vertexstart+4,!0)),vertices.push(reader.getFloat32(vertexstart+8,!0)),normals.push(normalX,normalY,normalZ),hasColors&&colors.push(r,g,b)}return geometry.setAttribute("position",new THREE.BufferAttribute(new Float32Array(vertices),3)),geometry.setAttribute("normal",new THREE.BufferAttribute(new Float32Array(normals),3)),hasColors&&(geometry.setAttribute("color",new THREE.BufferAttribute(new Float32Array(colors),3)),geometry.hasColors=!0,geometry.alpha=alpha),geometry}(binData):function(data){for(var result,geometry=new THREE.BufferGeometry,patternFace=/facet([\s\S]*?)endfacet/g,faceCounter=0,patternFloat=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,patternVertex=new RegExp("vertex"+patternFloat+patternFloat+patternFloat,"g"),patternNormal=new RegExp("normal"+patternFloat+patternFloat+patternFloat,"g"),vertices=[],normals=[],normal=new THREE.Vector3;null!==(result=patternFace.exec(data));){for(var vertexCountPerFace=0,normalCountPerFace=0,text=result[0];null!==(result=patternNormal.exec(text));)normal.x=parseFloat(result[1]),normal.y=parseFloat(result[2]),normal.z=parseFloat(result[3]),normalCountPerFace++;for(;null!==(result=patternVertex.exec(text));)vertices.push(parseFloat(result[1]),parseFloat(result[2]),parseFloat(result[3])),normals.push(normal.x,normal.y,normal.z),vertexCountPerFace++;// every face have to own ONE valid normal
729
- 1!==normalCountPerFace&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+faceCounter),3!==vertexCountPerFace&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+faceCounter),faceCounter++}return geometry.setAttribute("position",new THREE.Float32BufferAttribute(vertices,3)),geometry.setAttribute("normal",new THREE.Float32BufferAttribute(normals,3)),geometry}(function(buffer){return"string"==typeof buffer?buffer:THREE.LoaderUtils.decodeText(new Uint8Array(buffer))}(data))}};
730
-
731
- /***/ }),
732
- /* 28 */
733
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
734
-
735
- "use strict";
736
- __webpack_require__.r(__webpack_exports__);
737
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OBJLoader", function() { return OBJLoader; });
738
- var THREE=__webpack_require__(3),OBJLoader=function(){function ParserState(){var state={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materialLibraries:[],startObject:function startObject(name,fromDeclaration){// If the current object (initial from reset) is not from a g/o declaration in the parsed
739
- // file. We need to use it for the first parsed g/o to keep things in sync.
740
- if(this.object&&!1===this.object.fromDeclaration)return this.object.name=name,void(this.object.fromDeclaration=!1!==fromDeclaration);var previousMaterial=this.object&&"function"==typeof this.object.currentMaterial?this.object.currentMaterial():void 0;// Inherit previous objects material.
741
- // Spec tells us that a declared material must be set to all objects until a new material is declared.
742
- // If a usemtl declaration is encountered while this new object is being parsed, it will
743
- // overwrite the inherited material. Exception being that there was already face declarations
744
- // to the inherited material, then it will be preserved for proper MultiMaterial continuation.
745
- if(this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0),this.object={name:name||"",fromDeclaration:!1!==fromDeclaration,geometry:{vertices:[],normals:[],colors:[],uvs:[]},materials:[],smooth:!0,startMaterial:function startMaterial(name,libraries){var previous=this._finalize(!1);// New usemtl declaration overwrites an inherited material, except if faces were declared
746
- // after the material, then it must be preserved for proper MultiMaterial continuation.
747
- previous&&(previous.inherited||0>=previous.groupCount)&&this.materials.splice(previous.index,1);var material={index:this.materials.length,name:name||"",mtllib:Array.isArray(libraries)&&0<libraries.length?libraries[libraries.length-1]:"",smooth:void 0===previous?this.smooth:previous.smooth,groupStart:void 0===previous?0:previous.groupEnd,groupEnd:-1,groupCount:-1,inherited:!1,clone:function clone(index){var cloned={index:"number"==typeof index?index:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return cloned.clone=this.clone.bind(cloned),cloned}};return this.materials.push(material),material},currentMaterial:function currentMaterial(){return 0<this.materials.length?this.materials[this.materials.length-1]:void 0},_finalize:function _finalize(end){var lastMultiMaterial=this.currentMaterial();// Ignore objects tail materials if no face declarations followed them before a new o/g started.
748
- if(lastMultiMaterial&&-1===lastMultiMaterial.groupEnd&&(lastMultiMaterial.groupEnd=this.geometry.vertices.length/3,lastMultiMaterial.groupCount=lastMultiMaterial.groupEnd-lastMultiMaterial.groupStart,lastMultiMaterial.inherited=!1),end&&1<this.materials.length)for(var mi=this.materials.length-1;0<=mi;mi--)0>=this.materials[mi].groupCount&&this.materials.splice(mi,1);// Guarantee at least one empty material, this makes the creation later more straight forward.
749
- return end&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),lastMultiMaterial}},previousMaterial&&previousMaterial.name&&"function"==typeof previousMaterial.clone){var declared=previousMaterial.clone(0);declared.inherited=!0,this.object.materials.push(declared)}this.objects.push(this.object)},finalize:function finalize(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function parseVertexIndex(value,len){var index=parseInt(value,10);return 3*(0<=index?index-1:index+len/3)},parseNormalIndex:function parseNormalIndex(value,len){var index=parseInt(value,10);return 3*(0<=index?index-1:index+len/3)},parseUVIndex:function parseUVIndex(value,len){var index=parseInt(value,10);return 2*(0<=index?index-1:index+len/2)},addVertex:function addVertex(a,b,c){var src=this.vertices,dst=this.object.geometry.vertices;dst.push(src[a+0],src[a+1],src[a+2]),dst.push(src[b+0],src[b+1],src[b+2]),dst.push(src[c+0],src[c+1],src[c+2])},addVertexPoint:function addVertexPoint(a){var src=this.vertices,dst=this.object.geometry.vertices;dst.push(src[a+0],src[a+1],src[a+2])},addVertexLine:function addVertexLine(a){var src=this.vertices,dst=this.object.geometry.vertices;dst.push(src[a+0],src[a+1],src[a+2])},addNormal:function addNormal(a,b,c){var src=this.normals,dst=this.object.geometry.normals;dst.push(src[a+0],src[a+1],src[a+2]),dst.push(src[b+0],src[b+1],src[b+2]),dst.push(src[c+0],src[c+1],src[c+2])},addColor:function addColor(a,b,c){var src=this.colors,dst=this.object.geometry.colors;dst.push(src[a+0],src[a+1],src[a+2]),dst.push(src[b+0],src[b+1],src[b+2]),dst.push(src[c+0],src[c+1],src[c+2])},addUV:function addUV(a,b,c){var src=this.uvs,dst=this.object.geometry.uvs;dst.push(src[a+0],src[a+1]),dst.push(src[b+0],src[b+1]),dst.push(src[c+0],src[c+1])},addUVLine:function addUVLine(a){var src=this.uvs,dst=this.object.geometry.uvs;dst.push(src[a+0],src[a+1])},addFace:function addFace(a,b,c,ua,ub,uc,na,nb,nc){var vLen=this.vertices.length,ia=this.parseVertexIndex(a,vLen),ib=this.parseVertexIndex(b,vLen),ic=this.parseVertexIndex(c,vLen);if(this.addVertex(ia,ib,ic),void 0!==ua&&""!==ua){var uvLen=this.uvs.length;ia=this.parseUVIndex(ua,uvLen),ib=this.parseUVIndex(ub,uvLen),ic=this.parseUVIndex(uc,uvLen),this.addUV(ia,ib,ic)}if(void 0!==na&&""!==na){// Normals are many times the same. If so, skip function call and parseInt.
750
- var nLen=this.normals.length;ia=this.parseNormalIndex(na,nLen),ib=na===nb?ia:this.parseNormalIndex(nb,nLen),ic=na===nc?ia:this.parseNormalIndex(nc,nLen),this.addNormal(ia,ib,ic)}0<this.colors.length&&this.addColor(ia,ib,ic)},addPointGeometry:function addPointGeometry(vertices){this.object.geometry.type="Points";for(var vLen=this.vertices.length,vi=0,l=vertices.length;vi<l;vi++)this.addVertexPoint(this.parseVertexIndex(vertices[vi],vLen))},addLineGeometry:function addLineGeometry(vertices,uvs){this.object.geometry.type="Line";for(var vLen=this.vertices.length,uvLen=this.uvs.length,vi=0,l=vertices.length;vi<l;vi++)this.addVertexLine(this.parseVertexIndex(vertices[vi],vLen));for(var uvi=0,l=uvs.length;uvi<l;uvi++)this.addUVLine(this.parseUVIndex(uvs[uvi],uvLen))}};return state.startObject("",!1),state}//
751
- function OBJLoader(manager){this.manager=void 0===manager?THREE.DefaultLoadingManager:manager,this.materials=null}// o object_name | g group_name
752
- var object_pattern=/^[og]\s*(.+)?/,material_library_pattern=/^mtllib /,material_use_pattern=/^usemtl /;// mtllib file_reference
753
- return OBJLoader.prototype={constructor:OBJLoader,load:function load(url,onLoad,onProgress,onError){var scope=this,loader=new THREE.FileLoader(scope.manager);loader.setPath(this.path),loader.load(url,function(text){onLoad(scope.parse(text))},onProgress,onError)},setPath:function setPath(value){return this.path=value,this},setMaterials:function setMaterials(materials){return this.materials=materials,this},parse:function parse(text){console.time("OBJLoader");var state=new ParserState;-1!==text.indexOf("\r\n")&&(text=text.replace(/\r\n/g,"\n")),-1!==text.indexOf("\\\n")&&(text=text.replace(/\\\n/g,""));for(var lines=text.split("\n"),line="",lineFirstChar="",lineLength=0,result=[],trimLeft="function"==typeof"".trimLeft,i=0,l=lines.length;i<l;i++)if(line=lines[i],line=trimLeft?line.trimLeft():line.trim(),lineLength=line.length,0!==lineLength&&(lineFirstChar=line.charAt(0),"#"!==lineFirstChar))// @todo invoke passed in handler if any
754
- if("v"===lineFirstChar){var data=line.split(/\s+/);switch(data[0]){case"v":state.vertices.push(parseFloat(data[1]),parseFloat(data[2]),parseFloat(data[3])),8===data.length&&state.colors.push(parseFloat(data[4]),parseFloat(data[5]),parseFloat(data[6]));break;case"vn":state.normals.push(parseFloat(data[1]),parseFloat(data[2]),parseFloat(data[3]));break;case"vt":state.uvs.push(parseFloat(data[1]),parseFloat(data[2]));}}else if("f"===lineFirstChar){// Parse the face vertex data into an easy to work with format
755
- for(var vertex,lineData=line.substr(1).trim(),vertexData=lineData.split(/\s+/),faceVertices=[],j=0,jl=vertexData.length;j<jl;j++)if(vertex=vertexData[j],0<vertex.length){var vertexParts=vertex.split("/");faceVertices.push(vertexParts)}// Draw an edge between the first vertex and all subsequent vertices to form an n-gon
756
- for(var v1=faceVertices[0],j=1,jl=faceVertices.length-1;j<jl;j++){var v2=faceVertices[j],v3=faceVertices[j+1];state.addFace(v1[0],v2[0],v3[0],v1[1],v2[1],v3[1],v1[2],v2[2],v3[2])}}else if("l"===lineFirstChar){var lineParts=line.substring(1).trim().split(" "),lineVertices=[],lineUVs=[];if(-1===line.indexOf("/"))lineVertices=lineParts;else for(var parts,li=0,llen=lineParts.length;li<llen;li++)parts=lineParts[li].split("/"),""!==parts[0]&&lineVertices.push(parts[0]),""!==parts[1]&&lineUVs.push(parts[1]);state.addLineGeometry(lineVertices,lineUVs)}else if("p"===lineFirstChar){var lineData=line.substr(1).trim(),pointData=lineData.split(" ");state.addPointGeometry(pointData)}else if(null!==(result=object_pattern.exec(line))){// o object_name
757
- // or
758
- // g group_name
759
- // WORKAROUND: https://bugs.chromium.org/p/v8/issues/detail?id=2869
760
- // var name = result[ 0 ].substr( 1 ).trim();
761
- var name=(" "+result[0].substr(1).trim()).substr(1);state.startObject(name)}else if(material_use_pattern.test(line))// material
762
- state.object.startMaterial(line.substring(7).trim(),state.materialLibraries);else if(material_library_pattern.test(line))// mtl file
763
- state.materialLibraries.push(line.substring(7).trim());else if("s"===lineFirstChar){// smooth shading
764
- // @todo Handle files that have varying smooth values for a set of faces inside one geometry,
765
- // but does not define a usemtl for each face set.
766
- // This should be detected and a dummy material created (later MultiMaterial and geometry groups).
767
- // This requires some care to not create extra material on each smooth value for "normal" obj files.
768
- // where explicit usemtl defines geometry groups.
769
- // Example asset: examples/models/obj/cerberus/Cerberus.obj
770
- /*
771
- * http://paulbourke.net/dataformats/obj/
772
- * or
773
- * http://www.cs.utah.edu/~boulos/cs3505/obj_spec.pdf
774
- *
775
- * From chapter "Grouping" Syntax explanation "s group_number":
776
- * "group_number is the smoothing group number. To turn off smoothing groups, use a value of 0 or off.
777
- * Polygonal elements use group numbers to put elements in different smoothing groups. For free-form
778
- * surfaces, smoothing groups are either turned on or off; there is no difference between values greater
779
- * than 0."
780
- */if(result=line.split(" "),1<result.length){var value=result[1].trim().toLowerCase();state.object.smooth="0"!==value&&"off"!==value}else// ZBrush can produce "s" lines #11707
781
- state.object.smooth=!0;var material=state.object.currentMaterial();material&&(material.smooth=state.object.smooth)}else{// Handle null terminated files without exception
782
- if("\0"===line)continue;throw new Error("THREE.OBJLoader: Unexpected line: \""+line+"\"")}state.finalize();var container=new THREE.Group;container.materialLibraries=[].concat(state.materialLibraries);for(var i=0,l=state.objects.length;i<l;i++){var object=state.objects[i],geometry=object.geometry,materials=object.materials,isLine="Line"===geometry.type,isPoints="Points"===geometry.type,hasVertexColors=!1;// Skip o/g line declarations that did not follow with any faces
783
- if(0!==geometry.vertices.length){var buffergeometry=new THREE.BufferGeometry;buffergeometry.setAttribute("position",new THREE.Float32BufferAttribute(geometry.vertices,3)),0<geometry.normals.length?buffergeometry.setAttribute("normal",new THREE.Float32BufferAttribute(geometry.normals,3)):buffergeometry.computeVertexNormals(),0<geometry.colors.length&&(hasVertexColors=!0,buffergeometry.setAttribute("color",new THREE.Float32BufferAttribute(geometry.colors,3))),0<geometry.uvs.length&&buffergeometry.setAttribute("uv",new THREE.Float32BufferAttribute(geometry.uvs,2));for(var createdMaterials=[],mi=0,miLen=materials.length;mi<miLen;mi++){var sourceMaterial=materials[mi],material=void 0;if(null!==this.materials)// mtl etc. loaders probably can't create line materials correctly, copy properties to a line material.
784
- if(material=this.materials.create(sourceMaterial.name),isLine&&material&&!(material instanceof THREE.LineBasicMaterial)){var materialLine=new THREE.LineBasicMaterial;materialLine.copy(material),materialLine.lights=!1,material=materialLine}else if(isPoints&&material&&!(material instanceof THREE.PointsMaterial)){var materialPoints=new THREE.PointsMaterial({size:10,sizeAttenuation:!1});materialLine.copy(material),material=materialPoints}material||(material=isLine?new THREE.LineBasicMaterial:isPoints?new THREE.PointsMaterial({size:1,sizeAttenuation:!1}):new THREE.MeshPhongMaterial,material.name=sourceMaterial.name),material.flatShading=!sourceMaterial.smooth,material.vertexColors=hasVertexColors?THREE.VertexColors:THREE.NoColors,createdMaterials.push(material)}// Create mesh
785
- var mesh;if(1<createdMaterials.length){for(var sourceMaterial,mi=0,miLen=materials.length;mi<miLen;mi++)sourceMaterial=materials[mi],buffergeometry.addGroup(sourceMaterial.groupStart,sourceMaterial.groupCount,mi);mesh=isLine?new THREE.LineSegments(buffergeometry,createdMaterials):isPoints?new THREE.Points(buffergeometry,createdMaterials):new THREE.Mesh(buffergeometry,createdMaterials)}else mesh=isLine?new THREE.LineSegments(buffergeometry,createdMaterials[0]):isPoints?new THREE.Points(buffergeometry,createdMaterials[0]):new THREE.Mesh(buffergeometry,createdMaterials[0]);mesh.name=object.name,container.add(mesh)}}return console.timeEnd("OBJLoader"),container}},OBJLoader}();/**
786
- * @author mrdoob / http://mrdoob.com/
787
- */
935
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit
936
+ */class GLTFMaterialsUnlitExtension{constructor(writer){this.writer=writer,this.name="KHR_materials_unlit"}writeMaterial(material,materialDef){if(material.isMeshBasicMaterial){var writer=this.writer,extensionsUsed=writer.extensionsUsed;materialDef.extensions=materialDef.extensions||{},materialDef.extensions[this.name]={},extensionsUsed[this.name]=!0,materialDef.pbrMetallicRoughness.metallicFactor=0,materialDef.pbrMetallicRoughness.roughnessFactor=.9}}}/**
937
+ * Specular-Glossiness Extension
938
+ *
939
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness
940
+ */class GLTFMaterialsPBRSpecularGlossiness{constructor(writer){this.writer=writer,this.name="KHR_materials_pbrSpecularGlossiness"}writeMaterial(material,materialDef){if(material.isGLTFSpecularGlossinessMaterial){var writer=this.writer,extensionsUsed=writer.extensionsUsed,extensionDef={};materialDef.pbrMetallicRoughness.baseColorFactor&&(extensionDef.diffuseFactor=materialDef.pbrMetallicRoughness.baseColorFactor);var specularFactor=[1,1,1];if(material.specular.toArray(specularFactor,0),extensionDef.specularFactor=specularFactor,extensionDef.glossinessFactor=material.glossiness,materialDef.pbrMetallicRoughness.baseColorTexture&&(extensionDef.diffuseTexture=materialDef.pbrMetallicRoughness.baseColorTexture),material.specularMap){var specularMapDef={index:writer.processTexture(material.specularMap)};writer.applyTextureTransform(specularMapDef,material.specularMap),extensionDef.specularGlossinessTexture=specularMapDef}materialDef.extensions=materialDef.extensions||{},materialDef.extensions[this.name]=extensionDef,extensionsUsed[this.name]=!0}}}/**
941
+ * Static utility functions
942
+ */GLTFExporter.Utils={insertKeyframe:function insertKeyframe(track,time){var index,tolerance=.001,valueSize=track.getValueSize(),times=new track.TimeBufferType(track.times.length+1),values=new track.ValueBufferType(track.values.length+valueSize),interpolant=track.createInterpolant(new track.ValueBufferType(valueSize));// 1ms
943
+ if(0===track.times.length){times[0]=time;for(var i=0;i<valueSize;i++)values[i]=0;index=0}else if(time<track.times[0]){if(Math.abs(track.times[0]-time)<tolerance)return 0;times[0]=time,times.set(track.times,1),values.set(interpolant.evaluate(time),0),values.set(track.values,valueSize),index=0}else if(time>track.times[track.times.length-1]){if(Math.abs(track.times[track.times.length-1]-time)<tolerance)return track.times.length-1;times[times.length-1]=time,times.set(track.times,0),values.set(track.values,0),values.set(interpolant.evaluate(time),track.values.length),index=times.length-1}else for(var _i6=0;_i6<track.times.length;_i6++){if(Math.abs(track.times[_i6]-time)<tolerance)return _i6;if(track.times[_i6]<time&&track.times[_i6+1]>time){times.set(track.times.slice(0,_i6+1),0),times[_i6+1]=time,times.set(track.times.slice(_i6+1),_i6+2),values.set(track.values.slice(0,(_i6+1)*valueSize),0),values.set(interpolant.evaluate(time),(_i6+1)*valueSize),values.set(track.values.slice((_i6+1)*valueSize),(_i6+2)*valueSize),index=_i6+1;break}}return track.times=times,track.values=values,index},mergeMorphTargetTracks:function mergeMorphTargetTracks(clip,root){for(var tracks=[],mergedTracks={},sourceTracks=clip.tracks,i=0;i<sourceTracks.length;++i){var sourceTrack=sourceTracks[i],sourceTrackBinding=three__WEBPACK_IMPORTED_MODULE_0__["PropertyBinding"].parseTrackName(sourceTrack.name),sourceTrackNode=three__WEBPACK_IMPORTED_MODULE_0__["PropertyBinding"].findNode(root,sourceTrackBinding.nodeName);if("morphTargetInfluences"!==sourceTrackBinding.propertyName||void 0===sourceTrackBinding.propertyIndex){tracks.push(sourceTrack);continue}if(sourceTrack.createInterpolant!==sourceTrack.InterpolantFactoryMethodDiscrete&&sourceTrack.createInterpolant!==sourceTrack.InterpolantFactoryMethodLinear){if(sourceTrack.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)// This should never happen, because glTF morph target animations
944
+ // affect all targets already.
945
+ throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),sourceTrack=sourceTrack.clone(),sourceTrack.setInterpolation(three__WEBPACK_IMPORTED_MODULE_0__["InterpolateLinear"])}var targetCount=sourceTrackNode.morphTargetInfluences.length,targetIndex=sourceTrackNode.morphTargetDictionary[sourceTrackBinding.propertyIndex];if(void 0===targetIndex)throw new Error("THREE.GLTFExporter: Morph target name not found: "+sourceTrackBinding.propertyIndex);var mergedTrack=void 0;// If this is the first time we've seen this object, create a new
946
+ // track to store merged keyframe data for each morph target.
947
+ if(void 0===mergedTracks[sourceTrackNode.uuid]){mergedTrack=sourceTrack.clone();for(var values=new mergedTrack.ValueBufferType(targetCount*mergedTrack.times.length),j=0;j<mergedTrack.times.length;j++)values[j*targetCount+targetIndex]=mergedTrack.values[j];// We need to take into consideration the intended target node
948
+ // of our original un-merged morphTarget animation.
949
+ mergedTrack.name=(sourceTrackBinding.nodeName||"")+".morphTargetInfluences",mergedTrack.values=values,mergedTracks[sourceTrackNode.uuid]=mergedTrack,tracks.push(mergedTrack);continue}var sourceInterpolant=sourceTrack.createInterpolant(new sourceTrack.ValueBufferType(1));mergedTrack=mergedTracks[sourceTrackNode.uuid];// For every existing keyframe of the merged track, write a (possibly
950
+ // interpolated) value from the source track.
951
+ for(var _j=0;_j<mergedTrack.times.length;_j++)mergedTrack.values[_j*targetCount+targetIndex]=sourceInterpolant.evaluate(mergedTrack.times[_j]);// For every existing keyframe of the source track, write a (possibly
952
+ // new) keyframe to the merged track. Values from the previous loop may
953
+ // be written again, but keyframes are de-duplicated.
954
+ for(var keyframeIndex,_j2=0;_j2<sourceTrack.times.length;_j2++)keyframeIndex=this.insertKeyframe(mergedTrack,sourceTrack.times[_j2]),mergedTrack.values[keyframeIndex*targetCount+targetIndex]=sourceTrack.values[_j2]}return clip.tracks=tracks,clip}};
788
955
 
789
956
  /***/ }),
790
- /* 29 */
957
+ /* 32 */
791
958
  /***/ (function(module, exports, __webpack_require__) {
792
959
 
793
- var THREE=__webpack_require__(3),resolveURL=__webpack_require__(6).resolveURL,Viewport=function(){this.nearPlane=.1,this.farPlane=2e3,this.eyePosition=[0,0,0],this.targetPosition=[0,0,0],this.upVector=[0,1,0];this},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},STATE={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM:4,TOUCH_PAN:5,SCROLL:6},CLICK_ACTION={};CLICK_ACTION.MAIN=STATE.ROTATE,CLICK_ACTION.AUXILIARY=STATE.ZOOM,CLICK_ACTION.SECONDARY=STATE.PAN,this.cameraObject=object,this.domElement=domElement===void 0?document:domElement,this.renderer=renderer,this.scene=scene,this.tumble_rate=1.5,this.pointer_x=0,this.pointer_y=0,this.pointer_x_start=0,this.pointer_y_start=0,this.previous_pointer_x=0,this.previous_pointer_y=0,this.near_plane_fly_debt=0,this.touchZoomDistanceStart=0,this.touchZoomDistanceEnd=0,this.directionalLight=0,this.scrollRate=50;var duration=6e3,inbuildTime=0,cameraPath=void 0,numberOfCameraPoint=void 0,updateLightWithPathFlag=!1,playRate=500,deviceOrientationControl=void 0,defaultViewport=new Viewport,currentMode=MODE.DEFAULT,smoothCameraTransitionObject=void 0,rotateCameraTransitionObject=void 0,cameraAutoTumbleObject=void 0,mouseScroll=0;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;this.cameraObject.target===void 0&&(this.cameraObject.target=new THREE.Vector3(0,0,0)),this.onResize=()=>{rect&&(rect=void 0)},this.setMouseButtonAction=(buttonName,actionName)=>{CLICK_ACTION[buttonName]=STATE[actionName]};var translateViewport=translation=>{this.cameraObject.target.add(translation),this.cameraObject.position.add(translation),this.updateDirectionalLight()},onDocumentMouseDown=event=>{void 0===rect&&(rect=this.domElement.getBoundingClientRect());// Check if mouse event hapens inside the minimap
794
- 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(void 0===rect&&(rect=this.domElement.getBoundingClientRect()),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=()=>{this._state=STATE.NONE},onDocumentTouchStart=event=>{rect===void 0&&(rect=this.domElement.getBoundingClientRect());var len=event.touches.length;if(1==len)this._state=STATE.TOUCH_ROTATE,this.pointer_x=event.touches[0].clientX-rect.left,this.pointer_y=event.touches[0].clientY-rect.top,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y;else if(2==len){this._state=STATE.TOUCH_ZOOM;var dx=event.touches[0].clientX-event.touches[1].clientX,dy=event.touches[0].clientY-event.touches[1].clientY;this.touchZoomDistanceEnd=this.touchZoomDistanceStart=Math.sqrt(dx*dx+dy*dy)}else 3==len&&(this._state=STATE.TOUCH_PAN,this.targetTouchId=event.touches[0].identifier,this.pointer_x=event.touches[0].clientX-rect.left,this.pointer_y=event.touches[0].clientY-rect.top,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y)},onDocumentTouchMove=event=>{event.preventDefault(),event.stopPropagation();var len=event.touches.length;if(1==len)this.pointer_x=event.touches[0].clientX-rect.left,this.pointer_y=event.touches[0].clientY-rect.top;else if(2==len){if(this._state===STATE.TOUCH_ZOOM){var dx=event.touches[0].clientX-event.touches[1].clientX,dy=event.touches[0].clientY-event.touches[1].clientY;this.touchZoomDistanceEnd=Math.sqrt(dx*dx+dy*dy)}}else if(3==len&&this._state===STATE.TOUCH_PAN)for(var i=0;3>i;i++)event.touches[i].identifier==this.targetTouchId&&(this.pointer_x=event.touches[0].clientX-rect.left,this.pointer_y=event.touches[0].clientY-rect.top)},onDocumentTouchEnd=event=>{var len=event.touches.length;this.touchZoomDistanceStart=this.touchZoomDistanceEnd=0,this.targetTouchId=-1,this._state=STATE.NONE,1==len&&zincRayCaster!==void 0&&this.pointer_x_start==event.touches[0].clientX-rect.left&&this.pointer_y_start==event.touches[0].clientY-rect.top&&zincRayCaster.pick(this.cameraObject,event.touches[0].clientX,event.touches[0].clientY,this.renderer)},onDocumentWheelEvent=event=>{rect===void 0&&(rect=this.domElement.getBoundingClientRect()),this._state=STATE.SCROLL;var changes=0;0<event.deltaY?changes=this.scrollRate:0>event.deltaY&&(changes=-1*this.scrollRate),mouseScroll+=changes,event.preventDefault(),event.stopImmediatePropagation()},translate=()=>{if("undefined"!=typeof this.cameraObject){var height=rect.height,distance=this.cameraObject.position.distanceTo(this.cameraObject.target),fact=0;this.cameraObject.far>this.cameraObject.near&&distance>=this.cameraObject.near&&distance<=this.cameraObject.far&&(fact=(distance-this.cameraObject.near)/(this.cameraObject.far-this.cameraObject.near)),_b.set(this.previous_pointer_x,height-this.previous_pointer_y,0),_c.set(this.previous_pointer_x,height-this.previous_pointer_y,1),_new_b.set(this.pointer_x,height-this.pointer_y,0),_new_c.set(this.pointer_x,height-this.pointer_y,1),_b.unproject(this.cameraObject),_c.unproject(this.cameraObject),_new_b.unproject(this.cameraObject),_new_c.unproject(this.cameraObject);_new_b.sub(_b).multiplyScalar(1-fact),_new_c.sub(_c).multiplyScalar(fact),_new_b.add(_new_c).multiplyScalar(-.002),translateViewport(_new_b)}this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y};this.getVectorsFromRotateAboutLookAtPoints=(axis,angle)=>{axis.normalize(),_v.copy(this.cameraObject.position).sub(this.cameraObject.target),_rel_eye.copy(_v),_v.normalize(),.8<Math.abs(_v.dot(axis))&&_v.copy(this.cameraObject.up),_b.crossVectors(axis,_v).normalize(),_c.crossVectors(axis,_b);var rel_eyea=axis.dot(_rel_eye),rel_eyeb=_b.dot(_rel_eye),rel_eyec=_c.dot(_rel_eye),upa=axis.dot(this.cameraObject.up),upb=_b.dot(this.cameraObject.up),upc=_c.dot(this.cameraObject.up),cos_angle=Math.cos(angle),sin_angle=Math.sin(angle);return _new_b.set(cos_angle*_b.x+sin_angle*_c.x,cos_angle*_b.y+sin_angle*_c.y,cos_angle*_b.z+sin_angle*_c.z),_new_c.set(cos_angle*_c.x-sin_angle*_b.x,cos_angle*_c.y-sin_angle*_b.y,cos_angle*_c.z-sin_angle*_b.z),_v.copy(this.cameraObject.target),_v.x=_v.x+axis.x*rel_eyea+_new_b.x*rel_eyeb+_new_c.x*rel_eyec,_v.y=_v.y+axis.y*rel_eyea+_new_b.y*rel_eyeb+_new_c.y*rel_eyec,_v.z=_v.z+axis.z*rel_eyea+_new_b.z*rel_eyeb+_new_c.z*rel_eyec,_a.set(axis.x*upa+_new_b.x*upb+_new_c.x*upc,axis.y*upa+_new_b.y*upb+_new_c.y*upc,axis.z*upa+_new_b.z*upb+_new_c.z*upc),{position:_v,up:_a}},this.rotateAboutLookAtpoint=(axis,angle)=>{var returned_values=this.getVectorsFromRotateAboutLookAtPoints(axis,angle);this.cameraObject.position.copy(returned_values.position),this.updateDirectionalLight(),this.cameraObject.up.copy(returned_values.up)};var tumble=()=>{if("undefined"!=typeof this.cameraObject){var width=rect.width,height=rect.height;if(0<width&&0<height){var radius=.25*(width+height);delta_x=this.pointer_x-this.previous_pointer_x,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=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?delta=mouseScroll:(delta=-1*(this.touchZoomDistanceEnd-this.touchZoomDistanceStart),this.touchZoomDistanceStart=this.touchZoomDistanceEnd),delta};this.changeZoomByScrollRateUnit=unit=>{var delta_y=unit*this.scrollRate;this.changeZoomByValue(delta_y)},this.changeZoomByValue=delta_y=>{if("undefined"!=typeof this.cameraObject){var width=rect.width,height=rect.height,a=this.cameraObject.position.clone();a.sub(this.cameraObject.target);var dist=a.length(),dy=1.5*delta_y/height;if(.01<dist+dy*dist){a.normalize();var eye_position=this.cameraObject.position.clone();eye_position.x+=a.x*dy*dist,eye_position.y+=a.y*dy*dist,eye_position.z+=a.z*dy*dist,this.cameraObject.position.set(eye_position.x,eye_position.y,eye_position.z),this.updateDirectionalLight();var near_far_minimum_ratio=1e-5;if(near_far_minimum_ratio*this.cameraObject.far<this.cameraObject.near+dy*dist+this.near_plane_fly_debt)0!=this.near_plane_fly_debt&&(this.near_plane_fly_debt+=dy*dist,0<this.near_plane_fly_debt?(this.cameraObject.near+=this.near_plane_fly_debt,this.cameraObject.far+=this.near_plane_fly_debt,this.near_plane_fly_debt=0):(this.cameraObject.near+=dy*dist,this.cameraObject.far+=dy*dist));else{if(0==this.near_plane_fly_debt){var diff=this.cameraObject.near-near_far_minimum_ratio*this.cameraObject.far;this.cameraObject.near=near_far_minimum_ratio*this.cameraObject.far,this.cameraObject.far-=diff,this.near_plane_fly_debt-=near_far_minimum_ratio*this.cameraObject.far}this.near_plane_fly_debt+=dy*dist}}}};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&&(mouseScroll=0)};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&&(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("contextmenu",event=>{event.preventDefault()},!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("contextmenu",event=>{event.preventDefault()},!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()}},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};var updateTime=delta=>{var targetTime=inbuildTime+delta;targetTime>duration&&(targetTime-=duration),inbuildTime=targetTime};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),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,1-(current_time-bottom_frame)]}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))};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]))}};/* tumble rate is in radians per second */this.calculatePathNow=()=>{updatePath(0)},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),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&&currentMode===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=()=>{this.cameraObject.near=defaultViewport.nearPlane,this.cameraObject.far=defaultViewport.farPlane,this.cameraObject.position.set(defaultViewport.eyePosition[0],defaultViewport.eyePosition[1],defaultViewport.eyePosition[2]),this.cameraObject.target.set(defaultViewport.targetPosition[0],defaultViewport.targetPosition[1],defaultViewport.targetPosition[2]),this.cameraObject.up.set(defaultViewport.upVector[0],defaultViewport.upVector[1],defaultViewport.upVector[2]),this.cameraObject.updateProjectionMatrix(),this.updateDirectionalLight()},this.setDefaultCameraSettings=newViewport=>{newViewport.nearPlane&&(defaultViewport.nearPlane=newViewport.nearPlane),newViewport.farPlane&&(defaultViewport.farPlane=newViewport.farPlane),newViewport.eyePosition&&(defaultViewport.eyePosition=newViewport.eyePosition),newViewport.targetPosition&&(defaultViewport.targetPosition=newViewport.targetPosition),newViewport.upVector&&(defaultViewport.upVector=newViewport.upVector)},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.getDefaultViewport=()=>defaultViewport,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.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,lastHovered=void 0,cooldown=!1;this.enable=()=>{enable=!0},this.disable=()=>{enable=!1};var getIntersectsObject=(zincCamera,x,y)=>{var rect=zincCamera.domElement.getBoundingClientRect();if(mouse.x=2*((x-rect.left)/rect.width)-1,mouse.y=2*-((y-rect.top)/rect.height)+1,hostSceneIn!==scene){var threejsScene=scene.getThreeJSScene();renderer.render(threejsScene,zincCamera.cameraObject)}raycaster.setFromCamera(mouse,zincCamera.cameraObject);var objects=scene.getPickableThreeJSObjects();return raycaster.intersectObjects(objects,!0)};this.pick=(zincCamera,x,y)=>{if(enabled&&renderer&&scene&&zincCamera&&callbackFunction){var intersects=getIntersectsObject(zincCamera,x,y);callbackFunction(intersects,x,y)}};var hovered=(zincCamera,x,y)=>{if(enabled&&renderer&&scene&&zincCamera&&hoverCallbackFunction){var intersects=getIntersectsObject(zincCamera,x,y);lastHovered=new Date,hoverCallbackFunction(intersects,x,y)}};this.move=(zincCamera,x,y)=>{if(enabled&&renderer&&scene&&zincCamera&&hoverCallbackFunction)if(scene.displayMarkers)hovered(zincCamera,x,y);else if(!cooldown){var now=new Date;!lastHovered||250<now.getTime()-lastHovered.getTime()?hovered(zincCamera,x,y):(cooldown=!0,setTimeout(awaitMove(zincCamera,x,y),250))}};var awaitMove=(zincCamera,x,y)=>function(){cooldown=!1,hovered(zincCamera,x,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 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},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
960
+ var THREE=__webpack_require__(3),resolveURL=__webpack_require__(6).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];this},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},STATE={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM:4,TOUCH_PAN:5,SCROLL:6},CLICK_ACTION={};CLICK_ACTION.MAIN=STATE.ROTATE,CLICK_ACTION.AUXILIARY=STATE.ZOOM,CLICK_ACTION.SECONDARY=STATE.PAN,this.cameraObject=object,this.domElement=domElement===void 0?document:domElement,this.renderer=renderer,this.scene=scene,this.tumble_rate=1.5,this.pointer_x=0,this.pointer_y=0,this.pointer_x_start=0,this.pointer_y_start=0,this.previous_pointer_x=0,this.previous_pointer_y=0,this.near_plane_fly_debt=0,this.touchZoomDistanceStart=0,this.touchZoomDistanceEnd=0,this.directionalLight=0,this.scrollRate=50;var duration=6e3,inbuildTime=0,cameraPath=void 0,numberOfCameraPoint=void 0,updateLightWithPathFlag=!1,playRate=500,deviceOrientationControl=void 0,defaultViewport=new Viewport,currentMode=MODE.DEFAULT,smoothCameraTransitionObject=void 0,rotateCameraTransitionObject=void 0,cameraAutoTumbleObject=void 0,mouseScroll=0;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,maxDist=0;this.cameraObject.target===void 0&&(this.cameraObject.target=new THREE.Vector3(0,0,0)),this.calculateMaxAllowedDistance=scene=>{var box=scene.getBoundingBox();if(box){box.getBoundingSphere(sceneSphere),maxDist=6*sceneSphere.radius;var currentDist=0;this.cameraObject&&(currentDist=this.cameraObject.position.distanceTo(sceneSphere.center)),maxDist=currentDist>maxDist?currentDist:maxDist}else maxDist=0},this.onResize=()=>{rect&&(rect=void 0)},this.setMouseButtonAction=(buttonName,actionName)=>{CLICK_ACTION[buttonName]=STATE[actionName]};//Make sure the camera does not travel beyond limit
961
+ var checkTravelDistance=()=>{if(0<maxDist){var newDist=_tempEye.distanceTo(sceneSphere.center);return maxDist>newDist||this.cameraObject.position.distanceTo(sceneSphere.center)>newDist}return!0},translateViewport=translation=>{_tempEye.copy(this.cameraObject.position).add(translation),checkTravelDistance()&&(this.cameraObject.target.add(translation),this.cameraObject.position.add(translation),this.updateDirectionalLight())},onDocumentMouseDown=event=>{void 0===rect&&(rect=this.domElement.getBoundingClientRect());// Check if mouse event hapens inside the minimap
962
+ 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(void 0===rect&&(rect=this.domElement.getBoundingClientRect()),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=()=>{this._state=STATE.NONE},onDocumentTouchStart=event=>{rect===void 0&&(rect=this.domElement.getBoundingClientRect());var len=event.touches.length;if(1==len)this._state=STATE.TOUCH_ROTATE,this.pointer_x=event.touches[0].clientX-rect.left,this.pointer_y=event.touches[0].clientY-rect.top,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y;else if(2==len){this._state=STATE.TOUCH_ZOOM;var dx=event.touches[0].clientX-event.touches[1].clientX,dy=event.touches[0].clientY-event.touches[1].clientY;this.touchZoomDistanceEnd=this.touchZoomDistanceStart=Math.sqrt(dx*dx+dy*dy)}else 3==len&&(this._state=STATE.TOUCH_PAN,this.targetTouchId=event.touches[0].identifier,this.pointer_x=event.touches[0].clientX-rect.left,this.pointer_y=event.touches[0].clientY-rect.top,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y)},onDocumentTouchMove=event=>{event.preventDefault(),event.stopPropagation();var len=event.touches.length;if(1==len)this.pointer_x=event.touches[0].clientX-rect.left,this.pointer_y=event.touches[0].clientY-rect.top;else if(2==len){if(this._state===STATE.TOUCH_ZOOM){var dx=event.touches[0].clientX-event.touches[1].clientX,dy=event.touches[0].clientY-event.touches[1].clientY;this.touchZoomDistanceEnd=Math.sqrt(dx*dx+dy*dy)}}else if(3==len&&this._state===STATE.TOUCH_PAN)for(var i=0;3>i;i++)event.touches[i].identifier==this.targetTouchId&&(this.pointer_x=event.touches[0].clientX-rect.left,this.pointer_y=event.touches[0].clientY-rect.top)},onDocumentTouchEnd=event=>{var len=event.touches.length;this.touchZoomDistanceStart=this.touchZoomDistanceEnd=0,this.targetTouchId=-1,this._state=STATE.NONE,1==len&&zincRayCaster!==void 0&&this.pointer_x_start==event.touches[0].clientX-rect.left&&this.pointer_y_start==event.touches[0].clientY-rect.top&&zincRayCaster.pick(this.cameraObject,event.touches[0].clientX,event.touches[0].clientY,this.renderer)},onDocumentWheelEvent=event=>{rect===void 0&&(rect=this.domElement.getBoundingClientRect()),this._state=STATE.SCROLL;var changes=0;0<event.deltaY?changes=this.scrollRate:0>event.deltaY&&(changes=-1*this.scrollRate),mouseScroll+=changes,event.preventDefault(),event.stopImmediatePropagation()},translate=()=>{if("undefined"!=typeof this.cameraObject){var height=rect.height,distance=this.cameraObject.position.distanceTo(this.cameraObject.target),fact=0;this.cameraObject.far>this.cameraObject.near&&distance>=this.cameraObject.near&&distance<=this.cameraObject.far&&(fact=(distance-this.cameraObject.near)/(this.cameraObject.far-this.cameraObject.near)),_b.set(this.previous_pointer_x,height-this.previous_pointer_y,0),_c.set(this.previous_pointer_x,height-this.previous_pointer_y,1),_new_b.set(this.pointer_x,height-this.pointer_y,0),_new_c.set(this.pointer_x,height-this.pointer_y,1),_b.unproject(this.cameraObject),_c.unproject(this.cameraObject),_new_b.unproject(this.cameraObject),_new_c.unproject(this.cameraObject);_new_b.sub(_b).multiplyScalar(1-fact),_new_c.sub(_c).multiplyScalar(fact),_new_b.add(_new_c).multiplyScalar(-.002),translateViewport(_new_b)}this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y};this.getVectorsFromRotateAboutLookAtPoints=(axis,angle)=>{axis.normalize(),_v.copy(this.cameraObject.position).sub(this.cameraObject.target),_rel_eye.copy(_v),_v.normalize(),.8<Math.abs(_v.dot(axis))&&_v.copy(this.cameraObject.up),_b.crossVectors(axis,_v).normalize(),_c.crossVectors(axis,_b);var rel_eyea=axis.dot(_rel_eye),rel_eyeb=_b.dot(_rel_eye),rel_eyec=_c.dot(_rel_eye),upa=axis.dot(this.cameraObject.up),upb=_b.dot(this.cameraObject.up),upc=_c.dot(this.cameraObject.up),cos_angle=Math.cos(angle),sin_angle=Math.sin(angle);return _new_b.set(cos_angle*_b.x+sin_angle*_c.x,cos_angle*_b.y+sin_angle*_c.y,cos_angle*_b.z+sin_angle*_c.z),_new_c.set(cos_angle*_c.x-sin_angle*_b.x,cos_angle*_c.y-sin_angle*_b.y,cos_angle*_c.z-sin_angle*_b.z),_v.copy(this.cameraObject.target),_v.x=_v.x+axis.x*rel_eyea+_new_b.x*rel_eyeb+_new_c.x*rel_eyec,_v.y=_v.y+axis.y*rel_eyea+_new_b.y*rel_eyeb+_new_c.y*rel_eyec,_v.z=_v.z+axis.z*rel_eyea+_new_b.z*rel_eyeb+_new_c.z*rel_eyec,_a.set(axis.x*upa+_new_b.x*upb+_new_c.x*upc,axis.y*upa+_new_b.y*upb+_new_c.y*upc,axis.z*upa+_new_b.z*upb+_new_c.z*upc),{position:_v,up:_a}},this.rotateAboutLookAtpoint=(axis,angle)=>{var returned_values=this.getVectorsFromRotateAboutLookAtPoints(axis,angle);this.cameraObject.position.copy(returned_values.position),this.updateDirectionalLight(),this.cameraObject.up.copy(returned_values.up)};var tumble=()=>{if("undefined"!=typeof this.cameraObject){var width=rect.width,height=rect.height;if(0<width&&0<height){var radius=.25*(width+height);delta_x=this.pointer_x-this.previous_pointer_x,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=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?delta=mouseScroll:(delta=-1*(this.touchZoomDistanceEnd-this.touchZoomDistanceStart),this.touchZoomDistanceStart=this.touchZoomDistanceEnd),delta};this.changeZoomByScrollRateUnit=unit=>{var delta_y=unit*this.scrollRate;this.changeZoomByValue(delta_y)},this.changeZoomByValue=delta_y=>{if("undefined"!=typeof this.cameraObject){var width=rect.width,height=rect.height,a=this.cameraObject.position.clone();a.sub(this.cameraObject.target);var dist=a.length(),dy=1.5*delta_y/height;if(.01<dist+dy*dist&&(a.normalize(),_tempEye.copy(this.cameraObject.position),_tempEye.x+=a.x*dy*dist,_tempEye.y+=a.y*dy*dist,_tempEye.z+=a.z*dy*dist,checkTravelDistance())){this.cameraObject.position.copy(_tempEye),this.updateDirectionalLight();var near_far_minimum_ratio=1e-5;if(near_far_minimum_ratio*this.cameraObject.far<this.cameraObject.near+dy*dist+this.near_plane_fly_debt)0!=this.near_plane_fly_debt&&(this.near_plane_fly_debt+=dy*dist,0<this.near_plane_fly_debt?(this.cameraObject.near+=this.near_plane_fly_debt,this.cameraObject.far+=this.near_plane_fly_debt,this.near_plane_fly_debt=0):(this.cameraObject.near+=dy*dist,this.cameraObject.far+=dy*dist));else{if(0==this.near_plane_fly_debt){var diff=this.cameraObject.near-near_far_minimum_ratio*this.cameraObject.far;this.cameraObject.near=near_far_minimum_ratio*this.cameraObject.far,this.cameraObject.far-=diff,this.near_plane_fly_debt-=near_far_minimum_ratio*this.cameraObject.far}this.near_plane_fly_debt+=dy*dist}}}};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&&(mouseScroll=0)};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&&(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("contextmenu",event=>{event.preventDefault()},!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("contextmenu",event=>{event.preventDefault()},!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()}},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};var updateTime=delta=>{var targetTime=inbuildTime+delta;targetTime>duration&&(targetTime-=duration),inbuildTime=targetTime};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),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,1-(current_time-bottom_frame)]}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))};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]))}};/* tumble rate is in radians per second */this.calculatePathNow=()=>{updatePath(0)},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),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&&currentMode===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=()=>{this.cameraObject.near=defaultViewport.nearPlane,this.cameraObject.far=defaultViewport.farPlane,this.cameraObject.position.set(defaultViewport.eyePosition[0],defaultViewport.eyePosition[1],defaultViewport.eyePosition[2]),this.cameraObject.target.set(defaultViewport.targetPosition[0],defaultViewport.targetPosition[1],defaultViewport.targetPosition[2]),this.cameraObject.up.set(defaultViewport.upVector[0],defaultViewport.upVector[1],defaultViewport.upVector[2]),this.cameraObject.updateProjectionMatrix(),this.updateDirectionalLight()},this.setDefaultCameraSettings=newViewport=>{newViewport.nearPlane&&(defaultViewport.nearPlane=newViewport.nearPlane),newViewport.farPlane&&(defaultViewport.farPlane=newViewport.farPlane),newViewport.eyePosition&&(defaultViewport.eyePosition=newViewport.eyePosition),newViewport.targetPosition&&(defaultViewport.targetPosition=newViewport.targetPosition),newViewport.upVector&&(defaultViewport.upVector=newViewport.upVector)},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.getDefaultViewport=()=>defaultViewport,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.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,lastHovered=void 0,cooldown=!1;this.enable=()=>{enable=!0},this.disable=()=>{enable=!1};var getIntersectsObject=(zincCamera,x,y)=>{var rect=zincCamera.domElement.getBoundingClientRect();if(mouse.x=2*((x-rect.left)/rect.width)-1,mouse.y=2*-((y-rect.top)/rect.height)+1,hostSceneIn!==scene){var threejsScene=scene.getThreeJSScene();renderer.render(threejsScene,zincCamera.cameraObject)}raycaster.setFromCamera(mouse,zincCamera.cameraObject);var objects=scene.getPickableThreeJSObjects();return raycaster.intersectObjects(objects,!0)};this.pick=(zincCamera,x,y)=>{if(enabled&&renderer&&scene&&zincCamera&&callbackFunction){var intersects=getIntersectsObject(zincCamera,x,y);callbackFunction(intersects,x,y)}};var hovered=(zincCamera,x,y)=>{if(enabled&&renderer&&scene&&zincCamera&&hoverCallbackFunction){var intersects=getIntersectsObject(zincCamera,x,y);lastHovered=new Date,hoverCallbackFunction(intersects,x,y)}};this.move=(zincCamera,x,y)=>{if(enabled&&renderer&&scene&&zincCamera&&hoverCallbackFunction)if(scene.displayMarkers)hovered(zincCamera,x,y);else if(!cooldown){var now=new Date;!lastHovered||250<now.getTime()-lastHovered.getTime()?hovered(zincCamera,x,y):(cooldown=!0,setTimeout(awaitMove(zincCamera,x,y),250))}};var awaitMove=(zincCamera,x,y)=>function(){cooldown=!1,hovered(zincCamera,x,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 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},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
795
963
  // http://paulbourke.net/stereographics/stereorender/
796
964
  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
797
965
  // for left eye
@@ -815,21 +983,21 @@ quaternion.setFromEuler(euler),quaternion.multiply(q1),quaternion.multiply(q0.se
815
983
  setObjectQuaternion(scope.object,alpha,beta,gamma,orient)}},this.dispose=function(){this.disconnect()},this.connect()},exports.Viewport=Viewport,exports.CameraControls=CameraControls,exports.SmoothCameraTransition=SmoothCameraTransition,exports.RotateCameraTransition=RotateCameraTransition,exports.RayCaster=RayCaster,exports.CameraAutoTumble=CameraAutoTumble,exports.StereoEffect=StereoEffect;
816
984
 
817
985
  /***/ }),
818
- /* 30 */
986
+ /* 33 */
819
987
  /***/ (function(module, exports, __webpack_require__) {
820
988
 
821
- var THREE=__webpack_require__(3);exports.Minimap=function(sceneIn){var targetScene=sceneIn;this.camera=new THREE.OrthographicCamera(-.5,.5,.5,-.5,.01,10),this.helper=void 0;var geometry=new THREE.BufferGeometry,vertices=new Float32Array([-1,-1,1,1,-1,1,1,1,1,1,1,1,-1,1,1,-1,-1,1]),positionAttributes=new THREE.BufferAttribute(vertices,3);geometry.setAttribute("position",positionAttributes);var material=new THREE.MeshBasicMaterial({color:3355443,depthTest:!1,depthWrite:!1,opacity:.5,transparent:!0});this.mask=new THREE.Mesh(geometry,material),this.getDiffFromNormalised=(x,y)=>{var centre=new THREE.Box3().setFromBufferAttribute(positionAttributes).getCenter(),coord=centre.clone().project(this.camera),new_coord=new THREE.Vector3(x,y,coord.z).unproject(this.camera);return new_coord.sub(centre)};var setCurrentCameraSettings=(diameter,newViewport)=>{targetScene.camera.near&&(this.camera.near=targetScene.camera.near),newViewport.farPlane&&(this.camera.far=newViewport.farPlane),newViewport.eyePosition&&this.camera.position.set(newViewport.eyePosition[0],newViewport.eyePosition[1],newViewport.eyePosition[2]),newViewport.upVector&&this.camera.up.set(newViewport.upVector[0],newViewport.upVector[1],newViewport.upVector[2]),newViewport.targetPosition&&this.camera.lookAt(new THREE.Vector3(newViewport.targetPosition[0],newViewport.targetPosition[1],newViewport.targetPosition[2])),this.camera.zoom=1/diameter,this.camera.updateProjectionMatrix()};this.getBoundary=()=>{var target=new THREE.Vector3().copy(targetScene.camera.target).project(targetScene.camera),v1=new THREE.Vector3(-1,-1,target.z).unproject(targetScene.camera),v2=new THREE.Vector3(1,-1,target.z).unproject(targetScene.camera),v3=new THREE.Vector3(1,1,target.z).unproject(targetScene.camera),v4=new THREE.Vector3(-1,1,target.z).unproject(targetScene.camera);positionAttributes.copyVector3sArray([v1,v2,v3,v3,v4,v1]),positionAttributes.needsUpdate=!0},this.updateCamera=()=>{this.getBoundary();var cameraControl=targetScene.getZincCameraControls(),boundingBox=targetScene.getBoundingBox();if(boundingBox){// enlarge radius to keep image within edge of window
989
+ var THREE=__webpack_require__(3);exports.Minimap=function(sceneIn){var targetScene=sceneIn;this.camera=new THREE.OrthographicCamera(-.5,.5,.5,-.5,.01,10),this.helper=void 0;var geometry=new THREE.BufferGeometry,vertices=new Float32Array([-1,-1,1,1,-1,1,1,1,1,1,1,1,-1,1,1,-1,-1,1]),positionAttributes=new THREE.BufferAttribute(vertices,3);geometry.setAttribute("position",positionAttributes);var material=new THREE.MeshBasicMaterial({color:3355443,depthTest:!1,depthWrite:!1,opacity:.5,transparent:!0});this.mask=new THREE.Mesh(geometry,material);var _box=new THREE.Box3,_center=new THREE.Vector3;this.getDiffFromNormalised=(x,y)=>{_box.setFromBufferAttribute(positionAttributes).getCenter(_center);var coord=_center.clone().project(this.camera),new_coord=new THREE.Vector3(x,y,coord.z).unproject(this.camera);return new_coord.sub(_center)};var setCurrentCameraSettings=(diameter,newViewport)=>{targetScene.camera.near&&(this.camera.near=targetScene.camera.near),newViewport.farPlane&&(this.camera.far=newViewport.farPlane),newViewport.eyePosition&&this.camera.position.set(newViewport.eyePosition[0],newViewport.eyePosition[1],newViewport.eyePosition[2]),newViewport.upVector&&this.camera.up.set(newViewport.upVector[0],newViewport.upVector[1],newViewport.upVector[2]),newViewport.targetPosition&&this.camera.lookAt(new THREE.Vector3(newViewport.targetPosition[0],newViewport.targetPosition[1],newViewport.targetPosition[2])),this.camera.zoom=1/diameter,this.camera.updateProjectionMatrix()};this.getBoundary=()=>{var target=new THREE.Vector3().copy(targetScene.camera.target).project(targetScene.camera),v1=new THREE.Vector3(-1,-1,target.z).unproject(targetScene.camera),v2=new THREE.Vector3(1,-1,target.z).unproject(targetScene.camera),v3=new THREE.Vector3(1,1,target.z).unproject(targetScene.camera),v4=new THREE.Vector3(-1,1,target.z).unproject(targetScene.camera);positionAttributes.copyVector3sArray([v1,v2,v3,v3,v4,v1]),positionAttributes.needsUpdate=!0},this.updateCamera=()=>{this.getBoundary();var cameraControl=targetScene.getZincCameraControls(),boundingBox=targetScene.getBoundingBox();if(boundingBox){// enlarge radius to keep image within edge of window
822
990
  var diameter=boundingBox.min.distanceTo(boundingBox.max),radius=diameter/2,centreX=(boundingBox.min.x+boundingBox.max.x)/2,centreY=(boundingBox.min.y+boundingBox.max.y)/2,centreZ=(boundingBox.min.z+boundingBox.max.z)/2,viewport=cameraControl.getViewportFromCentreAndRadius(centreX,centreY,centreZ,radius,40,radius*4);setCurrentCameraSettings(diameter,viewport)}}};
823
991
 
824
992
  /***/ }),
825
- /* 31 */
993
+ /* 34 */
826
994
  /***/ (function(module, exports, __webpack_require__) {
827
995
 
828
- var THREE=__webpack_require__(3),ThreeBSP=__webpack_require__(32)(THREE),Geometry=__webpack_require__(2).Geometry,work=__webpack_require__(33),Promise=__webpack_require__(34).default,JSONLoader=THREE.BufferGeometryLoader,GeometryCSG=function(hostIn){//ZincGeoemtry of the main geometry
829
- var host;hostIn&&hostIn.isGeometry&&(host=hostIn);var core=void 0,worker=void 0,onProgress=!1,myResolve=void 0,createGeometryFromJSON=json=>{var material=host.morph.material.clone();material.morphTargets=!1;var newGeometry=new Geometry,JSONParser=new JSONLoader,geometry=JSONParser.parse(json),mesh=new THREE.Mesh(geometry.geometry,material);return newGeometry.geometry=mesh.geometry,newGeometry.morph=mesh,newGeometry.morph.userData=newGeometry,newGeometry},workerEventHandler=ev=>{switch(ev.data.action){case"message":console.log(ev.data.message);break;case"result":var csg=new GeometryCSG(createGeometryFromJSON(ev.data.object));myResolve&&myResolve(csg),myResolve=void 0,onProgress=!1;break;default:throw"Cannot handle specified action.";}},initialise=hostIn=>{if(void 0!==work&&(worker=work(/*require.resolve*/(35))),!worker)core=new(__webpack_require__(36).GeometryCSGInternal)(hostIn);else if(hostIn&&hostIn.isGeometry){var mesh=hostIn.morph,json=mesh.geometry.clone().applyMatrix(mesh.matrix).toJSON();worker.addEventListener("message",function(ev){workerEventHandler(ev)}),worker.postMessage({action:"initialise",object:json})}};this.getHostGeometry=()=>{var tempCSG=new ThreeBSP(host.morph);return new createZincGeometry(tempCSG)},this.getGeometry=()=>host;var createZincGeometry=csgMesh=>{var material=host.morph.material.clone();material.morphTargets=!1;var newMesh=csgMesh.toMesh(material),newGeometry=new Geometry;return newGeometry.geometry=newMesh.geometry,newGeometry.morph=newMesh,newGeometry.morph.userData=newGeometry,newGeometry};this.setCSG=CSG=>{core.setCSG(CSG)};var sendToWork=(guestGeometry,action,resolve,reject)=>{if(!onProgress){var mesh=guestGeometry.morph,json=mesh.geometry.clone().applyMatrix(mesh.matrix).toJSON();myResolve=resolve,onProgress=!0,worker.postMessage({action:action,object:json})}else reject("On progress")};this.intersect=guestGeometry=>new Promise((resolve,reject)=>{if(worker)sendToWork(guestGeometry,"intersect",resolve,reject);else{var result=core.intersect(guestGeometry),newCSG=new GeometryCSG(createZincGeometry(result));newCSG.setCSG(result),resolve(newCSG)}}),this.subtract=guestGeometry=>new Promise((resolve,reject)=>{if(worker)sendToWork(guestGeometry,"intersect",resolve,reject);else{var result=core.subtract(guestGeometry),newCSG=new GeometryCSG(createZincGeometry(result));newCSG.setCSG(result),resolve(newCSG)}}),this.union=guestGeometry=>new Promise((resolve,reject)=>{if(worker)sendToWork(guestGeometry,"intersect",resolve,reject);else{var result=core.union(guestGeometry),newCSG=new GeometryCSG(createZincGeometry(result));newCSG.setCSG(result),resolve(newCSG)}}),this.terminateWorker=()=>{worker&&worker.terminate()},initialise(hostIn)};exports.GeometryCSG=GeometryCSG;
996
+ var THREE=__webpack_require__(3),ThreeBSP=__webpack_require__(35)(THREE),Geometry=__webpack_require__(2).Geometry,work=__webpack_require__(36),Promise=__webpack_require__(37).default,JSONLoader=THREE.BufferGeometryLoader,GeometryCSG=function(hostIn){//ZincGeoemtry of the main geometry
997
+ var host;hostIn&&hostIn.isGeometry&&(host=hostIn);var core=void 0,worker=void 0,onProgress=!1,myResolve=void 0,createGeometryFromJSON=json=>{var material=host.morph.material.clone();material.morphTargets=!1;var newGeometry=new Geometry,JSONParser=new JSONLoader,geometry=JSONParser.parse(json),mesh=new THREE.Mesh(geometry.geometry,material);return newGeometry.geometry=mesh.geometry,newGeometry.morph=mesh,newGeometry.morph.userData=newGeometry,newGeometry},workerEventHandler=ev=>{switch(ev.data.action){case"message":console.log(ev.data.message);break;case"result":var csg=new GeometryCSG(createGeometryFromJSON(ev.data.object));myResolve&&myResolve(csg),myResolve=void 0,onProgress=!1;break;default:throw"Cannot handle specified action.";}},initialise=hostIn=>{if(void 0!==work&&(worker=work(/*require.resolve*/(38))),!worker)core=new(__webpack_require__(39).GeometryCSGInternal)(hostIn);else if(hostIn&&hostIn.isGeometry){var mesh=hostIn.morph,json=mesh.geometry.clone().applyMatrix(mesh.matrix).toJSON();worker.addEventListener("message",function(ev){workerEventHandler(ev)}),worker.postMessage({action:"initialise",object:json})}};this.getHostGeometry=()=>{var tempCSG=new ThreeBSP(host.morph);return new createZincGeometry(tempCSG)},this.getGeometry=()=>host;var createZincGeometry=csgMesh=>{var material=host.morph.material.clone();material.morphTargets=!1;var newMesh=csgMesh.toMesh(material),newGeometry=new Geometry;return newGeometry.geometry=newMesh.geometry,newGeometry.morph=newMesh,newGeometry.morph.userData=newGeometry,newGeometry};this.setCSG=CSG=>{core.setCSG(CSG)};var sendToWork=(guestGeometry,action,resolve,reject)=>{if(!onProgress){var mesh=guestGeometry.morph,json=mesh.geometry.clone().applyMatrix(mesh.matrix).toJSON();myResolve=resolve,onProgress=!0,worker.postMessage({action:action,object:json})}else reject("On progress")};this.intersect=guestGeometry=>new Promise((resolve,reject)=>{if(worker)sendToWork(guestGeometry,"intersect",resolve,reject);else{var result=core.intersect(guestGeometry),newCSG=new GeometryCSG(createZincGeometry(result));newCSG.setCSG(result),resolve(newCSG)}}),this.subtract=guestGeometry=>new Promise((resolve,reject)=>{if(worker)sendToWork(guestGeometry,"intersect",resolve,reject);else{var result=core.subtract(guestGeometry),newCSG=new GeometryCSG(createZincGeometry(result));newCSG.setCSG(result),resolve(newCSG)}}),this.union=guestGeometry=>new Promise((resolve,reject)=>{if(worker)sendToWork(guestGeometry,"intersect",resolve,reject);else{var result=core.union(guestGeometry),newCSG=new GeometryCSG(createZincGeometry(result));newCSG.setCSG(result),resolve(newCSG)}}),this.terminateWorker=()=>{worker&&worker.terminate()},initialise(hostIn)};exports.GeometryCSG=GeometryCSG;
830
998
 
831
999
  /***/ }),
832
- /* 32 */
1000
+ /* 35 */
833
1001
  /***/ (function(module, exports, __webpack_require__) {
834
1002
 
835
1003
  "use strict";
@@ -838,35 +1006,35 @@ var i,_length_i,face,vertex,faceVertexUvs,uvs,polygon,polygons=[];if(geometry.is
838
1006
  var x=this.x,y=this.y,z=this.z,e=m.elements;return this.x=e[0]*x+e[4]*y+e[8]*z+e[12],this.y=e[1]*x+e[5]*y+e[9]*z+e[13],this.z=e[2]*x+e[6]*y+e[10]*z+e[14],this},ThreeBSP.Node=function(polygons){var i,polygon_count,front=[],back=[];if(this.polygons=[],this.front=this.back=void 0,polygons instanceof Array&&0!==polygons.length){for(this.divider=polygons[0].clone(),i=0,polygon_count=polygons.length;i<polygon_count;i++)this.divider.splitPolygon(polygons[i],this.polygons,this.polygons,front,back);0<front.length&&(this.front=new ThreeBSP.Node(front)),0<back.length&&(this.back=new ThreeBSP.Node(back))}},ThreeBSP.Node.isConvex=function(polygons){var i,j;for(i=0;i<polygons.length;i++)for(j=0;j<polygons.length;j++)if(i!==j&&polygons[i].classifySide(polygons[j])!==BACK)return!1;return!0},ThreeBSP.Node.prototype.build=function(polygons){var i,polygon_count,front=[],back=[];for(this.divider||(this.divider=polygons[0].clone()),i=0,polygon_count=polygons.length;i<polygon_count;i++)this.divider.splitPolygon(polygons[i],this.polygons,this.polygons,front,back);0<front.length&&(!this.front&&(this.front=new ThreeBSP.Node),this.front.build(front)),0<back.length&&(!this.back&&(this.back=new ThreeBSP.Node),this.back.build(back))},ThreeBSP.Node.prototype.allPolygons=function(){var polygons=this.polygons.slice();return this.front&&(polygons=polygons.concat(this.front.allPolygons())),this.back&&(polygons=polygons.concat(this.back.allPolygons())),polygons},ThreeBSP.Node.prototype.clone=function(){var node=new ThreeBSP.Node;return node.divider=this.divider.clone(),node.polygons=this.polygons.map(function(polygon){return polygon.clone()}),node.front=this.front&&this.front.clone(),node.back=this.back&&this.back.clone(),node},ThreeBSP.Node.prototype.invert=function(){var i,polygon_count,temp;for(i=0,polygon_count=this.polygons.length;i<polygon_count;i++)this.polygons[i].flip();return this.divider.flip(),this.front&&this.front.invert(),this.back&&this.back.invert(),temp=this.front,this.front=this.back,this.back=temp,this},ThreeBSP.Node.prototype.clipPolygons=function(polygons){var i,polygon_count,front,back;if(!this.divider)return polygons.slice();for(front=[],back=[],(i=0,polygon_count=polygons.length);i<polygon_count;i++)this.divider.splitPolygon(polygons[i],front,back,front,back);return this.front&&(front=this.front.clipPolygons(front)),back=this.back?this.back.clipPolygons(back):[],front.concat(back)},ThreeBSP.Node.prototype.clipTo=function(node){this.polygons=node.clipPolygons(this.polygons),this.front&&this.front.clipTo(node),this.back&&this.back.clipTo(node)},ThreeBSP};
839
1007
 
840
1008
  /***/ }),
841
- /* 33 */
1009
+ /* 36 */
842
1010
  /***/ (function(module, exports) {
843
1011
 
844
1012
  module.exports = require("webworkify-webpack");
845
1013
 
846
1014
  /***/ }),
847
- /* 34 */
1015
+ /* 37 */
848
1016
  /***/ (function(module, exports) {
849
1017
 
850
1018
  module.exports = require("promise-polyfill");
851
1019
 
852
1020
  /***/ }),
853
- /* 35 */
1021
+ /* 38 */
854
1022
  /***/ (function(module, exports, __webpack_require__) {
855
1023
 
856
- var Geometry=__webpack_require__(2).Geometry,THREE=__webpack_require__(3),JSONLoader=THREE.BufferGeometryLoader;module.exports=function(self){var core=void 0,geometryFromJSON=function(object){var JSONParser=new JSONLoader,geometry=JSONParser.parse(object),material=new THREE.MeshPhongMaterial,mesh=new THREE.Mesh(geometry.geometry,material),host=new Geometry;return host.morph=mesh,host},initialise=function(object){var host=geometryFromJSON(object);core=new(__webpack_require__(36).GeometryCSGInternal)(host),self.postMessage({action:"message",message:"Initialised"})},intersect=function(object){if(core){var guest=geometryFromJSON(object),result=core.intersect(guest),json=result.toBufferGeometry().toJSON();self.postMessage({action:"result",object:json})}},subtract=function(object){if(core){var guest=geometryFromJSON(object),result=core.subtract(guest),json=result.toBufferGeometry().toJSON();self.postMessage({action:"result",object:json})}},union=function(object){if(core){var guest=geometryFromJSON(object),result=core.union(guest),json=result.toBufferGeometry().toJSON();self.postMessage({action:"result",object:json})}};self.addEventListener("message",function(ev){switch(ev.data.action){case"initialise":initialise(ev.data.object);break;case"intersect":intersect(ev.data.object);break;case"subtract":subtract(ev.data.object);break;case"union":union(ev.data.object);break;default:throw"Cannot handle specified action.";}})};
1024
+ var Geometry=__webpack_require__(2).Geometry,THREE=__webpack_require__(3),JSONLoader=THREE.BufferGeometryLoader;module.exports=function(self){var core=void 0,geometryFromJSON=function(object){var JSONParser=new JSONLoader,geometry=JSONParser.parse(object),material=new THREE.MeshPhongMaterial,mesh=new THREE.Mesh(geometry.geometry,material),host=new Geometry;return host.morph=mesh,host},initialise=function(object){var host=geometryFromJSON(object);core=new(__webpack_require__(39).GeometryCSGInternal)(host),self.postMessage({action:"message",message:"Initialised"})},intersect=function(object){if(core){var guest=geometryFromJSON(object),result=core.intersect(guest),json=result.toBufferGeometry().toJSON();self.postMessage({action:"result",object:json})}},subtract=function(object){if(core){var guest=geometryFromJSON(object),result=core.subtract(guest),json=result.toBufferGeometry().toJSON();self.postMessage({action:"result",object:json})}},union=function(object){if(core){var guest=geometryFromJSON(object),result=core.union(guest),json=result.toBufferGeometry().toJSON();self.postMessage({action:"result",object:json})}};self.addEventListener("message",function(ev){switch(ev.data.action){case"initialise":initialise(ev.data.object);break;case"intersect":intersect(ev.data.object);break;case"subtract":subtract(ev.data.object);break;case"union":union(ev.data.object);break;default:throw"Cannot handle specified action.";}})};
857
1025
 
858
1026
  /***/ }),
859
- /* 36 */
1027
+ /* 39 */
860
1028
  /***/ (function(module, exports, __webpack_require__) {
861
1029
 
862
- var THREE=__webpack_require__(3),ThreeBSP=__webpack_require__(32)(THREE),Geometry=__webpack_require__(2).Geometry,GeometryCSG=__webpack_require__(31).GeometryCSG,GeometryCSGInternal=function(hostIn){//ZincGeoemtry of the main geometry
1030
+ var THREE=__webpack_require__(3),ThreeBSP=__webpack_require__(35)(THREE),Geometry=__webpack_require__(2).Geometry,GeometryCSG=__webpack_require__(34).GeometryCSG,GeometryCSGInternal=function(hostIn){//ZincGeoemtry of the main geometry
863
1031
  var host;hostIn&&hostIn.isGeometry&&(host=hostIn);var hostCSG;this.setGeometry=hostIn=>{hostIn&&hostIn.isGeometry&&(host=hostIn),hostCSG=void 0},this.setCSG=csg=>{hostCSG=csg};var prepareCSG=guestGeometry=>{if(host&&host.morph&&guestGeometry&&guestGeometry.morph){hostCSG===void 0&&(hostCSG=new ThreeBSP(host.morph));var guestCSG=new ThreeBSP(guestGeometry.morph);return guestCSG}};this.intersect=guestGeometry=>{var guestCSG=prepareCSG(guestGeometry);return hostCSG&&guestCSG?hostCSG.intersect(guestCSG):void 0},this.subtract=guestGeometry=>{var guestCSG=prepareCSG(guestGeometry);return hostCSG&&guestCSG?hostCSG.subtract(guestCSG):void 0},this.union=guestGeometry=>{var guestCSG=prepareCSG(guestGeometry);return hostCSG&&guestCSG?hostCSG.union(guestCSG):void 0}};exports.GeometryCSGInternal=GeometryCSGInternal;
864
1032
 
865
1033
  /***/ }),
866
- /* 37 */
1034
+ /* 40 */
867
1035
  /***/ (function(module, exports, __webpack_require__) {
868
1036
 
869
- var THREE=__webpack_require__(3),ThreeBSP=__webpack_require__(32)(THREE),Glyphset=__webpack_require__(13).Glyphset,GlyphsetCSG=function(hostIn){var host;hostIn&&hostIn.isGlyphset&&(host=hostIn);var hostCSGs=[];this.setGlyphset=hostIn=>{hostIn&&hostIn.isGlyphset&&(host=hostIn),hostCSG=void 0},this.getGlyphset=()=>host;var prepareCSGForGlyphs=()=>glyph=>{var mesh=glyph.getMesh(),label=glyph.getLabel();if(mesh){var csg=new ThreeBSP(mesh.geometry.clone().applyMatrix(mesh.matrix)),store=[];store.csg=csg,store.label=label,mesh.material&&(store.material=mesh.material.clone()),hostCSGs.push(store)}},prepareCSG=guestGeometry=>{if(host&&guestGeometry&&guestGeometry.morph){0==hostCSGs.length&&host.forEachGlyph(prepareCSGForGlyphs());var guestCSG=new ThreeBSP(guestGeometry.morph);return guestCSG}};this.intersect=guestGeometry=>{var guestCSG=prepareCSG(guestGeometry);if(0<hostCSGs.length&&guestCSG){for(var glyphset=new(__webpack_require__(13).Glyphset),i=0;i<hostCSGs.length;i++){var _hostCSG=hostCSGs[i],intersect=_hostCSG.csg.intersect(guestCSG),mesh=intersect.toMesh();if(mesh&&mesh.geometry&&0<mesh.geometry.vertices.length){_hostCSG.material&&(mesh.material=_hostCSG.material,mesh.material.side=THREE.DoubleSide,mesh.material.clippingPlanes=null);var glyph=glyphset.addMeshAsGlyph(mesh,i+1);glyph.setLabel(_hostCSG.label)}}var newCSG=new GlyphsetCSG(glyphset);return newCSG}}};exports.GlyphsetCSG=GlyphsetCSG;
1037
+ var THREE=__webpack_require__(3),ThreeBSP=__webpack_require__(35)(THREE),Glyphset=__webpack_require__(13).Glyphset,GlyphsetCSG=function(hostIn){var host;hostIn&&hostIn.isGlyphset&&(host=hostIn);var hostCSGs=[];this.setGlyphset=hostIn=>{hostIn&&hostIn.isGlyphset&&(host=hostIn),hostCSG=void 0},this.getGlyphset=()=>host;var prepareCSGForGlyphs=()=>glyph=>{var mesh=glyph.getMesh(),label=glyph.getLabel();if(mesh){var csg=new ThreeBSP(mesh.geometry.clone().applyMatrix(mesh.matrix)),store=[];store.csg=csg,store.label=label,mesh.material&&(store.material=mesh.material.clone()),hostCSGs.push(store)}},prepareCSG=guestGeometry=>{if(host&&guestGeometry&&guestGeometry.morph){0==hostCSGs.length&&host.forEachGlyph(prepareCSGForGlyphs());var guestCSG=new ThreeBSP(guestGeometry.morph);return guestCSG}};this.intersect=guestGeometry=>{var guestCSG=prepareCSG(guestGeometry);if(0<hostCSGs.length&&guestCSG){for(var glyphset=new(__webpack_require__(13).Glyphset),i=0;i<hostCSGs.length;i++){var _hostCSG=hostCSGs[i],intersect=_hostCSG.csg.intersect(guestCSG),mesh=intersect.toMesh();if(mesh&&mesh.geometry&&0<mesh.geometry.vertices.length){_hostCSG.material&&(mesh.material=_hostCSG.material,mesh.material.side=THREE.DoubleSide,mesh.material.clippingPlanes=null);var glyph=glyphset.addMeshAsGlyph(mesh,i+1);glyph.setLabel(_hostCSG.label)}}var newCSG=new GlyphsetCSG(glyphset);return newCSG}}};exports.GlyphsetCSG=GlyphsetCSG;
870
1038
 
871
1039
  /***/ })
872
1040
  /******/ ]);