zincjs 1.18.3 → 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 +2 -2
- package/build/zinc.js.map +1 -1
- package/package.json +1 -1
- package/src/loaders/JSONLoader.js +16 -11
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}}}()});
|