zincjs 1.18.1 → 1.18.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/zinc.frontend.js +1 -1
- package/build/zinc.js +27 -23
- package/build/zinc.js.map +1 -1
- package/package.json +1 -1
- package/src/loaders/JSONLoader.js +16 -11
- package/src/loaders/primitivesLoader.js +7 -4
- package/src/scene.js +109 -86
package/build/zinc.js
CHANGED
|
@@ -32,7 +32,7 @@ module.exports = require("url-polyfill");
|
|
|
32
32
|
/***/ ((module) => {
|
|
33
33
|
|
|
34
34
|
"use strict";
|
|
35
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"zincjs","version":"1.18.
|
|
35
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"zincjs","version":"1.18.4","description":"ZincJS (Web-based-Zinc-Visualisation)","main":"build/zinc.js","directories":{"doc":"docs"},"files":["package.json","LICENSE","README.md","src/*","build/zinc.js","build/zinc.frontend.js","build/zinc.js.map","webpack.config.js"],"scripts":{"build-bundle":"webpack --config webpack.frontend.js; webpack --config webpack.backend.js","build-backend":"webpack --config webpack.backend.js","test":"npm --prefix ./test install && npm --prefix ./test run test-ci","changelog":"auto-changelog -p --output CHANGELOG.md --template keepachangelog","jsdoc":"jsdoc -c jsdoc_conf.json","version":"npm run build-bundle;npm run jsdoc;npm run changelog; git add CHANGELOG.md docs","release:beta":"npm version prerelease --preid=beta; npm publish --tag beta","release:minor":"npm version minor; npm publish","release:patch":"npm version patch; npm publish"},"repository":{"type":"git","url":"git+https://github.com/alan-wu/ZincJS.git"},"keywords":["library","webgl","3d","zincjs"],"author":"Alan Wu <alan.wu@auckland.ac.nz>","license":"MIT","bugs":{"url":"https://github.com/alan-wu/ZincJS/issues"},"homepage":"http://alan-wu.github.io/ZincJS/","devDependencies":{"@babel/core":"^7.23.9","@babel/preset-env":"^7.23.9","auto-changelog":"^2.4.0","babel-loader":"^9.1.3","babel-preset-minify":"^0.5.1","file-loader":"^6.2.0","jsdoc":"^4.0.2","raw-loader":"^4.0.2","webpack":"^5.90.3","webpack-cli":"^5.1.4","webpack-node-externals":"^3.0.0"},"dependencies":{"css-element-queries":"^1.2.2","lodash":"^4.17.19","promise-polyfill":"^8.1.3","three":"^0.130.1","three-spritetext":"1.6.2","url-loader":"^4.1.1","url-polyfill":"^1.1.7","webworkify-webpack":"^2.1.5"}}');
|
|
36
36
|
|
|
37
37
|
/***/ }),
|
|
38
38
|
/* 3 */
|
|
@@ -778,7 +778,7 @@ var THREE=__webpack_require__(4),Loader=(__webpack_require__(20).Loader),LoaderU
|
|
|
778
778
|
*/function JSONLoader(manager){"boolean"==typeof manager&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),manager=void 0),this.manager=manager===void 0?DefaultLoadingManager:manager,this.withCredentials=!1,this.paramsString=""}Object.assign(JSONLoader.prototype,{load:function load(url,onLoad,onProgress,onError){var scope=this,texturePath=this.texturePath&&"string"==typeof this.texturePath?this.texturePath:LoaderUtils.extractUrlBase(url),loader=new FileLoader(this.manager),params=url.split("?");//There are parameters, add them to the target
|
|
779
779
|
this.paramsString=2===url.length?paramsStrings[1]:"",loader.setWithCredentials(this.withCredentials),loader.load(url,function(text){var json;try{json=JSON.parse(text)}catch(e){if(console.error("The loader has encountered an error while parsing the content of a resource."),onError)return void onError({responseURL:url})}var metadata=json.metadata;if(metadata!==void 0){var type=metadata.type;if(type!==void 0&&"object"===type.toLowerCase())return void console.error("THREE.JSONLoader: "+url+" should be loaded with THREE.ObjectLoader instead.")}if(scope&&scope.parse)try{var object=scope.parse(json,texturePath);onLoad(object.geometry,object.materials)}catch(e){if(console.error("The loader has encountered aon loading the geometry"),console.error(e),onError)return void onError({responseURL:url})}},onProgress,onError)},setTexturePath:function setTexturePath(value){this.texturePath=value},parse:function(){function parseModel(json,geometry){function isBitSet(value,position){return value&1<<position}var i,j,fi,offset,zLength,colorIndex,normalIndex,uvIndex,materialIndex,type,isQuad,hasMaterial,hasFaceVertexUv,hasFaceNormal,hasFaceVertexNormal,hasFaceColor,hasFaceVertexColor,vertex,face,faceA,faceB,hex,normal,uvLayer,uv,u,v,faces=json.faces,vertices=json.vertices,normals=json.normals,colors=json.colors,scale=json.scale,nUvLayers=0;if(void 0!==json.uvs){// disregard empty arrays
|
|
780
780
|
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);
|
|
781
|
-
if(type=faces[offset++],isQuad=isBitSet(type,0),hasMaterial=isBitSet(type,1),hasFaceVertexUv=isBitSet(type,3),hasFaceNormal=isBitSet(type,4),hasFaceVertexNormal=isBitSet(type,5),hasFaceColor=isBitSet(type,6),hasFaceVertexColor=isBitSet(type,7),isQuad){if(faceA=new Face3,faceA.a=faces[offset],faceA.b=faces[offset+1],faceA.c=faces[offset+3],faceB=new Face3,faceB.a=faces[offset+1],faceB.b=faces[offset+2],faceB.c=faces[offset+3],offset+=4,hasMaterial&&(materialIndex=faces[offset++],faceA.materialIndex=materialIndex,faceB.materialIndex=materialIndex),fi=geometry.faces.length,hasFaceVertexUv)for(i=0;i<nUvLayers;i++)for(uvLayer=json.uvs[i],geometry.faceVertexUvs[i][fi]=[],geometry.faceVertexUvs[i][fi+1]=[],j=0;4>j;j++)uvIndex=faces[offset++],u=uvLayer[2*uvIndex],v=uvLayer[2*uvIndex+1],uv=new Vector2(u,v),2!==j&&geometry.faceVertexUvs[i][fi].push(uv),0!==j&&geometry.faceVertexUvs[i][fi+1].push(uv);if(hasFaceNormal&&(normalIndex=3*faces[offset++],faceA.normal.set(normals[normalIndex++],normals[normalIndex++],normals[normalIndex]),faceB.normal.copy(faceA.normal)),hasFaceVertexNormal)for(i=0;4>i;i++)normalIndex=3*faces[offset++],normal=new Vector3(normals[normalIndex++],normals[normalIndex++],normals[normalIndex]),2!==i&&faceA.vertexNormals.push(normal),0!==i&&faceB.vertexNormals.push(normal);if(hasFaceColor&&(colorIndex=faces[offset++],hex=colors[colorIndex],faceA.color.setHex(hex),faceB.color.setHex(hex)),hasFaceVertexColor)for(i=0;4>i;i++)colorIndex=faces[offset++],hex=colors[colorIndex],2!==i&&faceA.vertexColors.push(new Color(hex)),0!==i&&faceB.vertexColors.push(new Color(hex));geometry.faces.push(faceA),geometry.faces.push(faceB)}else{if(face=new Face3,face.a=faces[offset++],face.b=faces[offset++],face.c=faces[offset++],hasMaterial&&(materialIndex=faces[offset++],face.materialIndex=materialIndex),fi=geometry.faces.length,hasFaceVertexUv)for(i=0;i<nUvLayers;i++)for(uvLayer=json.uvs[i],geometry.faceVertexUvs[i][fi]=[],j=0;3>j;j++)uvIndex=faces[offset++],u=uvLayer[2*uvIndex],v=uvLayer[2*uvIndex+1],uv=new Vector2(u,v),geometry.faceVertexUvs[i][fi].push(uv);if(hasFaceNormal&&(normalIndex=3*faces[offset++],face.normal.set(normals[normalIndex++],normals[normalIndex++],normals[normalIndex])),hasFaceVertexNormal)for(i=0;3>i;i++)normalIndex=3*faces[offset++],normal=new Vector3(normals[normalIndex++],normals[normalIndex++],normals[normalIndex]),face.vertexNormals.push(normal);if(hasFaceColor&&(colorIndex=faces[offset++],face.color.setHex(colors[colorIndex])),hasFaceVertexColor)for(i=0;3>i;i++)colorIndex=faces[offset++],face.vertexColors.push(new Color(colors[colorIndex]));geometry.faces.push(face)}}function parseSkin(json,geometry){var influencesPerVertex=json.influencesPerVertex===void 0?2:json.influencesPerVertex;if(json.skinWeights)for(var i=0,l=json.skinWeights.length;i<l;i+=influencesPerVertex){var x=json.skinWeights[i],y=1<influencesPerVertex?json.skinWeights[i+1]:0,z=2<influencesPerVertex?json.skinWeights[i+2]:0,w=3<influencesPerVertex?json.skinWeights[i+3]:0;geometry.skinWeights.push(new Vector4(x,y,z,w))}if(json.skinIndices)for(var i=0,l=json.skinIndices.length;i<l;i+=influencesPerVertex){var a=json.skinIndices[i],b=1<influencesPerVertex?json.skinIndices[i+1]:0,c=2<influencesPerVertex?json.skinIndices[i+2]:0,d=3<influencesPerVertex?json.skinIndices[i+3]:0;geometry.skinIndices.push(new Vector4(a,b,c,d))}geometry.bones=json.bones,geometry.bones&&0<geometry.bones.length&&(geometry.skinWeights.length!==geometry.skinIndices.length||geometry.skinIndices.length!==geometry.vertices.length)&&console.warn("When skinning, number of vertices ("+geometry.vertices.length+"), skinIndices ("+geometry.skinIndices.length+"), and skinWeights ("+geometry.skinWeights.length+") should match.")}function parseMorphing(json,geometry){var scale=json.scale;if(json.morphTargets!==void 0)for(var i=0,l=json.morphTargets.length;i<l;i++){geometry.morphTargets[i]={},geometry.morphTargets[i].name=json.morphTargets[i].name,geometry.morphTargets[i].vertices=[];for(var vertex,dstVertices=geometry.morphTargets[i].vertices,srcVertices=json.morphTargets[i].vertices,v=0,vl=srcVertices.length;v<vl;v+=3)vertex=new Vector3,vertex.x=srcVertices[v]*scale,vertex.y=srcVertices[v+1]*scale,vertex.z=srcVertices[v+2]*scale,dstVertices.push(vertex)}if(void 0!==json.morphNormals)for(var i=0,l=json.morphNormals.length;i<l;i++)if(geometry.morphTargets[i]){geometry.morphTargets[i].normals=[];for(var normals,dstNormals=geometry.morphTargets[i].normals,srcNormals=json.morphNormals[i].normals,v=0,vl=srcNormals.length;v<vl;v+=3)normals=new Vector3,normals.x=srcNormals[v],normals.y=srcNormals[v+1],normals.z=srcNormals[v+2],dstNormals.push(normals);geometry.morphNormalsReady=!0}if(void 0!==json.morphColors){var i,l,c,cl,dstColors,srcColors,color;for(i=0,l=json.morphColors.length;i<l;i++)for(geometry.morphColors[i]={},geometry.morphColors[i].name=json.morphColors[i].name,geometry.morphColors[i].colors=[],dstColors=geometry.morphColors[i].colors,srcColors=json.morphColors[i].colors,(c=0,cl=srcColors.length);c<cl;c+=3)color=new THREE.Color(16755200),color.setRGB(srcColors[c],srcColors[c+1],srcColors[c+2]),dstColors.push(color)}}function parseAnimations(json,geometry){var outputAnimations=[],animations=[];// parse old style Bone/Hierarchy animations
|
|
781
|
+
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++],face.b||(face.b=face.a),face.c||(face.c=face.b),hasMaterial&&(materialIndex=faces[offset++],face.materialIndex=materialIndex),fi=geometry.faces.length,hasFaceVertexUv)for(i=0;i<nUvLayers;i++)for(uvLayer=json.uvs[i],geometry.faceVertexUvs[i][fi]=[],j=0;3>j;j++)uvIndex=faces[offset++],u=uvLayer[2*uvIndex],v=uvLayer[2*uvIndex+1],uv=new Vector2(u,v),geometry.faceVertexUvs[i][fi].push(uv);if(hasFaceNormal&&(normalIndex=3*faces[offset++],face.normal.set(normals[normalIndex++],normals[normalIndex++],normals[normalIndex])),hasFaceVertexNormal)for(i=0;3>i;i++)normalIndex=3*faces[offset++],normal=new Vector3(normals[normalIndex++],normals[normalIndex++],normals[normalIndex]),face.vertexNormals.push(normal);if(hasFaceColor&&(colorIndex=faces[offset++],face.color.setHex(colors[colorIndex])),hasFaceVertexColor)for(i=0;3>i;i++)colorIndex=faces[offset++],face.vertexColors.push(new Color(colors[colorIndex]));geometry.faces.push(face)}}function parseSkin(json,geometry){var influencesPerVertex=json.influencesPerVertex===void 0?2:json.influencesPerVertex;if(json.skinWeights)for(var i=0,l=json.skinWeights.length;i<l;i+=influencesPerVertex){var x=json.skinWeights[i],y=1<influencesPerVertex?json.skinWeights[i+1]:0,z=2<influencesPerVertex?json.skinWeights[i+2]:0,w=3<influencesPerVertex?json.skinWeights[i+3]:0;geometry.skinWeights.push(new Vector4(x,y,z,w))}if(json.skinIndices)for(var i=0,l=json.skinIndices.length;i<l;i+=influencesPerVertex){var a=json.skinIndices[i],b=1<influencesPerVertex?json.skinIndices[i+1]:0,c=2<influencesPerVertex?json.skinIndices[i+2]:0,d=3<influencesPerVertex?json.skinIndices[i+3]:0;geometry.skinIndices.push(new Vector4(a,b,c,d))}geometry.bones=json.bones,geometry.bones&&0<geometry.bones.length&&(geometry.skinWeights.length!==geometry.skinIndices.length||geometry.skinIndices.length!==geometry.vertices.length)&&console.warn("When skinning, number of vertices ("+geometry.vertices.length+"), skinIndices ("+geometry.skinIndices.length+"), and skinWeights ("+geometry.skinWeights.length+") should match.")}function parseMorphing(json,geometry){var scale=json.scale;if(json.morphTargets!==void 0)for(var i=0,l=json.morphTargets.length;i<l;i++){geometry.morphTargets[i]={},geometry.morphTargets[i].name=json.morphTargets[i].name,geometry.morphTargets[i].vertices=[];for(var vertex,dstVertices=geometry.morphTargets[i].vertices,srcVertices=json.morphTargets[i].vertices,v=0,vl=srcVertices.length;v<vl;v+=3)vertex=new Vector3,vertex.x=srcVertices[v]*scale,vertex.y=srcVertices[v+1]*scale,vertex.z=srcVertices[v+2]*scale,dstVertices.push(vertex)}if(void 0!==json.morphNormals)for(var i=0,l=json.morphNormals.length;i<l;i++)if(geometry.morphTargets[i]){geometry.morphTargets[i].normals=[];for(var normals,dstNormals=geometry.morphTargets[i].normals,srcNormals=json.morphNormals[i].normals,v=0,vl=srcNormals.length;v<vl;v+=3)normals=new Vector3,normals.x=srcNormals[v],normals.y=srcNormals[v+1],normals.z=srcNormals[v+2],dstNormals.push(normals);geometry.morphNormalsReady=!0}if(void 0!==json.morphColors){var i,l,c,cl,dstColors,srcColors,color;for(i=0,l=json.morphColors.length;i<l;i++)for(geometry.morphColors[i]={},geometry.morphColors[i].name=json.morphColors[i].name,geometry.morphColors[i].colors=[],dstColors=geometry.morphColors[i].colors,srcColors=json.morphColors[i].colors,(c=0,cl=srcColors.length);c<cl;c+=3)color=new THREE.Color(16755200),color.setRGB(srcColors[c],srcColors[c+1],srcColors[c+2]),dstColors.push(color)}}function parseAnimations(json,geometry){var outputAnimations=[],animations=[];// parse old style Bone/Hierarchy animations
|
|
782
782
|
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
|
|
783
783
|
if(geometry.morphTargets){// TODO: Figure out what an appropraite FPS is for morph target animations -- defaulting to 10, but really it is completely arbitrary.
|
|
784
784
|
var morphAnimationClips=AnimationClip.CreateClipsFromMorphTargetSequences(geometry.morphTargets,10);outputAnimations=outputAnimations.concat(morphAnimationClips)}0<outputAnimations.length&&(geometry.animations=outputAnimations)}return function(json,texturePath){void 0!==json.data&&(json=json.data),json.scale=void 0===json.scale?1:1/json.scale;var geometry=new Geometry;if(geometry.morphColors=[],parseModel(json,geometry),parseSkin(json,geometry),parseMorphing(json,geometry),parseAnimations(json,geometry),geometry.computeFaceNormals(),geometry.computeBoundingSphere(),void 0===json.materials||0===json.materials.length)return{geometry:geometry};var materials=Loader.prototype.initMaterials(json.materials,texturePath,"Anonymous");if(json.materials[0].video){var fullPath=texturePath+json.materials[0].video;this.paramsString&&(fullPath+="?".concat(this.paramsString));var videoHandler=new VideoHandler(fullPath);geometry._video=videoHandler}return materials&&0<materials.length&&(materials[0].side=json.materials[0].singleSided?THREE.FrontSide:json.materials[0].flipSided?THREE.BackSide:THREE.DoubleSide,json.materials[0].specularCoef&&(materials[0].shininess=Math.floor(json.materials[0].specularCoef/3))),{geometry:geometry,materials:materials}}}()});
|
|
@@ -1177,62 +1177,62 @@ module.exports = require("css-element-queries/src/ResizeSensor");
|
|
|
1177
1177
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1178
1178
|
|
|
1179
1179
|
var THREE=__webpack_require__(4),MarkerCluster=(__webpack_require__(33).MarkerCluster),SceneLoader=(__webpack_require__(35).SceneLoader),SceneExporter=(__webpack_require__(42).SceneExporter),Viewport=(__webpack_require__(44).Viewport),createBufferGeometry=(__webpack_require__(5).createBufferGeometry),getCircularTexture=(__webpack_require__(5).getCircularTexture),createNewSpriteText=(__webpack_require__(5).createNewSpriteText),uniqueiId=0,getUniqueId=function(){return"sc"+uniqueiId++},defaultMetadata=function(){return{Duration:"6 secs",OriginalDuration:"-",TimeStamps:{}}},defaultDuration=6e3;/**
|
|
1180
|
-
* A Scene contains {@link Region},and
|
|
1180
|
+
* A Scene contains {@link Region},and
|
|
1181
1181
|
* {@link CameraControls} which controls the viewport and additional features.
|
|
1182
1182
|
* It is the main object used for controlling what is and what is not displayed
|
|
1183
1183
|
* on the renderer.
|
|
1184
|
-
*
|
|
1184
|
+
*
|
|
1185
1185
|
* @class
|
|
1186
1186
|
* @param {Object} containerIn - Container to create the renderer on.
|
|
1187
1187
|
* @author Alan Wu
|
|
1188
1188
|
* @return {Scene}
|
|
1189
|
-
*/exports.Scene=function(containerIn,rendererIn){var _this=this,container=containerIn,videoHandler=void 0,sceneLoader=new SceneLoader(this),minimap=void 0,zincObjectAddedCallbacks={},zincObjectAddedCallbacks_id=0,zincObjectRemovedCallbacks={},zincObjectRemovedCallbacks_id=0,scene=new THREE.Scene,miniAxesScene=new THREE.Scene,rootRegion=new((__webpack_require__(45).Region))(void 0,this);scene.add(rootRegion.getGroup());var tempGroup=new THREE.Group;scene.add(tempGroup),this.directionalLight=void 0,this.ambient=void 0,this.camera=void 0;var duration=6e3,zincCameraControls=void 0;this.sceneName=void 0;var stereoEffectFlag=!1,stereoEffect=void 0;this.autoClearFlag=!0,this.displayMarkers=!1,this.displayMinimap=!1,this.displayMiniAxes=!1,this.minimapScissor={x_offset:16,y_offset:16,width:128,height:128,align:"top-right",updateRequired:!0};var scissor={x:0,y:0},metadata=defaultMetadata(),_markerTarget=new THREE.Vector2,pickableObjectsList=[];this.forcePickableObjectsUpdate=!1,this.uuid=getUniqueId();var markerCluster=new MarkerCluster(this);markerCluster.disable(),scene.add(markerCluster.group);var axisDisplay={main:[],mini:[]},_v3=new THREE.Vector3(0,0,0),getDrawingWidth=()=>container?"undefined"==typeof container.clientWidth?container.width:container.clientWidth:0,getDrawingHeight=()=>container?"undefined"==typeof container.clientHeight?container.height:container.clientHeight:0;/**
|
|
1189
|
+
*/exports.Scene=function(containerIn,rendererIn){var _this=this,container=containerIn,cameraHelper=void 0,videoHandler=void 0,sceneLoader=new SceneLoader(this),minimap=void 0,zincObjectAddedCallbacks={},zincObjectAddedCallbacks_id=0,zincObjectRemovedCallbacks={},zincObjectRemovedCallbacks_id=0,scene=new THREE.Scene,miniAxesScene=new THREE.Scene,rootRegion=new((__webpack_require__(45).Region))(void 0,this);scene.add(rootRegion.getGroup());var tempGroup=new THREE.Group;scene.add(tempGroup),this.directionalLight=void 0,this.ambient=void 0,this.camera=void 0;var duration=6e3,zincCameraControls=void 0;this.sceneName=void 0;var stereoEffectFlag=!1,stereoEffect=void 0;this.autoClearFlag=!0,this.displayMarkers=!1,this.displayMinimap=!1,this.displayMiniAxes=!1,this.minimapScissor={x_offset:16,y_offset:16,width:128,height:128,align:"top-right",updateRequired:!0};var scissor={x:0,y:0},metadata=defaultMetadata(),_markerTarget=new THREE.Vector2,pickableObjectsList=[];this.forcePickableObjectsUpdate=!1,this.uuid=getUniqueId();var markerCluster=new MarkerCluster(this);markerCluster.disable(),scene.add(markerCluster.group);var axisDisplay={main:[],mini:[]},_v3=new THREE.Vector3(0,0,0),getDrawingWidth=()=>container?"undefined"==typeof container.clientWidth?container.width:container.clientWidth:0,getDrawingHeight=()=>container?"undefined"==typeof container.clientHeight?container.height:container.clientHeight:0;/**
|
|
1190
1190
|
* This function returns a three component array, which contains
|
|
1191
1191
|
* [totalsize, totalLoaded and errorDownload] of all the downloads happening
|
|
1192
1192
|
* in this scene.
|
|
1193
|
-
* @returns {Array}
|
|
1193
|
+
* @returns {Array}
|
|
1194
1194
|
*/this.getDownloadProgress=()=>sceneLoader.getDownloadProgress(),this.onWindowResize=()=>{var wHeight=getDrawingHeight();this.camera.aspect=getDrawingWidth()/wHeight,this.camera.updateProjectionMatrix(),this.minimapScissor.updateRequired=!0,zincCameraControls.onResize(),zincCameraControls.calculateHeightPerPixelAtZeroDepth(wHeight)},this.resetView=()=>{this.onWindowResize(),zincCameraControls.resetView()},this.changeZoomByScrollRateUnit=unit=>{zincCameraControls.changeZoomByScrollRateUnit(unit)};//Setup the camera for this scene, it also initialise the lighting
|
|
1195
1195
|
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__(44).CameraControls))(this.camera,rendererIn.domElement,rendererIn,this),zincCameraControls.setDirectionalLight(this.directionalLight),zincCameraControls.resetView(),minimap=new((__webpack_require__(50).Minimap))(this)};setupCamera(),this.loadView=settings=>{var viewPort=new Viewport;return viewPort.setFromObject(settings),zincCameraControls.setCurrentCameraSettings(viewPort),!0},this.setupMultipleViews=(defaultView,entries)=>{for(var[name,settings]of Object.entries(entries)){var viewport=new Viewport;viewport.setFromObject(settings),zincCameraControls.addViewport(name,viewport)}zincCameraControls.setDefaultViewport(defaultView)},this.getBoundingBox=()=>rootRegion.getBoundingBox(!0),this.viewAllWithBoundingBox=boundingBox=>{if(boundingBox){var viewport=zincCameraControls.getViewportFromBoundingBox(boundingBox,1);zincCameraControls.setCurrentCameraSettings(viewport),zincCameraControls.calculateHeightPerPixelAtZeroDepth(getDrawingHeight()),markerCluster.markerUpdateRequired=!0}},this.viewAll=()=>{var boundingBox=this.getBoundingBox();this.viewAllWithBoundingBox(boundingBox),markerCluster.markerUpdateRequired=!0},this.forEachGeometry=callbackFunction=>{rootRegion.forEachGeometry(callbackFunction,!0)},this.forEachGlyphset=callbackFunction=>{rootRegion.forEachGlyphset(callbackFunction,!0)},this.forEachPointset=callbackFunction=>{rootRegion.forEachPointset(callbackFunction,!0)},this.forEachLine=callbackFunction=>{rootRegion.forEachLine(callbackFunction,!0)},this.findGeometriesWithGroupName=GroupName=>rootRegion.findGeometriesWithGroupName(GroupName,!0),this.findPointsetsWithGroupName=GroupName=>rootRegion.findPointsetsWithGroupName(GroupName,!0),this.findGlyphsetsWithGroupName=GroupName=>rootRegion.findGlyphsetsWithGroupName(GroupName,!0),this.findLinesWithGroupName=GroupName=>rootRegion.findLinesWithGroupName(GroupName,!0),this.findObjectsWithGroupName=GroupName=>rootRegion.findObjectsWithGroupName(GroupName,!0),this.findObjectsWithAnatomicalId=anatomicalId=>rootRegion.findObjectsWithAnatomicalId(anatomicalId,!0),this.getBoundingBoxOfZincObjects=objectsArray=>{for(var box,boundingBox=void 0,i=0;i<objectsArray.length;i++)box=objectsArray[i].getBoundingBox(),box&&(boundingBox?boundingBox.union(box):boundingBox=box);return boundingBox},this.vectorToScreenXY=point=>{point.project(this.camera);var width=getDrawingWidth(),height=getDrawingHeight(),widthHalf=width/2,heightHalf=height/2;return point.x=point.x*widthHalf+widthHalf,point.y=-(point.y*heightHalf)+heightHalf,point},this.getObjectsScreenXY=zincObjects=>{if(zincObjects&&0<zincObjects.length){var boundingBox=this.getBoundingBoxOfZincObjects(zincObjects),center=new THREE.Vector3;return boundingBox.getCenter(center),this.vectorToScreenXY(center)}},this.getNamedObjectsScreenXY=name=>{var zincObjects=this.findObjectsWithGroupName(name);return this.getObjectsScreenXY(zincObjects)},this.addZincObject=zincObject=>{zincObject&&(rootRegion.addZincObject(zincObject),zincCameraControls&&zincCameraControls.calculateMaxAllowedDistance(this))},this.loadGlyphsetURL=(metaurl,glyphurl,groupName,finishCallback)=>{sceneLoader.loadGlyphsetURL(rootRegion,metaurl,glyphurl,groupName,finishCallback)},this.loadPointsetURL=(url,timeEnabled,morphColour,groupName,finishCallback)=>{sceneLoader.loadPointsetURL(rootRegion,url,timeEnabled,morphColour,groupName,finishCallback)},this.loadLinesURL=(url,timeEnabled,morphColour,groupName,finishCallback)=>{sceneLoader.loadLinesURL(rootRegion,url,timeEnabled,morphColour,groupName,finishCallback)},this.loadSTL=(url,groupName,finishCallback)=>{sceneLoader.loadSTL(rootRegion,url,groupName,finishCallback)},this.loadOBJ=(url,groupName,finishCallback)=>{sceneLoader.loadOBJ(rootRegion,url,groupName,finishCallback)},this.loadMetadataURL=(url,finishCallback,allCompletedCallback,options)=>{sceneLoader.loadMetadataURL(rootRegion,url,finishCallback,allCompletedCallback,options)},this.loadModelsURL=(urls,colours,opacities,timeEnabled,morphColour,finishCallback)=>{sceneLoader.loadModelsURL(rootRegion.urls,colours,opacities,timeEnabled,morphColour,finishCallback)},this.loadViewURL=url=>{sceneLoader.loadViewURL(url)},this.loadFromViewURL=(jsonFilePrefix,finishCallback)=>{sceneLoader.loadFromViewURL(jsonFilePrefix,finishCallback)},this.loadGLTF=(url,finishCallback,allCompletedCallback,options)=>{sceneLoader.loadGLTF(rootRegion,url,finishCallback,allCompletedCallback,options)},this.updateDirectionalLight=()=>{zincCameraControls.updateDirectionalLight()},this.addObject=object=>{scene.add(object)},this.removeObject=object=>{scene.remove(object)},this.getCurrentTime=()=>{if(videoHandler!=null)return videoHandler.getCurrentTime(duration);var time=rootRegion.getCurrentTime();return-1===time?0:time},this.setMorphsTime=time=>{videoHandler!=null&&videoHandler.setMorphTime(time,duration),rootRegion.setMorphTime(time,!0)},this.isTimeVarying=()=>!!(videoHandler&&videoHandler.video&&!videoHandler.video.error)||rootRegion.isTimeVarying(),this.renderGeometries=(playRate,delta,playAnimation)=>{// Let video dictates the progress if one is present
|
|
1196
1196
|
var options={};if(options.camera=zincCameraControls,options.displayMarkers=this.displayMarkers,options.markerCluster=markerCluster,options.markersList=markerCluster.markers,options.ndcToBeUpdated=!1,playAnimation&&(options.markerCluster.markerUpdateRequired=!0),!videoHandler)0==sceneLoader.toBeDownloaded?(options.ndcToBeUpdated=zincCameraControls.update(delta),options.ndcToBeUpdated&&zincCameraControls.calculateHeightPerPixelAtZeroDepth(getDrawingHeight()),rootRegion.renderGeometries(playRate,delta,playAnimation,zincCameraControls,options,!0)):zincCameraControls.update(0);else if(videoHandler.isReadyToPlay()){playAnimation?videoHandler.video.play():videoHandler.video.pause();var currentTime=videoHandler.video.currentTime/videoHandler.getVideoDuration()*duration;0==sceneLoader.toBeDownloaded?(zincCameraControls.setTime(currentTime),options.ndcToBeUpdated=zincCameraControls.update(0),options.ndcToBeUpdated&&zincCameraControls.calculateHeightPerPixelAtZeroDepth(getDrawingHeight()),rootRegion.setMorphTime(currentTime,!0),rootRegion.renderGeometries(0,0,playAnimation,zincCameraControls,options,!0)):zincCameraControls.update(0)}else myPlayRate=0},this.getThreeJSScene=()=>scene,this.setVideoHandler=videoHandlerIn=>{videoHandler||(videoHandler=videoHandlerIn)},this.setAdditionalScenesGroup=scenesGroup=>{scene.add(scenesGroup)};var getWindowsPosition=(align,x_offset,y_offset,width,height,renderer_width,renderer_height)=>{var x=0,y=0;return y=align.includes("top")?renderer_height-height-y_offset:align.includes("bottom")?y_offset:Math.floor((renderer_height-height)/2),x=align.includes("left")?x_offset:align.includes("right")?renderer_width-x_offset-width:Math.floor((renderer_width-width)/2),{x:x,y:y}},renderMinimap=renderer=>{(this.displayMinimap||this.displayMiniAxes)&&(renderer.setScissorTest(!0),renderer.getSize(_markerTarget),this.minimapScissor.updateRequired&&(scissor=getWindowsPosition(this.minimapScissor.align,this.minimapScissor.x_offset,this.minimapScissor.y_offset,this.minimapScissor.width,this.minimapScissor.height,_markerTarget.x,_markerTarget.y),this.minimapScissor.updateRequired=!1),renderer.setScissor(scissor.x,scissor.y,this.minimapScissor.width,this.minimapScissor.height),renderer.setViewport(scissor.x,scissor.y,this.minimapScissor.width,this.minimapScissor.height),minimap.updateCamera(),this.displayMiniAxes?renderer.render(miniAxesScene,minimap.camera):(scene.add(minimap.mask),renderer.render(scene,minimap.camera),scene.remove(minimap.mask)),renderer.setScissorTest(!1),renderer.setViewport(0,0,_markerTarget.x,_markerTarget.y))};/**
|
|
1197
1197
|
* Render the scene.
|
|
1198
1198
|
* @private
|
|
1199
|
-
*/this.render=renderer=>{this.autoClearFlag&&renderer.clear(),stereoEffectFlag&&stereoEffect?stereoEffect.render(scene,this.camera):(renderer.render(scene,this.camera),renderMinimap(renderer))},this.setInteractiveControlEnable=flag=>{!0==flag?zincCameraControls.enable():zincCameraControls.disable()},this.getZincCameraControls=()=>zincCameraControls,this.getThreeJSScene=()=>scene,this.setDuration=durationIn=>{rootRegion.setDuration(durationIn),duration=durationIn,zincCameraControls.setPathDuration(durationIn),sceneLoader.duration=durationIn},this.getDuration=()=>duration,this.setStereoEffectEnable=stereoFlag=>{!0!=stereoFlag||stereoEffect||(stereoEffect=new __webpack_require__(44).StereoEffect(rendererIn)),rendererIn.setSize(getDrawingWidth(),getDrawingHeight()),this.camera.updateProjectionMatrix(),stereoEffectFlag=stereoFlag},this.objectIsInScene=zincObject=>rootRegion.objectIsInRegion(zincObject,!0),this.alignBoundingBoxToCameraView=(boundingBox,transitionTime)=>{if(boundingBox){boundingBox.getCenter(_v3);var viewport=this.getZincCameraControls().getCurrentViewport(),target=new THREE.Vector3(viewport.targetPosition[0],viewport.targetPosition[1],viewport.targetPosition[2]),eyePosition=new THREE.Vector3(viewport.eyePosition[0],viewport.eyePosition[1],viewport.eyePosition[2]),newVec1=new THREE.Vector3,newVec2=new THREE.Vector3;newVec1.subVectors(target,eyePosition).normalize(),newVec2.subVectors(target,_v3).normalize();var newVec3=new THREE.Vector3;newVec3.crossVectors(newVec1,newVec2);var angle=newVec1.angleTo(newVec2);0<transitionTime?(this.getZincCameraControls().rotateCameraTransition(newVec3,angle,transitionTime),this.getZincCameraControls().enableCameraTransition()):this.getZincCameraControls().rotateAboutLookAtpoint(newVec3,angle),markerCluster.markerUpdateRequired=!0}},this.translateBoundingBoxToCameraView=(boundingBox,scaleRadius,transitionTime)=>{if(boundingBox){var oldViewport=this.getZincCameraControls().getCurrentViewport(),viewport=this.getZincCameraControls().getViewportFromBoundingBox(boundingBox,scaleRadius);0<transitionTime&&(this.getZincCameraControls().cameraTransition(oldViewport,viewport,transitionTime),this.getZincCameraControls().enableCameraTransition()),markerCluster.markerUpdateRequired=!0}},this.alignObjectToCameraView=(zincObject,transitionTime)=>{if(this.objectIsInScene(zincObject)){var boundingBox=zincObject.getBoundingBox();this.alignBoundingBoxToCameraView(boundingBox,transitionTime)}},this.setCameraTargetToObject=zincObject=>{if(this.objectIsInScene(zincObject)){var boundingBox=zincObject.getBoundingBox(),viewport=this.getZincCameraControls().getCurrentViewport();boundingBox.getCenter(_v3);var target=new THREE.Vector3(viewport.targetPosition[0],viewport.targetPosition[1],viewport.targetPosition[2]),eyePosition=new THREE.Vector3(viewport.eyePosition[0],viewport.eyePosition[1],viewport.eyePosition[2]),newVec1=new THREE.Vector3,newVec2=new THREE.Vector3;newVec1.subVectors(eyePosition,target),newVec2.addVectors(_v3,newVec1),viewport.eyePosition[0]=newVec2.x,viewport.eyePosition[1]=newVec2.y,viewport.eyePosition[2]=newVec2.z,viewport.targetPosition[0]=_v3.x,viewport.targetPosition[1]=_v3.y,viewport.targetPosition[2]=_v3.z,this.getZincCameraControls().setCurrentCameraSettings(viewport),markerCluster.markerUpdateRequired=!0}},this.isStereoEffectEnable=()=>stereoEffectFlag,this.removeZincObject=zincObject=>{rootRegion.removeZincObject(zincObject),zincCameraControls&&zincCameraControls.calculateMaxAllowedDistance(this),markerCluster.markerUpdateRequired=!0},this.updatePickableThreeJSObjects=()=>{pickableObjectsList.length=0,markerCluster.isEnabled&&pickableObjectsList.push(markerCluster.group),rootRegion.getPickableThreeJSObjects(pickableObjectsList,!0),this.forcePickableObjectsUpdate=!1},this.getPickableThreeJSObjects=()=>((this.forcePickableObjectsUpdate||rootRegion.checkPickableUpdateRequred(!0))&&this.updatePickableThreeJSObjects(),pickableObjectsList),this.getNormalisedMinimapCoordinates=(renderer,event)=>{if(this.displayMinimap){var target=new THREE.Vector2;renderer.getSize(target);var offsetY=target.y-event.clientY;if(scissor.x+this.minimapScissor.width>event.clientX&&event.clientX>scissor.x&&scissor.y+this.minimapScissor.height>offsetY&&offsetY>scissor.y){var x=2*((event.clientX-scissor.x)/this.minimapScissor.width)-1,y=2*((offsetY-scissor.y)/this.minimapScissor.height)-1;return{x:x,y:y}}}},this.getMinimapDiffFromNormalised=(x,y)=>minimap?minimap.getDiffFromNormalised(x,y):void 0,this.isWebGL2=()=>rendererIn.isWebGL2(),this.clearAll=()=>{markerCluster.clear(),rootRegion.clear(!0),this.clearZincObjectAddedCallbacks(),this.clearZincObjectRemovedCallbacks(),sceneLoader.toBeDwonloaded=0,zincCameraControls&&zincCameraControls.calculateMaxAllowedDistance(this),markerCluster.markerUpdateRequired=!0},this.addMetadataTimeStamp=(key,time)=>{metadata.TimeStamps[key]=convertDurationObjectTomSec(time)},this.getMetadataTag=key=>metadata[key],this.getMetadata=()=>metadata,this.setMetadataTag=(key,value)=>{metadata[key]=value},this.removeMetadataTag=key=>{delete metadata[key]},this.resetMetadata=()=>{metadata=defaultMetadata()},this.resetDuration=()=>{this.setDuration(defaultDuration)};// Turn the object into a readable string {years: years,months: months,
|
|
1200
|
-
// weeks: weeks, days: days, hours: hours, mins: mins, secs: secs }
|
|
1201
|
-
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,
|
|
1202
|
-
// weeks: weeks, days: days, hours: hours, mins: mins, secs: secs }
|
|
1199
|
+
*/this.render=renderer=>{this.autoClearFlag&&renderer.clear(),stereoEffectFlag&&stereoEffect?stereoEffect.render(scene,this.camera):(renderer.render(scene,this.camera),renderMinimap(renderer))},this.setInteractiveControlEnable=flag=>{!0==flag?zincCameraControls.enable():zincCameraControls.disable()},this.getZincCameraControls=()=>zincCameraControls,this.getThreeJSScene=()=>scene,this.setDuration=durationIn=>{rootRegion.setDuration(durationIn),duration=durationIn,zincCameraControls.setPathDuration(durationIn),sceneLoader.duration=durationIn},this.getDuration=()=>duration,this.setStereoEffectEnable=stereoFlag=>{!0!=stereoFlag||stereoEffect||(stereoEffect=new __webpack_require__(44).StereoEffect(rendererIn)),rendererIn.setSize(getDrawingWidth(),getDrawingHeight()),this.camera.updateProjectionMatrix(),stereoEffectFlag=stereoFlag},this.objectIsInScene=zincObject=>rootRegion.objectIsInRegion(zincObject,!0),this.alignBoundingBoxToCameraView=(boundingBox,transitionTime)=>{if(boundingBox){boundingBox.getCenter(_v3);var viewport=this.getZincCameraControls().getCurrentViewport(),target=new THREE.Vector3(viewport.targetPosition[0],viewport.targetPosition[1],viewport.targetPosition[2]),eyePosition=new THREE.Vector3(viewport.eyePosition[0],viewport.eyePosition[1],viewport.eyePosition[2]),newVec1=new THREE.Vector3,newVec2=new THREE.Vector3;newVec1.subVectors(target,eyePosition).normalize(),newVec2.subVectors(target,_v3).normalize();var newVec3=new THREE.Vector3;newVec3.crossVectors(newVec1,newVec2);var angle=newVec1.angleTo(newVec2);0<transitionTime?(this.getZincCameraControls().rotateCameraTransition(newVec3,angle,transitionTime),this.getZincCameraControls().enableCameraTransition()):this.getZincCameraControls().rotateAboutLookAtpoint(newVec3,angle),markerCluster.markerUpdateRequired=!0}},this.translateBoundingBoxToCameraView=(boundingBox,scaleRadius,transitionTime)=>{if(boundingBox){var oldViewport=this.getZincCameraControls().getCurrentViewport(),viewport=this.getZincCameraControls().getViewportFromBoundingBox(boundingBox,scaleRadius);0<transitionTime&&(this.getZincCameraControls().cameraTransition(oldViewport,viewport,transitionTime),this.getZincCameraControls().enableCameraTransition()),markerCluster.markerUpdateRequired=!0}},this.alignObjectToCameraView=(zincObject,transitionTime)=>{if(this.objectIsInScene(zincObject)){var boundingBox=zincObject.getBoundingBox();this.alignBoundingBoxToCameraView(boundingBox,transitionTime)}},this.setCameraTargetToObject=zincObject=>{if(this.objectIsInScene(zincObject)){var boundingBox=zincObject.getBoundingBox(),viewport=this.getZincCameraControls().getCurrentViewport();boundingBox.getCenter(_v3);var target=new THREE.Vector3(viewport.targetPosition[0],viewport.targetPosition[1],viewport.targetPosition[2]),eyePosition=new THREE.Vector3(viewport.eyePosition[0],viewport.eyePosition[1],viewport.eyePosition[2]),newVec1=new THREE.Vector3,newVec2=new THREE.Vector3;newVec1.subVectors(eyePosition,target),newVec2.addVectors(_v3,newVec1),viewport.eyePosition[0]=newVec2.x,viewport.eyePosition[1]=newVec2.y,viewport.eyePosition[2]=newVec2.z,viewport.targetPosition[0]=_v3.x,viewport.targetPosition[1]=_v3.y,viewport.targetPosition[2]=_v3.z,this.getZincCameraControls().setCurrentCameraSettings(viewport),markerCluster.markerUpdateRequired=!0}},this.isStereoEffectEnable=()=>stereoEffectFlag,this.removeZincObject=zincObject=>{rootRegion.removeZincObject(zincObject),zincCameraControls&&zincCameraControls.calculateMaxAllowedDistance(this),markerCluster.markerUpdateRequired=!0},this.updatePickableThreeJSObjects=()=>{pickableObjectsList.length=0,markerCluster.isEnabled&&pickableObjectsList.push(markerCluster.group),rootRegion.getPickableThreeJSObjects(pickableObjectsList,!0),this.forcePickableObjectsUpdate=!1},this.getPickableThreeJSObjects=()=>((this.forcePickableObjectsUpdate||rootRegion.checkPickableUpdateRequred(!0))&&this.updatePickableThreeJSObjects(),pickableObjectsList),this.getNormalisedMinimapCoordinates=(renderer,event)=>{if(this.displayMinimap){var target=new THREE.Vector2;renderer.getSize(target);var offsetY=target.y-event.clientY;if(scissor.x+this.minimapScissor.width>event.clientX&&event.clientX>scissor.x&&scissor.y+this.minimapScissor.height>offsetY&&offsetY>scissor.y){var x=2*((event.clientX-scissor.x)/this.minimapScissor.width)-1,y=2*((offsetY-scissor.y)/this.minimapScissor.height)-1;return{x:x,y:y}}}},this.getMinimapDiffFromNormalised=(x,y)=>minimap?minimap.getDiffFromNormalised(x,y):void 0,this.isWebGL2=()=>rendererIn.isWebGL2(),this.clearAll=()=>{markerCluster.clear(),rootRegion.clear(!0),this.clearZincObjectAddedCallbacks(),this.clearZincObjectRemovedCallbacks(),sceneLoader.toBeDwonloaded=0,zincCameraControls&&zincCameraControls.calculateMaxAllowedDistance(this),markerCluster.markerUpdateRequired=!0},this.addMetadataTimeStamp=(key,time)=>{metadata.TimeStamps[key]=convertDurationObjectTomSec(time)},this.getMetadataTag=key=>metadata[key],this.getMetadata=()=>metadata,this.setMetadataTag=(key,value)=>{metadata[key]=value},this.removeMetadataTag=key=>{delete metadata[key]},this.resetMetadata=()=>{metadata=defaultMetadata()},this.resetDuration=()=>{this.setDuration(defaultDuration)};// Turn the object into a readable string {years: years,months: months,
|
|
1200
|
+
// weeks: weeks, days: days, hours: hours, mins: mins, secs: secs }
|
|
1201
|
+
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,
|
|
1202
|
+
// weeks: weeks, days: days, hours: hours, mins: mins, secs: secs }
|
|
1203
1203
|
// Set the readable duration and timer using an object
|
|
1204
1204
|
// with the following format {years: years,months: months, weeks: weeks, days: days,
|
|
1205
|
-
// hours: hours, mins: mins, secs: secs }
|
|
1205
|
+
// hours: hours, mins: mins, secs: secs }
|
|
1206
1206
|
// Set the readable original duration using an object
|
|
1207
1207
|
// with the following format {years: years,months: months, weeks: weeks, days: days,
|
|
1208
|
-
// hours: hours, mins: mins, secs: secs }
|
|
1208
|
+
// hours: hours, mins: mins, secs: secs }
|
|
1209
1209
|
/**
|
|
1210
1210
|
* Export the scene in GLTF format, it can either return it in
|
|
1211
1211
|
* string or binary form.
|
|
1212
|
-
*
|
|
1212
|
+
*
|
|
1213
1213
|
* @param {Boolean} binary - Indicate it should be exported as binary or
|
|
1214
1214
|
* text.
|
|
1215
|
-
*
|
|
1215
|
+
*
|
|
1216
1216
|
* @return {Promise} The exported data if the promise resolve successfully
|
|
1217
1217
|
*/ /**
|
|
1218
1218
|
* Get the root region of the scene.
|
|
1219
|
-
*
|
|
1219
|
+
*
|
|
1220
1220
|
* @return {Region} Return the root region of the scene
|
|
1221
1221
|
*/ /**
|
|
1222
|
-
* Create points in region specified in the path
|
|
1222
|
+
* Create points in region specified in the path
|
|
1223
1223
|
*
|
|
1224
1224
|
*/ /**
|
|
1225
|
-
* Create points in region specified in the path
|
|
1225
|
+
* Create points in region specified in the path
|
|
1226
1226
|
*
|
|
1227
1227
|
*/ /**
|
|
1228
1228
|
* Add a callback function which will be called everytime zinc object is added.
|
|
1229
1229
|
* @param {Function} callbackFunction - callbackFunction to be added.
|
|
1230
|
-
*
|
|
1230
|
+
*
|
|
1231
1231
|
* @return {Number}
|
|
1232
1232
|
*/ /**
|
|
1233
1233
|
* Add a callback function which will be called everytime zinc object is removed.
|
|
1234
1234
|
* @param {Function} callbackFunction - callbackFunction to be added.
|
|
1235
|
-
*
|
|
1235
|
+
*
|
|
1236
1236
|
* @return {Number}
|
|
1237
1237
|
*/ /**
|
|
1238
1238
|
* Remove a callback function that is previously added to the scene.
|
|
@@ -1254,6 +1254,10 @@ var convertDurationObjectToString=duration=>[...(duration.years?["".concat(durat
|
|
|
1254
1254
|
*/ /*
|
|
1255
1255
|
* Add temporary lines to the scene which can be removed
|
|
1256
1256
|
* with clearTemporaryPrimitives method.
|
|
1257
|
+
*/ /*
|
|
1258
|
+
* Display frustum
|
|
1259
|
+
*/ /*
|
|
1260
|
+
* Hide frustum
|
|
1257
1261
|
*/ /*
|
|
1258
1262
|
* Remove object from temporary objects list
|
|
1259
1263
|
*/ /*
|
|
@@ -1274,7 +1278,7 @@ var convertDurationObjectToString=duration=>[...(duration.years?["".concat(durat
|
|
|
1274
1278
|
*/ /*
|
|
1275
1279
|
* Enable static axis display, createAxisDisplay must be called
|
|
1276
1280
|
* before the axis can be display.
|
|
1277
|
-
*/this.setDurationFromObject=duration=>{var string=convertDurationObjectToString(duration),millisec=convertDurationObjectTomSec(duration);this.setMetadataTag("Duration",string),this.setDuration(millisec)},this.setOriginalDurationFromObject=duration=>{var string=convertDurationObjectToString(duration);this.setMetadataTag("OriginalDuration",string)},this.exportGLTF=binary=>{var exporter=new SceneExporter(this);return exporter.exportGLTF(binary)},this.getRootRegion=()=>rootRegion,this.createLines=(regionPath,groupName,coords,colour)=>{var region=rootRegion.findChildFromPath(regionPath);return void 0===region&&(region=rootRegion.createChildFromPath(regionPath)),region.createLines(groupName,coords,colour)},this.createPoints=(regionPath,groupName,coords,labels,colour)=>{var region=rootRegion.findChildFromPath(regionPath);return void 0===region&&(region=rootRegion.createChildFromPath(regionPath)),region.createPoints(groupName,coords,labels,colour)},this.addZincObjectAddedCallbacks=callbackFunction=>(++zincObjectAddedCallbacks_id,zincObjectAddedCallbacks[zincObjectAddedCallbacks_id]=callbackFunction,zincObjectAddedCallbacks_id),this.addZincObjectRemovedCallbacks=callbackFunction=>(++zincObjectRemovedCallbacks_id,zincObjectRemovedCallbacks[zincObjectRemovedCallbacks_id]=callbackFunction,zincObjectRemovedCallbacks_id),this.removeZincObjectAddedCallbacks=id=>{id in zincObjectAddedCallbacks_id&&delete zincObjectAddedCallbacks[id]},this.removeZincObjectRemovedCallbacks=id=>{id in zincObjectRemovedCallbacks_id&&delete zincObjectRemovedCallbacks[id]},this.clearZincObjectAddedCallbacks=()=>{zincObjectAddedCallbacks={},zincObjectAddedCallbacks_id=0},this.clearZincObjectRemovedCallbacks=()=>{zincObjectRemovedCallbacks={},zincObjectRemovedCallbacks_id=0},this.triggerObjectAddedCallback=zincObject=>{for(var key in zincObjectAddedCallbacks)zincObjectAddedCallbacks.hasOwnProperty(key)&&zincObjectAddedCallbacks[key](zincObject)},this.triggerObjectRemovedCallback=zincObject=>{for(var key in zincObjectRemovedCallbacks)zincObjectRemovedCallbacks.hasOwnProperty(key)&&zincObjectRemovedCallbacks[key](zincObject)},this.addTemporaryPoints=(coords,colour)=>{var geometry=createBufferGeometry(coords.length,coords),material=new THREE.PointsMaterial({alphaTest:.5,size:15,color:colour,sizeAttenuation:!1}),texture=getCircularTexture();material.map=texture;var point=new((__webpack_require__(23).Points))(geometry,material);return tempGroup.add(point),point},this.addTemporaryLines=(coords,colour)=>{var geometry=createBufferGeometry(coords.length,coords),material=new THREE.LineBasicMaterial({color:colour}),line=new((__webpack_require__(12).LineSegments))(geometry,material);return tempGroup.add(line),line},this.removeTemporaryPrimitive=object=>{tempGroup.remove(object),object.geometry.dispose(),object.material.dispose()},this.clearTemporaryPrimitives=()=>{var i=0,children=tempGroup.children;return children.forEach(child=>{child.geometry.dispose(),child.material.dispose(),i++}),tempGroup.clear(),i},this.addBoundingBoxPrimitive=function(regionPath,group,colour,opacity,visibility){var boundingBox=5<arguments.length&&void 0!==arguments[5]?arguments[5]:void 0,region=rootRegion.findChildFromPath(regionPath);void 0===region&&(region=rootRegion.createChildFromPath(regionPath));var box=boundingBox?boundingBox:_this.getBoundingBox();_v3.set(0,0,0);var dim=_v3.subVectors(box.max,box.min),boxGeo=new THREE.BoxGeometry(dim.x,dim.y,dim.z),primitive=region.createGeometryFromThreeJSGeometry(group,boxGeo,colour,opacity,visibility,1e4);return dim.addVectors(box.min,box.max).multiplyScalar(.5),primitive.setPosition(dim.x,dim.y,dim.z),primitive},this.addSlicesPrimitive=function(regionPath,groups,colours,opacity,visibility){var boundingBox=5<arguments.length&&arguments[5]!==void 0?arguments[5]:void 0;if(groups&&3<=groups.length&&colours&&3<=colours.length){var region=rootRegion.findChildFromPath(regionPath);void 0===region&&(region=rootRegion.createChildFromPath(regionPath));var box=boundingBox?boundingBox:_this.getBoundingBox();_v3.set(0,0,0);var dim=_v3.subVectors(box.max,box.min),primitives=[],index=0;return["x","y","z"].forEach(direction=>{var planeGeo;switch(direction){//YZ plane
|
|
1281
|
+
*/this.setDurationFromObject=duration=>{var string=convertDurationObjectToString(duration),millisec=convertDurationObjectTomSec(duration);this.setMetadataTag("Duration",string),this.setDuration(millisec)},this.setOriginalDurationFromObject=duration=>{var string=convertDurationObjectToString(duration);this.setMetadataTag("OriginalDuration",string)},this.exportGLTF=binary=>{var exporter=new SceneExporter(this);return exporter.exportGLTF(binary)},this.getRootRegion=()=>rootRegion,this.createLines=(regionPath,groupName,coords,colour)=>{var region=rootRegion.findChildFromPath(regionPath);return void 0===region&&(region=rootRegion.createChildFromPath(regionPath)),region.createLines(groupName,coords,colour)},this.createPoints=(regionPath,groupName,coords,labels,colour)=>{var region=rootRegion.findChildFromPath(regionPath);return void 0===region&&(region=rootRegion.createChildFromPath(regionPath)),region.createPoints(groupName,coords,labels,colour)},this.addZincObjectAddedCallbacks=callbackFunction=>(++zincObjectAddedCallbacks_id,zincObjectAddedCallbacks[zincObjectAddedCallbacks_id]=callbackFunction,zincObjectAddedCallbacks_id),this.addZincObjectRemovedCallbacks=callbackFunction=>(++zincObjectRemovedCallbacks_id,zincObjectRemovedCallbacks[zincObjectRemovedCallbacks_id]=callbackFunction,zincObjectRemovedCallbacks_id),this.removeZincObjectAddedCallbacks=id=>{id in zincObjectAddedCallbacks_id&&delete zincObjectAddedCallbacks[id]},this.removeZincObjectRemovedCallbacks=id=>{id in zincObjectRemovedCallbacks_id&&delete zincObjectRemovedCallbacks[id]},this.clearZincObjectAddedCallbacks=()=>{zincObjectAddedCallbacks={},zincObjectAddedCallbacks_id=0},this.clearZincObjectRemovedCallbacks=()=>{zincObjectRemovedCallbacks={},zincObjectRemovedCallbacks_id=0},this.triggerObjectAddedCallback=zincObject=>{for(var key in zincObjectAddedCallbacks)zincObjectAddedCallbacks.hasOwnProperty(key)&&zincObjectAddedCallbacks[key](zincObject)},this.triggerObjectRemovedCallback=zincObject=>{for(var key in zincObjectRemovedCallbacks)zincObjectRemovedCallbacks.hasOwnProperty(key)&&zincObjectRemovedCallbacks[key](zincObject)},this.addTemporaryPoints=(coords,colour)=>{var geometry=createBufferGeometry(coords.length,coords),material=new THREE.PointsMaterial({alphaTest:.5,size:15,color:colour,sizeAttenuation:!1}),texture=getCircularTexture();material.map=texture;var point=new((__webpack_require__(23).Points))(geometry,material);return tempGroup.add(point),point},this.addTemporaryLines=(coords,colour)=>{var geometry=createBufferGeometry(coords.length,coords),material=new THREE.LineBasicMaterial({color:colour}),line=new((__webpack_require__(12).LineSegments))(geometry,material);return tempGroup.add(line),line},this.enableFrustumDisplay=()=>{this.camera&&!cameraHelper&&(cameraHelper=new THREE.CameraHelper(this.camera),scene.add(cameraHelper))},this.disableFrustumDisplay=()=>{cameraHelper&&(scene.remove(cameraHelper),cameraHelper.dispose(),cameraHelper=void 0)},this.removeTemporaryPrimitive=object=>{tempGroup.remove(object),object.geometry.dispose(),object.material.dispose()},this.clearTemporaryPrimitives=()=>{var i=0,children=tempGroup.children;return children.forEach(child=>{child.geometry.dispose(),child.material.dispose(),i++}),tempGroup.clear(),i},this.addBoundingBoxPrimitive=function(regionPath,group,colour,opacity,visibility){var boundingBox=5<arguments.length&&void 0!==arguments[5]?arguments[5]:void 0,region=rootRegion.findChildFromPath(regionPath);void 0===region&&(region=rootRegion.createChildFromPath(regionPath));var box=boundingBox?boundingBox:_this.getBoundingBox();_v3.set(0,0,0);var dim=_v3.subVectors(box.max,box.min),boxGeo=new THREE.BoxGeometry(dim.x,dim.y,dim.z),primitive=region.createGeometryFromThreeJSGeometry(group,boxGeo,colour,opacity,visibility,1e4);return dim.addVectors(box.min,box.max).multiplyScalar(.5),primitive.setPosition(dim.x,dim.y,dim.z),primitive},this.addSlicesPrimitive=function(regionPath,groups,colours,opacity,visibility){var boundingBox=5<arguments.length&&arguments[5]!==void 0?arguments[5]:void 0;if(groups&&3<=groups.length&&colours&&3<=colours.length){var region=rootRegion.findChildFromPath(regionPath);void 0===region&&(region=rootRegion.createChildFromPath(regionPath));var box=boundingBox?boundingBox:_this.getBoundingBox();_v3.set(0,0,0);var dim=_v3.subVectors(box.max,box.min),primitives=[],index=0;return["x","y","z"].forEach(direction=>{var planeGeo;switch(direction){//YZ plane
|
|
1278
1282
|
case"x":planeGeo=new THREE.PlaneGeometry(dim.z,dim.y),planeGeo.rotateY(Math.PI/2);// code block
|
|
1279
1283
|
break;//XZ plane
|
|
1280
1284
|
case"y":planeGeo=new THREE.PlaneGeometry(dim.x,dim.z),planeGeo.rotateX(Math.PI/2);// code block
|
|
@@ -1587,9 +1591,9 @@ if(0<state.vertices.length){var _material2=new three__WEBPACK_IMPORTED_MODULE_0_
|
|
|
1587
1591
|
/* 38 */
|
|
1588
1592
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1589
1593
|
|
|
1590
|
-
function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread(e){for(var t,r=1;r<arguments.length;r++)t=null==arguments[r]?{}:arguments[r],r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))});return e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==typeof i?i:i+""}function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}var JSONLoader=(__webpack_require__(19).JSONLoader),THREE=__webpack_require__(4),FileLoader=THREE.FileLoader,mergeGlyphData=glyphData=>{var merge=(glyphData1,glyphData2)=>{glyphData1.metadata.number_of_vertices+=glyphData2.metadata.number_of_vertices,"labels"in glyphData1&&glyphData1.labels.push(...glyphData1.labels);var fields=["axis1","axis2","axis3","colors","positions","scale"];fields.forEach(field=>{field in glyphData1&&Object.keys(glyphData1[field]).forEach(step=>{glyphData1[field][step].push(...glyphData2[field][step])})})};if(glyphData&&0<glyphData.length)for(;1<glyphData.length;){var glyphData2=glyphData.splice(1,1);merge(glyphData[0],glyphData2[0])}},mergeGeometries=geometries=>{var merge=(geometry1,geometry2)=>{geometry1.merge(geometry2)};if(geometries&&0<geometries.length){for(;1<geometries.length;){var geometry2=geometries.splice(1,1);merge(geometries[0],geometry2[0])}return geometries[0]}},IndexedSourcesHandler=function IndexedSourcesHandler(urlIn,crossOrigin,onDownloadedCallback){var fileLoader=new FileLoader,jsonLoader=new JSONLoader;fileLoader.crossOrigin=crossOrigin;var url=urlIn,onDownloaded=onDownloadedCallback,data=void 0,downloading=!1,finished=!1,error=void 0,items=[],processItemDownloaded=item=>{var modelData=data[item.index];if(!modelData)processItemError(item,{responseURL:url});else if("GlyphGeometriesURL"in modelData)item.onLoad(modelData);else{var obj=jsonLoader.parse(modelData);item.onLoad(obj.geometry,obj.materials)}},processItemError=item=>{item.onError&&(!error&&(error={responseURL:url}),item.onError(error))};this.downloadCompleted=args=>{try{data=JSON.parse(args[0]),downloading=!1,finished=!0,Array.isArray(data)?items.forEach(item=>processItemDownloaded(item)):items.forEach(item=>processItemError(item))}catch(_unused){items.forEach(item=>processItemError(item))}};var errorHandling=()=>xhr=>{error=xhr,finished=!0,downloading=!1,items.forEach(item=>{processItemError(item)})},progressHandling=()=>xhr=>{items.forEach(item=>{item.onProgress&&item.onProgress(xhr)})};this.load=(index,onLoad,onProgress,onError)=>{var item={index,onLoad,onProgress,onError};finished?data?processItemDownloaded(item):processItemError(error):downloading?items.push(item):(items.push(item),downloading=!0,fileLoader.load(url,onDownloaded,progressHandling,errorHandling))}},MultiSourcesHandler=function MultiSourcesHandler(numberIn,onLoadCallback){var allData=[],number=numberIn,onLoad=onLoadCallback,totalDownloaded=0;this.itemDownloaded=(order,args)=>{if(allData[order]=args,totalDownloaded++,totalDownloaded==number&&0<allData.length)//Assume when item length is one then it is a glyphset otherwise geometry
|
|
1591
|
-
if(
|
|
1592
|
-
for(var materials=allData[0][1],geometries=allData.map(data=>data[0]),geometry=mergeGeometries(geometries),i=1;i<number;i++)allData[order][0].dispose(),allData[order][1].forEach(material=>material.dispose());onLoad(geometry,materials)}else{var glyphData=allData.map(item=>JSON.parse(item[0]));mergeGlyphData(glyphData),onLoad(glyphData[0])}}};exports.PrimitivesLoader=function(){var concurrentDownloads=0,MAX_DOWNLOAD=20;this.crossOrigin="Anonymous";var jsonloader=new JSONLoader,fileloader=new FileLoader;fileloader.crossOrigin="Anonymous";var waitingList=[],indexedLoaders={},loadFromMultipleSources=(urls,onLoad,onProgress,onError,options)=>{var number=urls.length,msHandler=new MultiSourcesHandler(number,onLoad),order=0;//The order here will give us hint on the sequence on merging the primitives
|
|
1594
|
+
function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread(e){for(var t,r=1;r<arguments.length;r++)t=null==arguments[r]?{}:arguments[r],r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))});return e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==typeof i?i:i+""}function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}var JSONLoader=(__webpack_require__(19).JSONLoader),THREE=__webpack_require__(4),FileLoader=THREE.FileLoader,mergeGlyphData=glyphData=>{var merge=(glyphData1,glyphData2)=>{glyphData1.metadata.number_of_vertices+=glyphData2.metadata.number_of_vertices,"labels"in glyphData1&&glyphData1.labels.push(...glyphData1.labels);var fields=["axis1","axis2","axis3","colors","positions","scale"];fields.forEach(field=>{field in glyphData1&&Object.keys(glyphData1[field]).forEach(step=>{glyphData1[field][step].push(...glyphData2[field][step])})})};if(glyphData&&0<glyphData.length)for(;1<glyphData.length;){var glyphData2=glyphData.splice(1,1);merge(glyphData[0],glyphData2[0])}},mergeGeometries=geometries=>{var merge=(geometry1,geometry2)=>{geometry1.merge(geometry2)};if(geometries&&0<geometries.length){for(;1<geometries.length;){var geometry2=geometries.splice(1,1);merge(geometries[0],geometry2[0])}return geometries[0]}},IndexedSourcesHandler=function IndexedSourcesHandler(urlIn,crossOrigin,onDownloadedCallback){var fileLoader=new FileLoader,jsonLoader=new JSONLoader;fileLoader.crossOrigin=crossOrigin;var url=urlIn,onDownloaded=onDownloadedCallback,data=void 0,downloading=!1,finished=!1,error=void 0,items=[],processItemDownloaded=item=>{var modelData=data[item.index];if(!modelData)processItemError(item,{responseURL:url});else if("GlyphGeometriesURL"in modelData)item.onLoad(modelData);else{var obj=jsonLoader.parse(modelData);item.onLoad(obj.geometry,obj.materials)}},processItemError=item=>{item.onError&&(!error&&(error={responseURL:url}),item.onError(error))};this.downloadCompleted=args=>{try{data=JSON.parse(args[0]),downloading=!1,finished=!0,Array.isArray(data)?items.forEach(item=>processItemDownloaded(item)):items.forEach(item=>processItemError(item))}catch(_unused){items.forEach(item=>processItemError(item))}};var errorHandling=()=>xhr=>{error=xhr,finished=!0,downloading=!1,items.forEach(item=>{processItemError(item)})},progressHandling=()=>xhr=>{items.forEach(item=>{item.onProgress&&item.onProgress(xhr)})};this.load=(index,onLoad,onProgress,onError)=>{var item={index,onLoad,onProgress,onError};finished?data?processItemDownloaded(item):processItemError(error):downloading?items.push(item):(items.push(item),downloading=!0,fileLoader.load(url,onDownloaded,progressHandling,errorHandling))}},MultiSourcesHandler=function MultiSourcesHandler(numberIn,onLoadCallback,options){var allData=[],number=numberIn,onLoad=onLoadCallback,totalDownloaded=0,isGlyphData=options.isGlyphsets;this.itemDownloaded=(order,args)=>{if(allData[order]=args,totalDownloaded++,totalDownloaded==number&&0<allData.length)//Assume when item length is one then it is a glyphset otherwise geometry
|
|
1595
|
+
if(!isGlyphData){//All geometries will be merged into the first one
|
|
1596
|
+
for(var materials=allData[0][1],geometries=allData.map(data=>data[0]),geometry=mergeGeometries(geometries),i=1;i<number;i++)allData[order][0].dispose(),allData[order][1].forEach(material=>material.dispose());onLoad(geometry,materials)}else{var glyphData=allData.map(item=>JSON.parse(item[0]));mergeGlyphData(glyphData),onLoad(glyphData[0])}}};exports.PrimitivesLoader=function(){var concurrentDownloads=0,MAX_DOWNLOAD=20;this.crossOrigin="Anonymous";var jsonloader=new JSONLoader,fileloader=new FileLoader;fileloader.crossOrigin="Anonymous";var waitingList=[],indexedLoaders={},loadFromMultipleSources=(urls,onLoad,onProgress,onError,options)=>{var number=urls.length,msHandler=new MultiSourcesHandler(number,onLoad,options),order=0;//The order here will give us hint on the sequence on merging the primitives
|
|
1593
1597
|
urls.forEach(url=>{var newOptions=options?_objectSpread({},options):{};newOptions.msHandler=msHandler,newOptions.order=order,order++,loadFromSingleSource(url,onLoad,onProgress,onError,newOptions)})},handleIndexedSource=(url,onLoad,onProgress,onError,options)=>{var newOptions=options?_objectSpread({},options):{},indexedLoader=indexedLoaders[url];if(!indexedLoader)if(MAX_DOWNLOAD>concurrentDownloads){var onLoadCallback=new onFinally(void 0,this,newOptions);++concurrentDownloads,indexedLoader=new IndexedSourcesHandler(url,this.crossOrigin,onLoadCallback),indexedLoaders[url]=indexedLoader}else waitingList.push({url,onLoad,onProgress,onError,options});indexedLoader&&(newOptions.isHandler=indexedLoader,indexedLoader.load(options.index,onLoad,onProgress,onError))},loadFromSingleSource=(url,onLoad,onProgress,onError,options)=>{if(options&&options.index!==void 0)handleIndexedSource(url,onLoad,onProgress,onError,options);else//Standard loading
|
|
1594
1598
|
if(MAX_DOWNLOAD>concurrentDownloads){++concurrentDownloads;var onLoadCallback=new onFinally(onLoad,this,options),onErrorCallback=new onFinally(onError,this,options);options.isGlyphsets?fileloader.load(url,onLoadCallback,onProgress,onErrorCallback):(jsonloader.crossOrigin=this.crossOrigin,jsonloader.load(url,onLoadCallback,onProgress,onErrorCallback))}else waitingList.push({url,onLoad,onProgress,onError,options})};//URL to loader pair
|
|
1595
1599
|
//Load the first file then the rest will be handled separately
|