@realsee/five 6.0.0-alpha.73 → 6.0.0-alpha.75
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/docs/assets/search.js +1 -1
- package/docs/classes/five.Model.html +2 -2
- package/docs/classes/five.Work.html +13 -13
- package/docs/functions/five.parseWork.html +1 -1
- package/docs/interfaces/five.XRPanoramaControllerCustomInitArgs.html +3 -4
- package/docs/types/five.ModelMaterialValues.html +1 -1
- package/docs/types/five.Models.html +4 -4
- package/docs/types/five.ParseWorkOptions.html +2 -2
- package/docs/types/five.Works.html +1 -1
- package/docs/variables/five.defaultPbmParameters.html +1 -1
- package/five/index.d.ts +6 -1
- package/five/index.js +71 -71
- package/five/index.mjs +1377 -1394
- package/gltf-loader/index.js +3 -3
- package/gltf-loader/index.mjs +3 -3
- package/line/index.js +3 -3
- package/line/index.mjs +3 -3
- package/package.json +3 -9
- package/react/index.js +2 -2
- package/react/index.mjs +2 -2
- package/scripts/five-staticify.js +183 -2
- package/sticker/index.js +3 -3
- package/sticker/index.mjs +3 -3
- package/umd/five-gltf-loader.js +3 -3
- package/umd/five-line.js +3 -3
- package/umd/five-react.js +2 -2
- package/umd/five-sticker.js +3 -3
- package/umd/five-vfx.js +2 -2
- package/umd/five-vue.js +2 -2
- package/umd/five.js +7 -7
- package/vfx/index.js +2 -2
- package/vfx/index.mjs +2 -2
- package/vue/index.js +2 -2
- package/vue/index.mjs +2 -2
- package/exporters/staticify.js +0 -210
- package/scripts/five-plugin-init.js +0 -83
- package/scripts/five-quick-start-init.js +0 -80
- package/scripts/five-react-component-init.js +0 -83
- package/templates/plugin/README.md +0 -38
- package/templates/plugin/devtools/external-five.js +0 -5
- package/templates/plugin/devtools/external-three.js +0 -5
- package/templates/plugin/devtools/tsconfig.build.json +0 -18
- package/templates/plugin/devtools/webpack.bundle.js +0 -44
- package/templates/plugin/devtools/webpack.example.js +0 -39
- package/templates/plugin/docs/.gitkeep +0 -0
- package/templates/plugin/examples/data.json +0 -507
- package/templates/plugin/examples/index.html +0 -28
- package/templates/plugin/examples/index.ts +0 -12
- package/templates/plugin/lib/index.ts +0 -30
- package/templates/plugin/package.json +0 -32
- package/templates/plugin/tsconfig.json +0 -26
- package/templates/quick-start/README.md +0 -47
- package/templates/quick-start/assets/work.json +0 -507
- package/templates/quick-start/index.html +0 -54
- package/templates/quick-start/index.tsx +0 -123
- package/templates/quick-start/package.json +0 -25
- package/templates/quick-start/tsconfig.json +0 -27
- package/templates/quick-start/webpack.config.js +0 -45
- package/templates/quick-start/webpack.production.js +0 -42
- package/templates/react-component/README.md +0 -32
- package/templates/react-component/devtools/external-five.js +0 -5
- package/templates/react-component/devtools/external-react.js +0 -5
- package/templates/react-component/devtools/external-three.js +0 -5
- package/templates/react-component/devtools/tsconfig.build.json +0 -19
- package/templates/react-component/devtools/webpack.bundle.js +0 -44
- package/templates/react-component/devtools/webpack.example.js +0 -39
- package/templates/react-component/docs/.gitkeep +0 -0
- package/templates/react-component/examples/data.json +0 -507
- package/templates/react-component/examples/index.html +0 -17
- package/templates/react-component/examples/index.tsx +0 -62
- package/templates/react-component/lib/index.tsx +0 -157
- package/templates/react-component/package.json +0 -38
- package/templates/react-component/tsconfig.json +0 -27
package/gltf-loader/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
3
|
* @realsee/five
|
|
4
|
-
* Generated:
|
|
5
|
-
* Version: 6.0.0-alpha.
|
|
4
|
+
* Generated: 1/3/2024
|
|
5
|
+
* Version: 6.0.0-alpha.75
|
|
6
6
|
* Terms:
|
|
7
7
|
* Realsee SDK License Agreement
|
|
8
8
|
* Update: July 28, 2021
|
|
@@ -258,4 +258,4 @@
|
|
|
258
258
|
`),a=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP"," vec4 texelGlossiness = texture2D( glossinessMap, vUv );"," // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture"," glossinessFactor *= texelGlossiness.a;","#endif"].join(`
|
|
259
259
|
`),i=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb;","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.specularRoughness = max( 1.0 - glossinessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.","material.specularRoughness += geometryRoughness;","material.specularRoughness = min( material.specularRoughness, 1.0 );","material.specularColor = specularFactor.rgb;"].join(`
|
|
260
260
|
`),s={specular:{value:new c.Color().setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=s,this.onBeforeCompile=function(o){for(var f in s)o.uniforms[f]=s[f];o.fragmentShader=o.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;"),o.fragmentShader=o.fragmentShader.replace("uniform float metalness;","uniform float glossiness;"),o.fragmentShader=o.fragmentShader.replace("#include <roughnessmap_pars_fragment>",r),o.fragmentShader=o.fragmentShader.replace("#include <metalnessmap_pars_fragment>",n),o.fragmentShader=o.fragmentShader.replace("#include <roughnessmap_fragment>",t),o.fragmentShader=o.fragmentShader.replace("#include <metalnessmap_fragment>",a),o.fragmentShader=o.fragmentShader.replace("#include <lights_physical_fragment>",i)},Object.defineProperties(this,{specular:{get:function(){return s.specular.value},set:function(o){s.specular.value=o}},specularMap:{get:function(){return s.specularMap.value},set:function(o){s.specularMap.value=o}},glossiness:{get:function(){return s.glossiness.value},set:function(o){s.glossiness.value=o}},glossinessMap:{get:function(){return s.glossinessMap.value},set:function(o){s.glossinessMap.value=o,o?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_ROUGHNESSMAP=""):(delete this.defines.USE_ROUGHNESSMAP,delete this.defines.USE_GLOSSINESSMAP)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}b.prototype=Object.create(c.MeshStandardMaterial.prototype),b.prototype.constructor=b,b.prototype.copy=function(e){return c.MeshStandardMaterial.prototype.copy.call(this,e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this};function V(){return{name:u.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,specularGlossinessParams:["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"],getMaterialType:function(){return b},extendParams:function(e,r,n){var t=r.extensions[this.name];e.color=new c.Color(1,1,1),e.opacity=1;var a=[];if(Array.isArray(t.diffuseFactor)){var i=t.diffuseFactor;e.color.fromArray(i),e.opacity=i[3]}if(t.diffuseTexture!==void 0&&a.push(n.assignTexture(e,"map",t.diffuseTexture)),e.emissive=new c.Color(0,0,0),e.glossiness=t.glossinessFactor!==void 0?t.glossinessFactor:1,e.specular=new c.Color(1,1,1),Array.isArray(t.specularFactor)&&e.specular.fromArray(t.specularFactor),t.specularGlossinessTexture!==void 0){var s=t.specularGlossinessTexture;a.push(n.assignTexture(e,"glossinessMap",s)),a.push(n.assignTexture(e,"specularMap",s))}return Promise.all(a)},createMaterial:function(e){var r=new b(e);return r.fog=!0,r.color=e.color,r.map=e.map===void 0?null:e.map,r.lightMap=null,r.lightMapIntensity=1,r.aoMap=e.aoMap===void 0?null:e.aoMap,r.aoMapIntensity=1,r.emissive=e.emissive,r.emissiveIntensity=1,r.emissiveMap=e.emissiveMap===void 0?null:e.emissiveMap,r.bumpMap=e.bumpMap===void 0?null:e.bumpMap,r.bumpScale=1,r.normalMap=e.normalMap===void 0?null:e.normalMap,r.normalMapType=c.TangentSpaceNormalMap,e.normalScale&&(r.normalScale=e.normalScale),r.displacementMap=null,r.displacementScale=1,r.displacementBias=0,r.specularMap=e.specularMap===void 0?null:e.specularMap,r.specular=e.specular,r.glossinessMap=e.glossinessMap===void 0?null:e.glossinessMap,r.glossiness=e.glossiness,r.alphaMap=null,r.envMap=e.envMap===void 0?null:e.envMap,r.envMapIntensity=1,r.refractionRatio=.98,r}}}function $(){this.name=u.KHR_MESH_QUANTIZATION}function P(e,r,n,t){c.Interpolant.call(this,e,r,n,t)}P.prototype=Object.create(c.Interpolant.prototype),P.prototype.constructor=P,P.prototype.copySampleValue_=function(e){for(var r=this.resultBuffer,n=this.sampleValues,t=this.valueSize,a=e*t*3+t,i=0;i!==t;i++)r[i]=n[a+i];return r},P.prototype.beforeStart_=P.prototype.copySampleValue_,P.prototype.afterEnd_=P.prototype.copySampleValue_,P.prototype.interpolate_=function(e,r,n,t){for(var a=this.resultBuffer,i=this.sampleValues,s=this.valueSize,o=s*2,f=s*3,l=t-r,v=(n-r)/l,d=v*v,h=d*v,y=e*f,_=y-f,S=-2*h+3*d,R=h-d,E=1-S,F=R-d+v,G=0;G!==s;G++){var te=i[_+G+s],ne=i[_+G+o]*l,Q=i[y+G+s],B=i[y+G]*l;a[G]=E*te+F*ne+S*Q+R*B}return a};var H={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},ee={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},re={9728:c.NearestFilter,9729:c.LinearFilter,9984:c.NearestMipmapNearestFilter,9985:c.LinearMipmapNearestFilter,9986:c.NearestMipmapLinearFilter,9987:c.LinearMipmapLinearFilter},J={33071:c.ClampToEdgeWrapping,33648:c.MirroredRepeatWrapping,10497:c.RepeatWrapping},W={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},j={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},X={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ge={CUBICSPLINE:void 0,LINEAR:c.InterpolateLinear,STEP:c.InterpolateDiscrete},ie={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"},fe={"image/png":c.RGBAFormat,"image/jpeg":c.RGBFormat};function de(e,r){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(r)&&/^\//.test(e)&&(r=r.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:r+e)}function me(e){return e.DefaultMaterial===void 0&&(e.DefaultMaterial=new c.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:c.FrontSide})),e.DefaultMaterial}function se(e,r,n){for(var t in n.extensions)e[t]===void 0&&(r.userData.gltfExtensions=r.userData.gltfExtensions||{},r.userData.gltfExtensions[t]=n.extensions[t])}function Y(e,r){r.extras!==void 0&&(typeof r.extras=="object"?Object.assign(e.userData,r.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+r.extras))}function Ae(e,r,n){for(var t=!1,a=!1,i=0,s=r.length;i<s;i++){var o=r[i];if(o.POSITION!==void 0&&(t=!0),o.NORMAL!==void 0&&(a=!0),t&&a)break}if(!t&&!a)return Promise.resolve(e);for(var f=[],l=[],i=0,s=r.length;i<s;i++){var o=r[i];if(t){var v=o.POSITION!==void 0?n.getDependency("accessor",o.POSITION):e.attributes.position;f.push(v)}if(a){var v=o.NORMAL!==void 0?n.getDependency("accessor",o.NORMAL):e.attributes.normal;l.push(v)}}return Promise.all([Promise.all(f),Promise.all(l)]).then(function(d){var h=d[0],y=d[1];return t&&(e.morphAttributes.position=h),a&&(e.morphAttributes.normal=y),e.morphTargetsRelative=!0,e})}function Se(e,r){if(e.updateMorphTargets(),r.weights!==void 0)for(var n=0,t=r.weights.length;n<t;n++)e.morphTargetInfluences[n]=r.weights[n];if(r.extras&&Array.isArray(r.extras.targetNames)){var a=r.extras.targetNames;if(e.morphTargetInfluences.length===a.length){e.morphTargetDictionary={};for(var n=0,t=a.length;n<t;n++)e.morphTargetDictionary[a[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function ye(e){var r=e.extensions&&e.extensions[u.KHR_DRACO_MESH_COMPRESSION],n;return r?n="draco:"+r.bufferView+":"+r.indices+":"+U(r.attributes):n=e.indices+":"+U(e.attributes)+":"+e.mode,n}function U(e){for(var r="",n=Object.keys(e).sort(),t=0,a=n.length;t<a;t++)r+=n[t]+":"+e[n[t]]+";";return r}function I(e,r,n){this.json=e||{},this.extensions=r||{},this.options=n||{},this.cache=new T,this.associations=new Map,this.primitiveCache={},this.textureLoader=new c.TextureLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.fileLoader=new c.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}I.prototype.parse=function(e,r){var n=this,t=this.json,a=this.extensions;this.cache.removeAll(),this.markDefs(),Promise.all([this.getDependencies("scene"),this.getDependencies("animation"),this.getDependencies("camera")]).then(function(i){var s={scene:i[0][t.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:t.asset,parser:n,userData:{}};se(a,s,t),Y(s,t),e(s)}).catch(r)},I.prototype.markDefs=function(){for(var e=this.json.nodes||[],r=this.json.skins||[],n=this.json.meshes||[],t={},a={},i=0,s=r.length;i<s;i++)for(var o=r[i].joints,f=0,l=o.length;f<l;f++)e[o[f]].isBone=!0;for(var v=0,d=e.length;v<d;v++){var h=e[v];h.mesh!==void 0&&(t[h.mesh]===void 0&&(t[h.mesh]=a[h.mesh]=0),t[h.mesh]++,h.skin!==void 0&&(n[h.mesh].isSkinnedMesh=!0))}this.json.meshReferences=t,this.json.meshUses=a},I.prototype.getDependency=function(e,r){var n=e+":"+r,t=this.cache.get(n);if(!t){switch(e){case"scene":t=this.loadScene(r);break;case"node":t=this.loadNode(r);break;case"mesh":t=this.loadMesh(r);break;case"accessor":t=this.loadAccessor(r);break;case"bufferView":t=this.loadBufferView(r);break;case"buffer":t=this.loadBuffer(r);break;case"material":t=this.loadMaterial(r);break;case"texture":t=this.loadTexture(r);break;case"skin":t=this.loadSkin(r);break;case"animation":t=this.loadAnimation(r);break;case"camera":t=this.loadCamera(r);break;case"light":t=this.extensions[u.KHR_LIGHTS_PUNCTUAL].loadLight(r);break;default:throw new Error("Unknown type: "+e)}this.cache.add(n,t)}return t},I.prototype.getDependencies=function(e){var r=this.cache.get(e);if(!r){var n=this,t=this.json[e+(e==="mesh"?"es":"s")]||[];r=Promise.all(t.map(function(a,i){return n.getDependency(e,i)})),this.cache.add(e,r)}return r},I.prototype.loadBuffer=function(e){var r=this.json.buffers[e],n=this.fileLoader;if(r.type&&r.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+r.type+" buffer type is not supported.");if(r.uri===void 0&&e===0)return Promise.resolve(this.extensions[u.KHR_BINARY_GLTF].body);var t=this.options;return new Promise(function(a,i){n.load(de(r.uri,t.path),a,void 0,function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+r.uri+'".'))})})},I.prototype.loadBufferView=function(e){var r=this.json.bufferViews[e];return this.getDependency("buffer",r.buffer).then(function(n){var t=r.byteLength||0,a=r.byteOffset||0;return n.slice(a,a+t)})},I.prototype.loadAccessor=function(e){var r=this,n=this.json,t=this.json.accessors[e];if(t.bufferView===void 0&&t.sparse===void 0)return Promise.resolve(null);var a=[];return t.bufferView!==void 0?a.push(this.getDependency("bufferView",t.bufferView)):a.push(null),t.sparse!==void 0&&(a.push(this.getDependency("bufferView",t.sparse.indices.bufferView)),a.push(this.getDependency("bufferView",t.sparse.values.bufferView))),Promise.all(a).then(function(i){var s=i[0],o=W[t.type],f=ee[t.componentType],l=f.BYTES_PER_ELEMENT,v=l*o,d=t.byteOffset||0,h=t.bufferView!==void 0?n.bufferViews[t.bufferView].byteStride:void 0,y=t.normalized===!0,_,S;if(h&&h!==v){var R=Math.floor(d/h),E="InterleavedBuffer:"+t.bufferView+":"+t.componentType+":"+R+":"+t.count,F=r.cache.get(E);F||(_=new f(s,R*h,t.count*h/l),F=new c.InterleavedBuffer(_,h/l),r.cache.add(E,F)),S=new c.InterleavedBufferAttribute(F,o,d%h/l,y)}else s===null?_=new f(t.count*o):_=new f(s,d,t.count*o),S=new c.BufferAttribute(_,o,y);if(t.sparse!==void 0){var G=W.SCALAR,te=ee[t.sparse.indices.componentType],ne=t.sparse.indices.byteOffset||0,Q=t.sparse.values.byteOffset||0,B=new te(i[1],ne,t.sparse.count*G),oe=new f(i[2],Q,t.sparse.count*o);s!==null&&(S=new c.BufferAttribute(S.array.slice(),S.itemSize,S.normalized));for(var k=0,Ee=B.length;k<Ee;k++){var ae=B[k];if(S.setX(ae,oe[k*o]),o>=2&&S.setY(ae,oe[k*o+1]),o>=3&&S.setZ(ae,oe[k*o+2]),o>=4&&S.setW(ae,oe[k*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return S})},I.prototype.loadTexture=function(e){var r=this,n=this.json,t=this.options,a=this.textureLoader,i=self.URL||self.webkitURL,s=n.textures[e],o=s.extensions||{},f;o[u.MSFT_TEXTURE_DDS]?f=n.images[o[u.MSFT_TEXTURE_DDS].source]:f=n.images[s.source];var l=f.uri,v=!1;return f.bufferView!==void 0&&(l=r.getDependency("bufferView",f.bufferView).then(function(d){v=!0;var h=new Blob([d],{type:f.mimeType});return l=i.createObjectURL(h),l})),Promise.resolve(l).then(function(d){var h=t.manager.getHandler(d);return h||(h=o[u.MSFT_TEXTURE_DDS]?r.extensions[u.MSFT_TEXTURE_DDS].ddsLoader:a),new Promise(function(y,_){h.load(de(d,t.path),y,void 0,_)})}).then(function(d){v===!0&&i.revokeObjectURL(l),d.flipY=!1,s.name&&(d.name=s.name),f.mimeType in fe&&(d.format=fe[f.mimeType]);var h=n.samplers||{},y=h[s.sampler]||{};return d.magFilter=re[y.magFilter]||c.LinearFilter,d.minFilter=re[y.minFilter]||c.LinearMipmapLinearFilter,d.wrapS=J[y.wrapS]||c.RepeatWrapping,d.wrapT=J[y.wrapT]||c.RepeatWrapping,r.associations.set(d,{type:"textures",index:e}),d})},I.prototype.assignTexture=function(e,r,n){var t=this;return this.getDependency("texture",n.index).then(function(a){if(!a.isCompressedTexture)switch(r){case"aoMap":case"emissiveMap":case"metalnessMap":case"normalMap":case"roughnessMap":a.format=c.RGBFormat;break}if(n.texCoord!==void 0&&n.texCoord!=0&&!(r==="aoMap"&&n.texCoord==1)&&console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+r+" not yet supported."),t.extensions[u.KHR_TEXTURE_TRANSFORM]){var i=n.extensions!==void 0?n.extensions[u.KHR_TEXTURE_TRANSFORM]:void 0;if(i){var s=this.associations.get(a);a=t.extensions[u.KHR_TEXTURE_TRANSFORM].extendTexture(a,i),this.associations.set(a,s)}}e[r]=a})},I.prototype.assignFinalMaterial=function(e){var r=e.geometry,n=e.material,t=r.attributes.tangent!==void 0,a=r.attributes.color!==void 0,i=r.attributes.normal===void 0,s=e.isSkinnedMesh===!0,o=Object.keys(r.morphAttributes).length>0,f=o&&r.morphAttributes.normal!==void 0;if(e.isPoints){var l="PointsMaterial:"+n.uuid,v=this.cache.get(l);v||(v=new c.PointsMaterial,c.Material.prototype.copy.call(v,n),v.color.copy(n.color),v.map=n.map,v.sizeAttenuation=!1,this.cache.add(l,v)),n=v}else if(e.isLine){var l="LineBasicMaterial:"+n.uuid,d=this.cache.get(l);d||(d=new c.LineBasicMaterial,c.Material.prototype.copy.call(d,n),d.color.copy(n.color),this.cache.add(l,d)),n=d}if(t||a||i||s||o){var l="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(l+="specular-glossiness:"),s&&(l+="skinning:"),t&&(l+="vertex-tangents:"),a&&(l+="vertex-colors:"),i&&(l+="flat-shading:"),o&&(l+="morph-targets:"),f&&(l+="morph-normals:");var h=this.cache.get(l);h||(h=n.clone(),s&&(h.skinning=!0),t&&(h.vertexTangents=!0),a&&(h.vertexColors=!0),i&&(h.flatShading=!0),o&&(h.morphTargets=!0),f&&(h.morphNormals=!0),this.cache.add(l,h),this.associations.set(h,this.associations.get(n))),n=h}n.aoMap&&r.attributes.uv2===void 0&&r.attributes.uv!==void 0&&r.setAttribute("uv2",r.attributes.uv),n.normalScale&&!t&&(n.normalScale.y=-n.normalScale.y),n.clearcoatNormalScale&&!t&&(n.clearcoatNormalScale.y=-n.clearcoatNormalScale.y),e.material=n},I.prototype.loadMaterial=function(e){var r=this,n=this.json,t=this.extensions,a=n.materials[e],i,s={},o=a.extensions||{},f=[];if(o[u.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){var l=t[u.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];i=l.getMaterialType(),f.push(l.extendParams(s,a,r))}else if(o[u.KHR_MATERIALS_UNLIT]){var v=t[u.KHR_MATERIALS_UNLIT];i=v.getMaterialType(),f.push(v.extendParams(s,a,r))}else{i=c.MeshStandardMaterial;var d=a.pbrMetallicRoughness||{};if(s.color=new c.Color(1,1,1),s.opacity=1,Array.isArray(d.baseColorFactor)){var h=d.baseColorFactor;s.color.fromArray(h),s.opacity=h[3]}d.baseColorTexture!==void 0&&f.push(r.assignTexture(s,"map",d.baseColorTexture)),s.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,s.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(f.push(r.assignTexture(s,"metalnessMap",d.metallicRoughnessTexture)),f.push(r.assignTexture(s,"roughnessMap",d.metallicRoughnessTexture)))}a.doubleSided===!0&&(s.side=c.DoubleSide);var y=a.alphaMode||ie.OPAQUE;if(y===ie.BLEND?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,y===ie.MASK&&(s.alphaTest=a.alphaCutoff!==void 0?a.alphaCutoff:.5)),a.normalTexture!==void 0&&i!==c.MeshBasicMaterial&&(f.push(r.assignTexture(s,"normalMap",a.normalTexture)),s.normalScale=new c.Vector2(1,1),a.normalTexture.scale!==void 0&&s.normalScale.set(a.normalTexture.scale,a.normalTexture.scale)),a.occlusionTexture!==void 0&&i!==c.MeshBasicMaterial&&(f.push(r.assignTexture(s,"aoMap",a.occlusionTexture)),a.occlusionTexture.strength!==void 0&&(s.aoMapIntensity=a.occlusionTexture.strength)),a.emissiveFactor!==void 0&&i!==c.MeshBasicMaterial&&(s.emissive=new c.Color().fromArray(a.emissiveFactor)),a.emissiveTexture!==void 0&&i!==c.MeshBasicMaterial&&f.push(r.assignTexture(s,"emissiveMap",a.emissiveTexture)),o[u.KHR_MATERIALS_CLEARCOAT]){var _=t[u.KHR_MATERIALS_CLEARCOAT];i=_.getMaterialType(),f.push(_.extendParams(s,{extensions:o},r))}if(o[u.KHR_MATERIALS_TRANSMISSION]){var _=t[u.KHR_MATERIALS_TRANSMISSION];i=_.getMaterialType(),f.push(_.extendParams(s,{extensions:o},r))}return Promise.all(f).then(function(){var S;return i===b?S=t[u.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(s):S=new i(s),a.name&&(S.name=a.name),S.map&&(S.map.encoding=c.sRGBEncoding),S.emissiveMap&&(S.emissiveMap.encoding=c.sRGBEncoding),Y(S,a),r.associations.set(S,{type:"materials",index:e}),a.extensions&&se(t,S,a),S})};function pe(e,r,n){var t=r.attributes,a=new c.Box3;if(t.POSITION!==void 0){var i=n.json.accessors[t.POSITION],s=i.min,o=i.max;if(s!==void 0&&o!==void 0)a.set(new c.Vector3(s[0],s[1],s[2]),new c.Vector3(o[0],o[1],o[2]));else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;var f=r.targets;if(f!==void 0){for(var l=new c.Vector3,v=new c.Vector3,d=0,h=f.length;d<h;d++){var y=f[d];if(y.POSITION!==void 0){var i=n.json.accessors[y.POSITION],s=i.min,o=i.max;s!==void 0&&o!==void 0?(v.setX(Math.max(Math.abs(s[0]),Math.abs(o[0]))),v.setY(Math.max(Math.abs(s[1]),Math.abs(o[1]))),v.setZ(Math.max(Math.abs(s[2]),Math.abs(o[2]))),l.max(v)):console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}a.expandByVector(l)}e.boundingBox=a;var _=new c.Sphere;a.getCenter(_.center),_.radius=a.min.distanceTo(a.max)/2,e.boundingSphere=_}function ue(e,r,n){var t=r.attributes,a=[];function i(l,v){return n.getDependency("accessor",l).then(function(d){e.setAttribute(v,d)})}for(var s in t){var o=j[s]||s.toLowerCase();o in e.attributes||a.push(i(t[s],o))}if(r.indices!==void 0&&!e.index){var f=n.getDependency("accessor",r.indices).then(function(l){e.setIndex(l)});a.push(f)}return Y(e,r),pe(e,r,n),Promise.all(a).then(function(){return r.targets!==void 0?Ae(e,r.targets,n):e})}function z(e,r){var n=e.getIndex();if(n===null){var t=[],a=e.getAttribute("position");if(a!==void 0){for(var i=0;i<a.count;i++)t.push(i);e.setIndex(t),n=e.getIndex()}else return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e}var s=n.count-2,o=[];if(r===c.TriangleFanDrawMode)for(var i=1;i<=s;i++)o.push(n.getX(0)),o.push(n.getX(i)),o.push(n.getX(i+1));else for(var i=0;i<s;i++)i%2===0?(o.push(n.getX(i)),o.push(n.getX(i+1)),o.push(n.getX(i+2))):(o.push(n.getX(i+2)),o.push(n.getX(i+1)),o.push(n.getX(i)));o.length/3!==s&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");var f=e.clone();return f.setIndex(o),f}return I.prototype.loadGeometries=function(e){var r=this,n=this.extensions,t=this.primitiveCache;function a(h){return n[u.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(h,r).then(function(y){return ue(y,h,r)})}for(var i=[],s=0,o=e.length;s<o;s++){var f=e[s],l=ye(f),v=t[l];if(v)i.push(v.promise);else{var d;f.extensions&&f.extensions[u.KHR_DRACO_MESH_COMPRESSION]?d=a(f):d=ue(new c.BufferGeometry,f,r),t[l]={primitive:f,promise:d},i.push(d)}}return Promise.all(i)},I.prototype.loadMesh=function(e){for(var r=this,n=this.json,t=n.meshes[e],a=t.primitives,i=[],s=0,o=a.length;s<o;s++){var f=a[s].material===void 0?me(this.cache):this.getDependency("material",a[s].material);i.push(f)}return i.push(r.loadGeometries(a)),Promise.all(i).then(function(l){for(var v=l.slice(0,l.length-1),d=l[l.length-1],h=[],y=0,_=d.length;y<_;y++){var S=d[y],R=a[y],E,F=v[y];if(R.mode===H.TRIANGLES||R.mode===H.TRIANGLE_STRIP||R.mode===H.TRIANGLE_FAN||R.mode===void 0)E=t.isSkinnedMesh===!0?new c.SkinnedMesh(S,F):new c.Mesh(S,F),E.isSkinnedMesh===!0&&!E.geometry.attributes.skinWeight.normalized&&E.normalizeSkinWeights(),R.mode===H.TRIANGLE_STRIP?E.geometry=z(E.geometry,c.TriangleStripDrawMode):R.mode===H.TRIANGLE_FAN&&(E.geometry=z(E.geometry,c.TriangleFanDrawMode));else if(R.mode===H.LINES)E=new c.LineSegments(S,F);else if(R.mode===H.LINE_STRIP)E=new c.Line(S,F);else if(R.mode===H.LINE_LOOP)E=new c.LineLoop(S,F);else if(R.mode===H.POINTS)E=new c.Points(S,F);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+R.mode);Object.keys(E.geometry.morphAttributes).length>0&&Se(E,t),E.name=t.name||"mesh_"+e,d.length>1&&(E.name+="_"+y),Y(E,t),r.assignFinalMaterial(E),h.push(E)}if(h.length===1)return h[0];for(var G=new c.Group,y=0,_=h.length;y<_;y++)G.add(h[y]);return G})},I.prototype.loadCamera=function(e){var r,n=this.json.cameras[e],t=n[n.type];if(!t){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?r=new c.PerspectiveCamera(c.MathUtils.radToDeg(t.yfov),t.aspectRatio||1,t.znear||1,t.zfar||2e6):n.type==="orthographic"&&(r=new c.OrthographicCamera(-t.xmag,t.xmag,t.ymag,-t.ymag,t.znear,t.zfar)),n.name&&(r.name=n.name),Y(r,n),Promise.resolve(r)},I.prototype.loadSkin=function(e){var r=this.json.skins[e],n={joints:r.joints};return r.inverseBindMatrices===void 0?Promise.resolve(n):this.getDependency("accessor",r.inverseBindMatrices).then(function(t){return n.inverseBindMatrices=t,n})},I.prototype.loadAnimation=function(e){for(var r=this.json,n=r.animations[e],t=[],a=[],i=[],s=[],o=[],f=0,l=n.channels.length;f<l;f++){var v=n.channels[f],d=n.samplers[v.sampler],h=v.target,y=h.node!==void 0?h.node:h.id,_=n.parameters!==void 0?n.parameters[d.input]:d.input,S=n.parameters!==void 0?n.parameters[d.output]:d.output;t.push(this.getDependency("node",y)),a.push(this.getDependency("accessor",_)),i.push(this.getDependency("accessor",S)),s.push(d),o.push(h)}return Promise.all([Promise.all(t),Promise.all(a),Promise.all(i),Promise.all(s),Promise.all(o)]).then(function(R){for(var E=R[0],F=R[1],G=R[2],te=R[3],ne=R[4],Q=[],B=0,oe=E.length;B<oe;B++){var k=E[B],Ee=F[B],ae=G[B],Le=te[B],_e=ne[B];if(k!==void 0){k.updateMatrix(),k.matrixAutoUpdate=!0;var he;switch(X[_e.path]){case X.weights:he=c.NumberKeyframeTrack;break;case X.rotation:he=c.QuaternionKeyframeTrack;break;case X.position:case X.scale:default:he=c.VectorKeyframeTrack;break}var Fe=k.name?k.name:k.uuid,De=Le.interpolation!==void 0?ge[Le.interpolation]:c.InterpolateLinear,ve=[];X[_e.path]===X.weights?k.traverse(function(ce){ce.isMesh===!0&&ce.morphTargetInfluences&&ve.push(ce.name?ce.name:ce.uuid)}):ve.push(Fe);var q=ae.array;if(ae.normalized){var le;if(q.constructor===Int8Array)le=1/127;else if(q.constructor===Uint8Array)le=1/255;else if(q.constructor==Int16Array)le=1/32767;else if(q.constructor===Uint16Array)le=1/65535;else throw new Error("THREE.GLTFLoader: Unsupported output accessor component type.");for(var Ie=new Float32Array(q.length),Z=0,Re=q.length;Z<Re;Z++)Ie[Z]=q[Z]*le;q=Ie}for(var Z=0,Re=ve.length;Z<Re;Z++){var Me=new he(ve[Z]+"."+X[_e.path],Ee.array,q,De);Le.interpolation==="CUBICSPLINE"&&(Me.createInterpolant=function(Ue){return new P(this.times,this.values,this.getValueSize()/3,Ue)},Me.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),Q.push(Me)}}}var Pe=n.name?n.name:"animation_"+e;return new c.AnimationClip(Pe,void 0,Q)})},I.prototype.loadNode=function(e){var r=this.json,n=this.extensions,t=this,a=r.meshReferences,i=r.meshUses,s=r.nodes[e];return function(){var o=[];return s.mesh!==void 0&&o.push(t.getDependency("mesh",s.mesh).then(function(f){var l;if(a[s.mesh]>1){var v=i[s.mesh]++;l=f.clone(),l.name+="_instance_"+v}else l=f;return s.weights!==void 0&&l.traverse(function(d){if(d.isMesh)for(var h=0,y=s.weights.length;h<y;h++)d.morphTargetInfluences[h]=s.weights[h]}),l})),s.camera!==void 0&&o.push(t.getDependency("camera",s.camera)),s.extensions&&s.extensions[u.KHR_LIGHTS_PUNCTUAL]&&s.extensions[u.KHR_LIGHTS_PUNCTUAL].light!==void 0&&o.push(t.getDependency("light",s.extensions[u.KHR_LIGHTS_PUNCTUAL].light)),Promise.all(o)}().then(function(o){var f;if(s.isBone===!0?f=new c.Bone:o.length>1?f=new c.Group:o.length===1?f=o[0]:f=new c.Object3D,f!==o[0])for(var l=0,v=o.length;l<v;l++)f.add(o[l]);if(s.name&&(f.userData.name=s.name,f.name=c.PropertyBinding.sanitizeNodeName(s.name)),Y(f,s),s.extensions&&se(n,f,s),s.matrix!==void 0){var d=new c.Matrix4;d.fromArray(s.matrix),f.applyMatrix4(d)}else s.translation!==void 0&&f.position.fromArray(s.translation),s.rotation!==void 0&&f.quaternion.fromArray(s.rotation),s.scale!==void 0&&f.scale.fromArray(s.scale);return t.associations.set(f,{type:"nodes",index:e}),f})},I.prototype.loadScene=function(){function e(r,n,t,a){var i=t.nodes[r];return a.getDependency("node",r).then(function(s){if(i.skin===void 0)return s;var o;return a.getDependency("skin",i.skin).then(function(f){o=f;for(var l=[],v=0,d=o.joints.length;v<d;v++)l.push(a.getDependency("node",o.joints[v]));return Promise.all(l)}).then(function(f){return s.traverse(function(l){if(l.isMesh){for(var v=[],d=[],h=0,y=f.length;h<y;h++){var _=f[h];if(_){v.push(_);var S=new c.Matrix4;o.inverseBindMatrices!==void 0&&S.fromArray(o.inverseBindMatrices.array,h*16),d.push(S)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',o.joints[h])}l.bind(new c.Skeleton(v,d),l.matrixWorld)}}),s})}).then(function(s){n.add(s);var o=[];if(i.children)for(var f=i.children,l=0,v=f.length;l<v;l++){var d=f[l];o.push(e(d,s,t,a))}return Promise.all(o)})}return function(n){var t=this.json,a=this.extensions,i=this.json.scenes[n],s=this,o=new c.Group;i.name&&(o.name=i.name),Y(o,i),i.extensions&&se(a,o,i);for(var f=i.nodes||[],l=[],v=0,d=f.length;v<d;v++)l.push(e(f[v],o,t,s));return Promise.all(l).then(function(){return o})}}(),p}(),K=function(p){c.Loader.call(this,p),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}};K.prototype=Object.assign(Object.create(c.Loader.prototype),{constructor:K,setDecoderPath:function(p){return this.decoderPath=p,this},setDecoderConfig:function(p){return this.decoderConfig=p,this},setWorkerLimit:function(p){return this.workerLimit=p,this},setVerbosity:function(){console.warn("THREE.DRACOLoader: The .setVerbosity() method has been removed.")},setDrawMode:function(){console.warn("THREE.DRACOLoader: The .setDrawMode() method has been removed.")},setSkipDequantization:function(){console.warn("THREE.DRACOLoader: The .setSkipDequantization() method has been removed.")},load:function(p,T,u,m){var g=new c.FileLoader(this.manager);g.setPath(this.path),g.setResponseType("arraybuffer"),this.crossOrigin==="use-credentials"&&g.setWithCredentials(!0),g.load(p,A=>{var L={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(A,L).then(T).catch(m)},u,m)},decodeDracoFile:function(p,T,u,m){var g={attributeIDs:u||this.defaultAttributeIDs,attributeTypes:m||this.defaultAttributeTypes,useUniqueIDs:!!u};this.decodeGeometry(p,g).then(T)},decodeGeometry:function(p,T){for(var u in T.attributeTypes){var m=T.attributeTypes[u];m.BYTES_PER_ELEMENT!==void 0&&(T.attributeTypes[u]=m.name)}var g=JSON.stringify(T);if(K.taskCache.has(p)){var A=K.taskCache.get(p);if(A.key===g)return A.promise;if(p.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}var L,O=this.workerNextTaskID++,D=p.byteLength,M=this._getWorker(O,D).then(C=>(L=C,new Promise((N,x)=>{L._callbacks[O]={resolve:N,reject:x},L.postMessage({type:"decode",id:O,taskConfig:T,buffer:p},[p])}))).then(C=>this._createGeometry(C.geometry));return M.catch(()=>!0).then(()=>{L&&O&&this._releaseTask(L,O)}),K.taskCache.set(p,{key:g,promise:M}),M},_createGeometry:function(p){var T=new c.BufferGeometry;p.index&&T.setIndex(new c.BufferAttribute(p.index.array,1));for(var u=0;u<p.attributes.length;u++){var m=p.attributes[u],g=m.name,A=m.array,L=m.itemSize;T.setAttribute(g,new c.BufferAttribute(A,L))}return T},_loadLibrary:function(p,T){var u=new c.FileLoader(this.manager);return u.setPath(this.decoderPath),u.setResponseType(T),new Promise((m,g)=>{u.load(p,m,void 0,g)})},preload:function(){return this._initDecoder(),this},_initDecoder:function(){if(this.decoderPending)return this.decoderPending;var p=typeof WebAssembly!="object"||this.decoderConfig.type==="js",T=[];return p?T.push(this._loadLibrary("draco_decoder.js","text")):(T.push(this._loadLibrary("draco_wasm_wrapper.js","text")),T.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(T).then(u=>{var m=u[0];p||(this.decoderConfig.wasmBinary=u[1]);var g=K.DRACOWorker.toString(),A=["/* draco decoder */",m,"","/* worker */",g.substring(g.indexOf("{")+1,g.lastIndexOf("}"))].join(`
|
|
261
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([A]))}),this.decoderPending},_getWorker:function(p,T){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){var u=new Worker(this.workerSourceURL);u._callbacks={},u._taskCosts={},u._taskLoad=0,u.postMessage({type:"init",decoderConfig:this.decoderConfig}),u.onmessage=function(g){var A=g.data;switch(A.type){case"decode":u._callbacks[A.id].resolve(A);break;case"error":u._callbacks[A.id].reject(A);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+A.type+'"')}},this.workerPool.push(u)}else this.workerPool.sort(function(m,g){return m._taskLoad>g._taskLoad?-1:1});var u=this.workerPool[this.workerPool.length-1];return u._taskCosts[p]=T,u._taskLoad+=T,u})},_releaseTask:function(p,T){p._taskLoad-=p._taskCosts[T],delete p._callbacks[T],delete p._taskCosts[T]},debug:function(){console.log("Task load: ",this.workerPool.map(p=>p._taskLoad))},dispose:function(){for(var p=0;p<this.workerPool.length;++p)this.workerPool[p].terminate();return this.workerPool.length=0,this}});K.DRACOWorker=function(){var p,T;onmessage=function(g){var A=g.data;switch(A.type){case"init":p=A.decoderConfig,T=new Promise(function(D){p.onModuleLoaded=function(M){D({draco:M})},DracoDecoderModule(p)});break;case"decode":var L=A.buffer,O=A.taskConfig;T.then(D=>{var M=D.draco,C=new M.Decoder,N=new M.DecoderBuffer;N.Init(new Int8Array(L),L.byteLength);try{var x=u(M,C,N,O),w=x.attributes.map(b=>b.array.buffer);x.index&&w.push(x.index.array.buffer),self.postMessage({type:"decode",id:A.id,geometry:x},w)}catch(b){console.error(b),self.postMessage({type:"error",id:A.id,error:b.message})}finally{M.destroy(N),M.destroy(C)}});break}};function u(g,A,L,O){var D=O.attributeIDs,M=O.attributeTypes,C,N,x=A.GetEncodedGeometryType(L);if(x===g.TRIANGULAR_MESH)C=new g.Mesh,N=A.DecodeBufferToMesh(L,C);else if(x===g.POINT_CLOUD)C=new g.PointCloud,N=A.DecodeBufferToPointCloud(L,C);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!N.ok()||C.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+N.error_msg());var w={index:null,attributes:[]};for(var b in D){var V=self[M[b]],$,P;if(O.useUniqueIDs)P=D[b],$=A.GetAttributeByUniqueId(C,P);else{if(P=A.GetAttributeId(C,g[D[b]]),P===-1)continue;$=A.GetAttribute(C,P)}w.attributes.push(m(g,A,C,b,V,$))}if(x===g.TRIANGULAR_MESH){for(var H=C.num_faces(),ee=H*3,re=new Uint32Array(ee),J=new g.DracoInt32Array,W=0;W<H;++W){A.GetFaceFromMesh(C,W,J);for(var j=0;j<3;++j)re[W*3+j]=J.GetValue(j)}w.index={array:re,itemSize:1},g.destroy(J)}return g.destroy(C),w}function m(g,A,L,O,D,M){var C=M.num_components(),N=L.num_points(),x=N*C,w,b;switch(D){case Float32Array:w=new g.DracoFloat32Array,A.GetAttributeFloatForAllPoints(L,M,w),b=new Float32Array(x);break;case Int8Array:w=new g.DracoInt8Array,A.GetAttributeInt8ForAllPoints(L,M,w),b=new Int8Array(x);break;case Int16Array:w=new g.DracoInt16Array,A.GetAttributeInt16ForAllPoints(L,M,w),b=new Int16Array(x);break;case Int32Array:w=new g.DracoInt32Array,A.GetAttributeInt32ForAllPoints(L,M,w),b=new Int32Array(x);break;case Uint8Array:w=new g.DracoUInt8Array,A.GetAttributeUInt8ForAllPoints(L,M,w),b=new Uint8Array(x);break;case Uint16Array:w=new g.DracoUInt16Array,A.GetAttributeUInt16ForAllPoints(L,M,w),b=new Uint16Array(x);break;case Uint32Array:w=new g.DracoUInt32Array,A.GetAttributeUInt32ForAllPoints(L,M,w),b=new Uint32Array(x);break;default:throw new Error("THREE.DRACOLoader: Unexpected attribute type.")}for(var V=0;V<x;V++)b[V]=w.GetValue(V);return g.destroy(w),{name:O,array:b,itemSize:C}}};K.taskCache=new WeakMap;K.setDecoderPath=function(){console.warn("THREE.DRACOLoader: The .setDecoderPath() method has been removed. Use instance methods.")};K.setDecoderConfig=function(){console.warn("THREE.DRACOLoader: The .setDecoderConfig() method has been removed. Use instance methods.")};K.releaseDecoderModule=function(){console.warn("THREE.DRACOLoader: The .releaseDecoderModule() method has been removed. Use instance methods.")};K.getDecoderModule=function(){console.warn("THREE.DRACOLoader: The .getDecoderModule() method has been removed. Use instance methods.")};var Te=function(p){c.CompressedTextureLoader.call(this,p)};Te.prototype=Object.assign(Object.create(c.CompressedTextureLoader.prototype),{constructor:Te,parse:function(p,T){var u={mipmaps:[],width:0,height:0,format:null,mipmapCount:1},m=542327876,g=131072,A=512,L=1024,O=2048,D=4096,M=8192,C=16384,N=32768,x=4;function w(l){return l.charCodeAt(0)+(l.charCodeAt(1)<<8)+(l.charCodeAt(2)<<16)+(l.charCodeAt(3)<<24)}function b(l){return String.fromCharCode(l&255,l>>8&255,l>>16&255,l>>24&255)}function V(l,v,d,h){for(var y=d*h*4,_=new Uint8Array(l,v,y),S=new Uint8Array(y),R=0,E=0,F=0;F<h;F++)for(var G=0;G<d;G++){var te=_[E];E++;var ne=_[E];E++;var Q=_[E];E++;var B=_[E];E++,S[R]=Q,R++,S[R]=ne,R++,S[R]=te,R++,S[R]=B,R++}return S}var $=w("DXT1"),P=w("DXT3"),H=w("DXT5"),ee=w("ETC1"),re=31,J=0,W=1,j=2,X=3,ge=4,ie=7,fe=20,de=21,me=22,se=23,Y=24,Ae=25,Se=26,ye=28,U=new Int32Array(p,0,re);if(U[J]!==m)return console.error("THREE.DDSLoader.parse: Invalid magic number in DDS header."),u;if(!U[fe]&x)return console.error("THREE.DDSLoader.parse: Unsupported format, must contain a FourCC code."),u;var I,pe=U[de],ue=!1;switch(pe){case $:I=8,u.format=c.RGB_S3TC_DXT1_Format;break;case P:I=16,u.format=c.RGBA_S3TC_DXT3_Format;break;case H:I=16,u.format=c.RGBA_S3TC_DXT5_Format;break;case ee:I=8,u.format=c.RGB_ETC1_Format;break;default:if(U[me]===32&&U[se]&16711680&&U[Y]&65280&&U[Ae]&255&&U[Se]&4278190080)ue=!0,I=64,u.format=c.RGBAFormat;else return console.error("THREE.DDSLoader.parse: Unsupported FourCC code ",b(pe)),u}u.mipmapCount=1,U[j]&g&&T!==!1&&(u.mipmapCount=Math.max(1,U[ie]));var z=U[ye];if(u.isCubemap=!!(z&A),u.isCubemap&&(!(z&L)||!(z&O)||!(z&D)||!(z&M)||!(z&C)||!(z&N)))return console.error("THREE.DDSLoader.parse: Incomplete cubemap faces"),u;u.width=U[ge],u.height=U[X];for(var e=U[W]+4,r=u.isCubemap?6:1,n=0;n<r;n++)for(var t=u.width,a=u.height,i=0;i<u.mipmapCount;i++){if(ue)var s=V(p,e,t,a),o=s.length;else var o=Math.max(4,t)/4*Math.max(4,a)/4*I,s=new Uint8Array(p,e,o);var f={data:s,width:t,height:a};u.mipmaps.push(f),e+=o,t=Math.max(t>>1,1),a=Math.max(a>>1,1)}return u}});var Ce=function(p){xe(T,p);function T(u){var m=p.call(this)||this;return m.needsRender=!0,u&&u.children.length&&m.add.apply(m,u.children),m.mixer=new we.AnimationMixer(m),m}return T.prototype.clone=function(){var u=p.prototype.clone.call(this,!0),m=new we.AnimationMixer(u);return u.mixer=m,u.needsRender=!0,u},T}(we.Group),Ne="https://vr-public.realsee-cdn.cn/release/static/image/release/five/resource/draco/1.5.6/",ke=function(p){xe(T,p);function T(u){var m=p.call(this,u)||this;return m.ddsLoader=new Te(u),m.dracoLoader=new K(u),m.dracoLoader.setDecoderPath(Ne),m}return Object.defineProperty(T,"version",{get:function(){return"6.0.0-alpha.
|
|
261
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([A]))}),this.decoderPending},_getWorker:function(p,T){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){var u=new Worker(this.workerSourceURL);u._callbacks={},u._taskCosts={},u._taskLoad=0,u.postMessage({type:"init",decoderConfig:this.decoderConfig}),u.onmessage=function(g){var A=g.data;switch(A.type){case"decode":u._callbacks[A.id].resolve(A);break;case"error":u._callbacks[A.id].reject(A);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+A.type+'"')}},this.workerPool.push(u)}else this.workerPool.sort(function(m,g){return m._taskLoad>g._taskLoad?-1:1});var u=this.workerPool[this.workerPool.length-1];return u._taskCosts[p]=T,u._taskLoad+=T,u})},_releaseTask:function(p,T){p._taskLoad-=p._taskCosts[T],delete p._callbacks[T],delete p._taskCosts[T]},debug:function(){console.log("Task load: ",this.workerPool.map(p=>p._taskLoad))},dispose:function(){for(var p=0;p<this.workerPool.length;++p)this.workerPool[p].terminate();return this.workerPool.length=0,this}});K.DRACOWorker=function(){var p,T;onmessage=function(g){var A=g.data;switch(A.type){case"init":p=A.decoderConfig,T=new Promise(function(D){p.onModuleLoaded=function(M){D({draco:M})},DracoDecoderModule(p)});break;case"decode":var L=A.buffer,O=A.taskConfig;T.then(D=>{var M=D.draco,C=new M.Decoder,N=new M.DecoderBuffer;N.Init(new Int8Array(L),L.byteLength);try{var x=u(M,C,N,O),w=x.attributes.map(b=>b.array.buffer);x.index&&w.push(x.index.array.buffer),self.postMessage({type:"decode",id:A.id,geometry:x},w)}catch(b){console.error(b),self.postMessage({type:"error",id:A.id,error:b.message})}finally{M.destroy(N),M.destroy(C)}});break}};function u(g,A,L,O){var D=O.attributeIDs,M=O.attributeTypes,C,N,x=A.GetEncodedGeometryType(L);if(x===g.TRIANGULAR_MESH)C=new g.Mesh,N=A.DecodeBufferToMesh(L,C);else if(x===g.POINT_CLOUD)C=new g.PointCloud,N=A.DecodeBufferToPointCloud(L,C);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!N.ok()||C.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+N.error_msg());var w={index:null,attributes:[]};for(var b in D){var V=self[M[b]],$,P;if(O.useUniqueIDs)P=D[b],$=A.GetAttributeByUniqueId(C,P);else{if(P=A.GetAttributeId(C,g[D[b]]),P===-1)continue;$=A.GetAttribute(C,P)}w.attributes.push(m(g,A,C,b,V,$))}if(x===g.TRIANGULAR_MESH){for(var H=C.num_faces(),ee=H*3,re=new Uint32Array(ee),J=new g.DracoInt32Array,W=0;W<H;++W){A.GetFaceFromMesh(C,W,J);for(var j=0;j<3;++j)re[W*3+j]=J.GetValue(j)}w.index={array:re,itemSize:1},g.destroy(J)}return g.destroy(C),w}function m(g,A,L,O,D,M){var C=M.num_components(),N=L.num_points(),x=N*C,w,b;switch(D){case Float32Array:w=new g.DracoFloat32Array,A.GetAttributeFloatForAllPoints(L,M,w),b=new Float32Array(x);break;case Int8Array:w=new g.DracoInt8Array,A.GetAttributeInt8ForAllPoints(L,M,w),b=new Int8Array(x);break;case Int16Array:w=new g.DracoInt16Array,A.GetAttributeInt16ForAllPoints(L,M,w),b=new Int16Array(x);break;case Int32Array:w=new g.DracoInt32Array,A.GetAttributeInt32ForAllPoints(L,M,w),b=new Int32Array(x);break;case Uint8Array:w=new g.DracoUInt8Array,A.GetAttributeUInt8ForAllPoints(L,M,w),b=new Uint8Array(x);break;case Uint16Array:w=new g.DracoUInt16Array,A.GetAttributeUInt16ForAllPoints(L,M,w),b=new Uint16Array(x);break;case Uint32Array:w=new g.DracoUInt32Array,A.GetAttributeUInt32ForAllPoints(L,M,w),b=new Uint32Array(x);break;default:throw new Error("THREE.DRACOLoader: Unexpected attribute type.")}for(var V=0;V<x;V++)b[V]=w.GetValue(V);return g.destroy(w),{name:O,array:b,itemSize:C}}};K.taskCache=new WeakMap;K.setDecoderPath=function(){console.warn("THREE.DRACOLoader: The .setDecoderPath() method has been removed. Use instance methods.")};K.setDecoderConfig=function(){console.warn("THREE.DRACOLoader: The .setDecoderConfig() method has been removed. Use instance methods.")};K.releaseDecoderModule=function(){console.warn("THREE.DRACOLoader: The .releaseDecoderModule() method has been removed. Use instance methods.")};K.getDecoderModule=function(){console.warn("THREE.DRACOLoader: The .getDecoderModule() method has been removed. Use instance methods.")};var Te=function(p){c.CompressedTextureLoader.call(this,p)};Te.prototype=Object.assign(Object.create(c.CompressedTextureLoader.prototype),{constructor:Te,parse:function(p,T){var u={mipmaps:[],width:0,height:0,format:null,mipmapCount:1},m=542327876,g=131072,A=512,L=1024,O=2048,D=4096,M=8192,C=16384,N=32768,x=4;function w(l){return l.charCodeAt(0)+(l.charCodeAt(1)<<8)+(l.charCodeAt(2)<<16)+(l.charCodeAt(3)<<24)}function b(l){return String.fromCharCode(l&255,l>>8&255,l>>16&255,l>>24&255)}function V(l,v,d,h){for(var y=d*h*4,_=new Uint8Array(l,v,y),S=new Uint8Array(y),R=0,E=0,F=0;F<h;F++)for(var G=0;G<d;G++){var te=_[E];E++;var ne=_[E];E++;var Q=_[E];E++;var B=_[E];E++,S[R]=Q,R++,S[R]=ne,R++,S[R]=te,R++,S[R]=B,R++}return S}var $=w("DXT1"),P=w("DXT3"),H=w("DXT5"),ee=w("ETC1"),re=31,J=0,W=1,j=2,X=3,ge=4,ie=7,fe=20,de=21,me=22,se=23,Y=24,Ae=25,Se=26,ye=28,U=new Int32Array(p,0,re);if(U[J]!==m)return console.error("THREE.DDSLoader.parse: Invalid magic number in DDS header."),u;if(!U[fe]&x)return console.error("THREE.DDSLoader.parse: Unsupported format, must contain a FourCC code."),u;var I,pe=U[de],ue=!1;switch(pe){case $:I=8,u.format=c.RGB_S3TC_DXT1_Format;break;case P:I=16,u.format=c.RGBA_S3TC_DXT3_Format;break;case H:I=16,u.format=c.RGBA_S3TC_DXT5_Format;break;case ee:I=8,u.format=c.RGB_ETC1_Format;break;default:if(U[me]===32&&U[se]&16711680&&U[Y]&65280&&U[Ae]&255&&U[Se]&4278190080)ue=!0,I=64,u.format=c.RGBAFormat;else return console.error("THREE.DDSLoader.parse: Unsupported FourCC code ",b(pe)),u}u.mipmapCount=1,U[j]&g&&T!==!1&&(u.mipmapCount=Math.max(1,U[ie]));var z=U[ye];if(u.isCubemap=!!(z&A),u.isCubemap&&(!(z&L)||!(z&O)||!(z&D)||!(z&M)||!(z&C)||!(z&N)))return console.error("THREE.DDSLoader.parse: Incomplete cubemap faces"),u;u.width=U[ge],u.height=U[X];for(var e=U[W]+4,r=u.isCubemap?6:1,n=0;n<r;n++)for(var t=u.width,a=u.height,i=0;i<u.mipmapCount;i++){if(ue)var s=V(p,e,t,a),o=s.length;else var o=Math.max(4,t)/4*Math.max(4,a)/4*I,s=new Uint8Array(p,e,o);var f={data:s,width:t,height:a};u.mipmaps.push(f),e+=o,t=Math.max(t>>1,1),a=Math.max(a>>1,1)}return u}});var Ce=function(p){xe(T,p);function T(u){var m=p.call(this)||this;return m.needsRender=!0,u&&u.children.length&&m.add.apply(m,u.children),m.mixer=new we.AnimationMixer(m),m}return T.prototype.clone=function(){var u=p.prototype.clone.call(this,!0),m=new we.AnimationMixer(u);return u.mixer=m,u.needsRender=!0,u},T}(we.Group),Ne="https://vr-public.realsee-cdn.cn/release/static/image/release/five/resource/draco/1.5.6/",ke=function(p){xe(T,p);function T(u){var m=p.call(this,u)||this;return m.ddsLoader=new Te(u),m.dracoLoader=new K(u),m.dracoLoader.setDecoderPath(Ne),m}return Object.defineProperty(T,"version",{get:function(){return"6.0.0-alpha.75"},enumerable:!1,configurable:!0}),T.prototype.load=function(u,m,g,A){return p.prototype.load.call(this,u,m,g,A)},T.prototype.parse=function(u,m,g,A){return p.prototype.parse.call(this,u,m,function(L){var O=new Ce(L.scene),D=L.scenes.map(function(M){return M===L.scene?O:new Ce(M)});g(Object.assign(L,{scene:O,scenes:D}))},A)},T}(Oe);exports.DDSLoader=Te;exports.DRACOLoader=K;exports.GLTFLoader=ke;exports.GLTFObject=Ce;exports.THREEGLTFLoader=Oe;
|
package/gltf-loader/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
3
|
* @realsee/five
|
|
4
|
-
* Generated:
|
|
5
|
-
* Version: 6.0.0-alpha.
|
|
4
|
+
* Generated: 1/3/2024
|
|
5
|
+
* Version: 6.0.0-alpha.75
|
|
6
6
|
* Terms:
|
|
7
7
|
* Realsee SDK License Agreement
|
|
8
8
|
* Update: July 28, 2021
|
|
@@ -1683,7 +1683,7 @@ var Je = (
|
|
|
1683
1683
|
}
|
|
1684
1684
|
return Object.defineProperty(T, "version", {
|
|
1685
1685
|
get: function() {
|
|
1686
|
-
return "6.0.0-alpha.
|
|
1686
|
+
return "6.0.0-alpha.75";
|
|
1687
1687
|
},
|
|
1688
1688
|
enumerable: !1,
|
|
1689
1689
|
configurable: !0
|
package/line/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
3
|
* @realsee/five
|
|
4
|
-
* Generated:
|
|
5
|
-
* Version: 6.0.0-alpha.
|
|
4
|
+
* Generated: 1/3/2024
|
|
5
|
+
* Version: 6.0.0-alpha.75
|
|
6
6
|
* Terms:
|
|
7
7
|
* Realsee SDK License Agreement
|
|
8
8
|
* Update: July 28, 2021
|
|
@@ -451,4 +451,4 @@
|
|
|
451
451
|
#include <premultiplied_alpha_fragment>
|
|
452
452
|
|
|
453
453
|
}
|
|
454
|
-
`},g=function(a){y(r,a);function r(t){var n=a.call(this,{uniforms:o.UniformsUtils.clone(B.uniforms),vertexShader:B.vertexShader,fragmentShader:B.fragmentShader,clipping:!0})||this;return n.type="LineMaterial",n.dashed=!1,Object.defineProperties(n,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth.value=e}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}}}),n.setValues(t),n}return r}(o.ShaderMaterial);Object.assign(g.prototype,{isLineMaterial:!0});var M=function(a){y(r,a);function r(t,n){var e=a.call(this)||this;return e.type="LineSegments2",e.geometry=t!==void 0?t:new A,e.material=n!==void 0?n:new g({color:Math.random()*16777215}),e}return r.prototype.computeLineDistances=function(){for(var t=this.geometry,n=t.attributes.instanceStart,e=t.attributes.instanceEnd,i=new Float32Array(2*n.count),s=new o.Vector3,c=new o.Vector3,p=0,u=0,S=n.count;p<S;p++,u+=2)s.fromBufferAttribute(n,p),c.fromBufferAttribute(e,p),i[u]=u===0?0:i[u-1],i[u+1]=i[u]+s.distanceTo(c);var h=new o.InstancedInterleavedBuffer(i,2,1);return t.setAttribute("instanceDistanceStart",new o.InterleavedBufferAttribute(h,1,0)),t.setAttribute("instanceDistanceEnd",new o.InterleavedBufferAttribute(h,1,1)),this},r.prototype.raycast=function(t,n){t.camera===null&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.');var e=t.ray,i=t.camera,s=i.projectionMatrix,c=this.geometry,p=this.material,u=p.resolution,S=p.linewidth,h=c.attributes.instanceStart,U=c.attributes.instanceEnd,l=new o.Vector4,f=new o.Vector4,v=new o.Vector4,b=new o.Vector3,w=new o.Matrix4,d=new o.Line3,z=new o.Vector3;e.at(1,v),v.w=1,v.applyMatrix4(i.matrixWorldInverse),v.applyMatrix4(s),v.multiplyScalar(1/v.w),v.x*=u.x/2,v.y*=u.y/2,v.z=0,b.copy(v);var x=this.matrixWorld;w.multiplyMatrices(i.matrixWorldInverse,x);for(var m=0,N=h.count;m<N;m++){l.fromBufferAttribute(h,m),f.fromBufferAttribute(U,m),l.w=1,f.w=1,l.applyMatrix4(w),f.applyMatrix4(w),l.applyMatrix4(s),f.applyMatrix4(s),l.multiplyScalar(1/l.w),f.multiplyScalar(1/f.w);var j=l.z<-1&&f.z<-1,G=l.z>1&&f.z>1;if(!(j||G)){l.x*=u.x/2,l.y*=u.y/2,f.x*=u.x/2,f.y*=u.y/2,d.start.copy(l),d.start.z=0,d.end.copy(f),d.end.z=0;var D=d.closestPointToPointParameter(b,!0);d.at(D,z);var O=o.MathUtils.lerp(l.z,f.z,D),W=O>=-1&&O<=1,T=b.distanceTo(z)<S*.5;if(W&&T){d.start.fromBufferAttribute(h,m),d.end.fromBufferAttribute(U,m),d.start.applyMatrix4(x),d.end.applyMatrix4(x);var V=new o.Vector3,E=new o.Vector3;e.distanceSqToSegment(d.start,d.end,E,V),n.push({point:E,pointOnLine:V,distance:e.origin.distanceTo(E),object:this,faceIndex:m})}}}},r}(o.Mesh);Object.assign(M.prototype,{isLineSegments2:!0});var C=function(a){y(r,a);function r(t,n){var e=a.call(this,t,n)||this;return e.type="Line2",e}return r}(M);Object.assign(C.prototype,{isLine2:!0});var P=function(a){y(r,a);function r(){var t=a.call(this)||this;return t.type="LineGeometry",t}return r.prototype.setPositions=function(t){for(var n=t.length-3,e=new Float32Array(2*n),i=0;i<n;i+=3)e[2*i]=t[i],e[2*i+1]=t[i+1],e[2*i+2]=t[i+2],e[2*i+3]=t[i+3],e[2*i+4]=t[i+4],e[2*i+5]=t[i+5];return a.prototype.setPositions.call(this,e),this},r.prototype.setColors=function(t){for(var n=t.length-3,e=new Float32Array(2*n),i=0;i<n;i+=3)e[2*i]=t[i],e[2*i+1]=t[i+1],e[2*i+2]=t[i+2],e[2*i+3]=t[i+3],e[2*i+4]=t[i+4],e[2*i+5]=t[i+5];return a.prototype.setColors.call(this,e),this},r.prototype.fromLine=function(t){var n=t.geometry;if(n instanceof o.Geometry){var e=new o.BufferGeometry().fromGeometry(n);this.setPositions(e.attributes.position.array)}else n instanceof o.BufferGeometry&&this.setPositions(n.attributes.position.array);return this},r.prototype.copy=function(){return this},r}(A);Object.assign(P.prototype,{isLineGeometry:!0});var k="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sHDgwCEMBJZu0AAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAABM5JREFUWMO1V0tPG2cUPZ4Hxh6DazIOrjFNqJs0FIMqWFgWQkatsmvVbtggKlSVRVf5AWz4AWz4AUSKEChll19QJYSXkECuhFxsHjEhxCYm+DWGMZ5HF72DJq4bAzFXurI0M/I5997v3u9cC65vTJVn2lX/xHINQOYSBLTLEuIuCWw4Z3IGAEvf6ASmVHjNzHCXBG4A0AjACsAOwEbO0nsFQBnAGYASAIl+ZRMR7SolMEdsByD09fV5R0ZGgg8ePPjW5/N1iqLYpuu6RZblciKR2I9Go69evnwZnZ+fjwI4IS8AKBIRzeQfJWCANwKwh0KhtrGxsYehUOin1tbW+zzP23ietzY2NnIAoGmaLsuyUiqVyvl8XtrY2NiamZn589mzZxsAUgCOAeQAnFI2tI+VxIjaAeDzoaGh7xYWFuZOTk6OZVk+12uYqqq6JEnn0Wg0OT4+/geAXwGEAdwDIFJQXC1wO4DWR48e/RCPxxclSSroVzRFUbSDg4P848ePFwH8DuAhkWih83TRQWxFOXgAwvDwcOfo6OhvXV1d39tsNtuVBwTDWBwOh1UUxVsMw1hXVlbSdCgNV43uYSvrHg6H24aHh38eHBz85TrgF9FYLHA4HLzH43FvbW2d7u/vG+dANp8FpqIlbd3d3V8Fg8EfBUFw4BONZVmL3+9vHhkZCQL4AoAHgJPK8G+yzC0XDofdoVAo5PP5vkadTBAEtr+/39ff3x8gAp/RPOEqx2qjx+NpvXv3bk9DQ0NDvQgwDIOWlhZrMBj8kgi0UJdxRgYMArzL5XJ7vd57qLPZ7Xamp6fnNgBXtQxcjFuHw+Hyer3t9SYgCAITCAScAJoBNNEY/08GOFVVrfVMv7kMNDntFD1vjIAPrlRN0xjckOm6biFQ3jwNPwDMZrOnqVTqfb3Bi8Wivru7W/VCYkwPlKOjo0IikXh7EwQikYgE4Nw0CfXKDCipVCoTj8df3QABbW1tLUc6oUgkFPMkVACUNjc337148eKvw8PDbJ2jP1taWkoCyNDVXDSECmNSK4qiKNLq6urW8+fPI/UicHx8rD59+jSVy+WOAKSJhKENwFItLtoxk8mwsixzHR0dHe3t7c5PAU+n09rs7OzJkydPYqVSaQfANoDXALIk31S2smU1TWMPDg7K5XKZ7+3t9TudTut1U7+wsFCcmJiIpdPpbQBxADsAknQWymYCOukBHYCuKApisdhpMpnURFEU79y503TVyKenpzOTk5M7e3t7MQKPV0Zv1gNm+awB0MvlshqLxfLb29uyJElWURSbXC4XXyvqxcXFs6mpqeTc3Nzu3t7e3wQcA7BPZ8Cov1pNlJplmQtAG8MwHV6v95tAINA5MDBwPxAIuLu6upr8fr/VAN3c3JQjkcjZ+vp6fnl5+d2bN29SuVzuNYAEpf01CdRChUL+X1VskHACuA3Ay3Fcu9vt7nA6nZ7m5uYWQRCaNE3jVVW15PP580KhIGUymWw2m00DOAJwSP4WwPtq4LX2Ao6USxNlQyS/RcQcdLGwlNIz6vEMAaZpNzCk2Pll94LK/cDYimxERiBwG10sxjgvEZBE0UpE6vxj+0Ct5bTaXthgEhRmja8QWNkkPGsuIpfdjpkK+cZUWTC0KredVmtD/gdlSl6EG4AMvQAAAABJRU5ErkJggg==",F=14467195,Q=8,Z=2,X=20,I=null,_=function(a){y(r,a);function r(t,n){t===void 0&&(t=new o.Vector3),n===void 0&&(n=new o.Vector3);var e=a.call(this)||this;e.type="FiveLine",e.needsRender=!0;var i=new P,s=new g({color:F,linewidth:Z,dashScale:X,dashed:!1});e.line=new C(i,s);var c=new o.BufferGeometry,p=new o.PointsMaterial({color:F,size:Q,map:I||(I=new o.TextureLoader().load(k)),sizeAttenuation:!1,transparent:!0});return e.points=new o.Points(c,p),e.points.renderOrder=11,e.points.frustumCulled=!1,e.setPoints(t,n),e.add(e.line,e.points),e}return Object.defineProperty(r,"version",{get:function(){return"6.0.0-alpha.
|
|
454
|
+
`},g=function(a){y(r,a);function r(t){var n=a.call(this,{uniforms:o.UniformsUtils.clone(B.uniforms),vertexShader:B.vertexShader,fragmentShader:B.fragmentShader,clipping:!0})||this;return n.type="LineMaterial",n.dashed=!1,Object.defineProperties(n,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth.value=e}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}}}),n.setValues(t),n}return r}(o.ShaderMaterial);Object.assign(g.prototype,{isLineMaterial:!0});var M=function(a){y(r,a);function r(t,n){var e=a.call(this)||this;return e.type="LineSegments2",e.geometry=t!==void 0?t:new A,e.material=n!==void 0?n:new g({color:Math.random()*16777215}),e}return r.prototype.computeLineDistances=function(){for(var t=this.geometry,n=t.attributes.instanceStart,e=t.attributes.instanceEnd,i=new Float32Array(2*n.count),s=new o.Vector3,c=new o.Vector3,p=0,u=0,S=n.count;p<S;p++,u+=2)s.fromBufferAttribute(n,p),c.fromBufferAttribute(e,p),i[u]=u===0?0:i[u-1],i[u+1]=i[u]+s.distanceTo(c);var h=new o.InstancedInterleavedBuffer(i,2,1);return t.setAttribute("instanceDistanceStart",new o.InterleavedBufferAttribute(h,1,0)),t.setAttribute("instanceDistanceEnd",new o.InterleavedBufferAttribute(h,1,1)),this},r.prototype.raycast=function(t,n){t.camera===null&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.');var e=t.ray,i=t.camera,s=i.projectionMatrix,c=this.geometry,p=this.material,u=p.resolution,S=p.linewidth,h=c.attributes.instanceStart,U=c.attributes.instanceEnd,l=new o.Vector4,f=new o.Vector4,v=new o.Vector4,b=new o.Vector3,w=new o.Matrix4,d=new o.Line3,z=new o.Vector3;e.at(1,v),v.w=1,v.applyMatrix4(i.matrixWorldInverse),v.applyMatrix4(s),v.multiplyScalar(1/v.w),v.x*=u.x/2,v.y*=u.y/2,v.z=0,b.copy(v);var x=this.matrixWorld;w.multiplyMatrices(i.matrixWorldInverse,x);for(var m=0,N=h.count;m<N;m++){l.fromBufferAttribute(h,m),f.fromBufferAttribute(U,m),l.w=1,f.w=1,l.applyMatrix4(w),f.applyMatrix4(w),l.applyMatrix4(s),f.applyMatrix4(s),l.multiplyScalar(1/l.w),f.multiplyScalar(1/f.w);var j=l.z<-1&&f.z<-1,G=l.z>1&&f.z>1;if(!(j||G)){l.x*=u.x/2,l.y*=u.y/2,f.x*=u.x/2,f.y*=u.y/2,d.start.copy(l),d.start.z=0,d.end.copy(f),d.end.z=0;var D=d.closestPointToPointParameter(b,!0);d.at(D,z);var O=o.MathUtils.lerp(l.z,f.z,D),W=O>=-1&&O<=1,T=b.distanceTo(z)<S*.5;if(W&&T){d.start.fromBufferAttribute(h,m),d.end.fromBufferAttribute(U,m),d.start.applyMatrix4(x),d.end.applyMatrix4(x);var V=new o.Vector3,E=new o.Vector3;e.distanceSqToSegment(d.start,d.end,E,V),n.push({point:E,pointOnLine:V,distance:e.origin.distanceTo(E),object:this,faceIndex:m})}}}},r}(o.Mesh);Object.assign(M.prototype,{isLineSegments2:!0});var C=function(a){y(r,a);function r(t,n){var e=a.call(this,t,n)||this;return e.type="Line2",e}return r}(M);Object.assign(C.prototype,{isLine2:!0});var P=function(a){y(r,a);function r(){var t=a.call(this)||this;return t.type="LineGeometry",t}return r.prototype.setPositions=function(t){for(var n=t.length-3,e=new Float32Array(2*n),i=0;i<n;i+=3)e[2*i]=t[i],e[2*i+1]=t[i+1],e[2*i+2]=t[i+2],e[2*i+3]=t[i+3],e[2*i+4]=t[i+4],e[2*i+5]=t[i+5];return a.prototype.setPositions.call(this,e),this},r.prototype.setColors=function(t){for(var n=t.length-3,e=new Float32Array(2*n),i=0;i<n;i+=3)e[2*i]=t[i],e[2*i+1]=t[i+1],e[2*i+2]=t[i+2],e[2*i+3]=t[i+3],e[2*i+4]=t[i+4],e[2*i+5]=t[i+5];return a.prototype.setColors.call(this,e),this},r.prototype.fromLine=function(t){var n=t.geometry;if(n instanceof o.Geometry){var e=new o.BufferGeometry().fromGeometry(n);this.setPositions(e.attributes.position.array)}else n instanceof o.BufferGeometry&&this.setPositions(n.attributes.position.array);return this},r.prototype.copy=function(){return this},r}(A);Object.assign(P.prototype,{isLineGeometry:!0});var k="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sHDgwCEMBJZu0AAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAABM5JREFUWMO1V0tPG2cUPZ4Hxh6DazIOrjFNqJs0FIMqWFgWQkatsmvVbtggKlSVRVf5AWz4AWz4AUSKEChll19QJYSXkECuhFxsHjEhxCYm+DWGMZ5HF72DJq4bAzFXurI0M/I5997v3u9cC65vTJVn2lX/xHINQOYSBLTLEuIuCWw4Z3IGAEvf6ASmVHjNzHCXBG4A0AjACsAOwEbO0nsFQBnAGYASAIl+ZRMR7SolMEdsByD09fV5R0ZGgg8ePPjW5/N1iqLYpuu6RZblciKR2I9Go69evnwZnZ+fjwI4IS8AKBIRzeQfJWCANwKwh0KhtrGxsYehUOin1tbW+zzP23ietzY2NnIAoGmaLsuyUiqVyvl8XtrY2NiamZn589mzZxsAUgCOAeQAnFI2tI+VxIjaAeDzoaGh7xYWFuZOTk6OZVk+12uYqqq6JEnn0Wg0OT4+/geAXwGEAdwDIFJQXC1wO4DWR48e/RCPxxclSSroVzRFUbSDg4P848ePFwH8DuAhkWih83TRQWxFOXgAwvDwcOfo6OhvXV1d39tsNtuVBwTDWBwOh1UUxVsMw1hXVlbSdCgNV43uYSvrHg6H24aHh38eHBz85TrgF9FYLHA4HLzH43FvbW2d7u/vG+dANp8FpqIlbd3d3V8Fg8EfBUFw4BONZVmL3+9vHhkZCQL4AoAHgJPK8G+yzC0XDofdoVAo5PP5vkadTBAEtr+/39ff3x8gAp/RPOEqx2qjx+NpvXv3bk9DQ0NDvQgwDIOWlhZrMBj8kgi0UJdxRgYMArzL5XJ7vd57qLPZ7Xamp6fnNgBXtQxcjFuHw+Hyer3t9SYgCAITCAScAJoBNNEY/08GOFVVrfVMv7kMNDntFD1vjIAPrlRN0xjckOm6biFQ3jwNPwDMZrOnqVTqfb3Bi8Wivru7W/VCYkwPlKOjo0IikXh7EwQikYgE4Nw0CfXKDCipVCoTj8df3QABbW1tLUc6oUgkFPMkVACUNjc337148eKvw8PDbJ2jP1taWkoCyNDVXDSECmNSK4qiKNLq6urW8+fPI/UicHx8rD59+jSVy+WOAKSJhKENwFItLtoxk8mwsixzHR0dHe3t7c5PAU+n09rs7OzJkydPYqVSaQfANoDXALIk31S2smU1TWMPDg7K5XKZ7+3t9TudTut1U7+wsFCcmJiIpdPpbQBxADsAknQWymYCOukBHYCuKApisdhpMpnURFEU79y503TVyKenpzOTk5M7e3t7MQKPV0Zv1gNm+awB0MvlshqLxfLb29uyJElWURSbXC4XXyvqxcXFs6mpqeTc3Nzu3t7e3wQcA7BPZ8Cov1pNlJplmQtAG8MwHV6v95tAINA5MDBwPxAIuLu6upr8fr/VAN3c3JQjkcjZ+vp6fnl5+d2bN29SuVzuNYAEpf01CdRChUL+X1VskHACuA3Ay3Fcu9vt7nA6nZ7m5uYWQRCaNE3jVVW15PP580KhIGUymWw2m00DOAJwSP4WwPtq4LX2Ao6USxNlQyS/RcQcdLGwlNIz6vEMAaZpNzCk2Pll94LK/cDYimxERiBwG10sxjgvEZBE0UpE6vxj+0Ct5bTaXthgEhRmja8QWNkkPGsuIpfdjpkK+cZUWTC0KredVmtD/gdlSl6EG4AMvQAAAABJRU5ErkJggg==",F=14467195,Q=8,Z=2,X=20,I=null,_=function(a){y(r,a);function r(t,n){t===void 0&&(t=new o.Vector3),n===void 0&&(n=new o.Vector3);var e=a.call(this)||this;e.type="FiveLine",e.needsRender=!0;var i=new P,s=new g({color:F,linewidth:Z,dashScale:X,dashed:!1});e.line=new C(i,s);var c=new o.BufferGeometry,p=new o.PointsMaterial({color:F,size:Q,map:I||(I=new o.TextureLoader().load(k)),sizeAttenuation:!1,transparent:!0});return e.points=new o.Points(c,p),e.points.renderOrder=11,e.points.frustumCulled=!1,e.setPoints(t,n),e.add(e.line,e.points),e}return Object.defineProperty(r,"version",{get:function(){return"6.0.0-alpha.75"},enumerable:!1,configurable:!0}),r.prototype.setPoints=function(t,n){var e=[].concat(t.toArray(),n.toArray());this.points.geometry.setAttribute("position",new o.BufferAttribute(new Float32Array(e),3)),this.line.geometry.setPositions(e),this.line.computeLineDistances(),this.needsRender=!0},r.prototype.getPoints=function(){var t=this.points.geometry.attributes.position.array;return[new o.Vector3(t[0],t[1],t[2]),new o.Vector3(t[3],t[4],t[5])]},r.prototype.setMaterial=function(t){var n=this.line.material;for(var e in t)if(t.hasOwnProperty(e)){var i=t[e];e==="dashed"?(n.dashed=i,i?n.defines.USE_DASH="":delete n.defines.USE_DASH,n.needsUpdate=!0):n[e]=t[e]}this.needsRender=!0},r.prototype.setResolution=function(t,n){var e=this.line.material.resolution;(e.x!==t||e.y!==n)&&(e.set(t,n),this.needsRender=!0)},r}(o.Object3D);Object.assign(_.prototype,{isFiveLine:!0});exports.Line=_;exports.LineGeometry=P;exports.LineMaterial=g;exports.LineSegmentsGeometry=A;exports.THREE_Line2=C;exports.THREE_LineSegments2=M;
|
package/line/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
3
|
* @realsee/five
|
|
4
|
-
* Generated:
|
|
5
|
-
* Version: 6.0.0-alpha.
|
|
4
|
+
* Generated: 1/3/2024
|
|
5
|
+
* Version: 6.0.0-alpha.75
|
|
6
6
|
* Terms:
|
|
7
7
|
* Realsee SDK License Agreement
|
|
8
8
|
* Update: July 28, 2021
|
|
@@ -738,7 +738,7 @@ var T = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAA
|
|
|
738
738
|
}
|
|
739
739
|
return Object.defineProperty(o, "version", {
|
|
740
740
|
get: function() {
|
|
741
|
-
return "6.0.0-alpha.
|
|
741
|
+
return "6.0.0-alpha.75";
|
|
742
742
|
},
|
|
743
743
|
enumerable: !1,
|
|
744
744
|
configurable: !0
|
package/package.json
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@realsee/five",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.75",
|
|
4
4
|
"description": "Realsee Renderer SDK",
|
|
5
5
|
"bin": {
|
|
6
|
-
"five-plugin-init": "./scripts/five-plugin-init.js",
|
|
7
|
-
"five-react-component-init": "./scripts/five-react-component-init.js",
|
|
8
|
-
"five-quick-start-init": "./scripts/five-quick-start-init.js",
|
|
9
6
|
"five-staticify": "./scripts/five-staticify.js"
|
|
10
7
|
},
|
|
11
8
|
"author": "BEIKE REALSEE TECHNOLOGY (HK) LIMITED",
|
|
12
9
|
"license": "SEE LICENSE IN TERMS.txt",
|
|
13
10
|
"peerDependencies": {
|
|
14
|
-
"react": "
|
|
11
|
+
"react": ">=16.12.0",
|
|
15
12
|
"three": "^0.117.1",
|
|
16
13
|
"vue": "^3.0.0"
|
|
17
14
|
},
|
|
@@ -29,11 +26,8 @@
|
|
|
29
26
|
"dependencies": {
|
|
30
27
|
"archiver": "^6.0.1",
|
|
31
28
|
"commander": "^11.1.0",
|
|
32
|
-
"copyfiles": "^2.4.1",
|
|
33
29
|
"ejs": "^3.1.6",
|
|
34
|
-
"
|
|
35
|
-
"protobufjs": "^7.2.5",
|
|
36
|
-
"vite-bundle-visualizer": "^1.0.0"
|
|
30
|
+
"protobufjs": "^7.2.5"
|
|
37
31
|
},
|
|
38
32
|
"main": "five/index.js",
|
|
39
33
|
"types": "five/index.d.ts",
|
package/react/index.js
CHANGED
package/react/index.mjs
CHANGED
|
@@ -1,7 +1,189 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
3
5
|
const { program } = require("commander");
|
|
4
|
-
const
|
|
6
|
+
const archiver = require("archiver");
|
|
7
|
+
const ejs = require("ejs");
|
|
8
|
+
const { parseWork, defaultImageURLTransform } = require("@realsee/five");
|
|
9
|
+
|
|
10
|
+
function matchJsonpFunctionName(url) {
|
|
11
|
+
const regExps = [
|
|
12
|
+
/\.([0-9a-z]+)\.jsonp([\?\#].*)?$/i,
|
|
13
|
+
/jsonp_([0-9a-z]+)([\?\#].*)?$/i
|
|
14
|
+
];
|
|
15
|
+
for (const regExp of regExps) {
|
|
16
|
+
const matched = url.match(regExp);
|
|
17
|
+
if (matched) {
|
|
18
|
+
return "jsonp_" + matched[1];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
async function download(url, jsonpHandleKey) {
|
|
25
|
+
const request = /^https\:/.test(url) ? require("https") : require("http");
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
const req = request.get(url, res => {
|
|
28
|
+
const mime = res.headers['content-type'];
|
|
29
|
+
const buffers = [];
|
|
30
|
+
|
|
31
|
+
res.on('data', chunk => buffers.push(chunk));
|
|
32
|
+
res.on('end', () => {
|
|
33
|
+
const contents = Buffer.concat(buffers);
|
|
34
|
+
if (jsonpHandleKey) {
|
|
35
|
+
const dataURL = `data:${mime};base64,${contents.toString('base64')}`;
|
|
36
|
+
const jsopContents = `window[${JSON.stringify(jsonpHandleKey)}] && window[${JSON.stringify(jsonpHandleKey)}](${JSON.stringify(dataURL)})`;
|
|
37
|
+
resolve(Buffer.from(jsopContents));
|
|
38
|
+
} else {
|
|
39
|
+
resolve(Buffer.from(contents));
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
res.on("error", () => reject(new Error(`fetch ${url} got error`)));
|
|
43
|
+
});
|
|
44
|
+
req.on("error", () => reject(new Error(`fetch ${url} got error`)));
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const template = `
|
|
49
|
+
<!DOCTYPE html>
|
|
50
|
+
<html lang="en">
|
|
51
|
+
<head>
|
|
52
|
+
<meta charset="UTF-8">
|
|
53
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
54
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
55
|
+
<title>REALSEE PREVIEW</title>
|
|
56
|
+
<style>
|
|
57
|
+
* { margin: 0; padding: 0; }
|
|
58
|
+
html, body { height: 100%; width: 100%; overflow: hidden; }
|
|
59
|
+
#app { position: fixed; top: 0; left: 0; right: 0; bottom: 0; overflow: hidden; }
|
|
60
|
+
.buttons { position: fixed; top: 10px; left: 10px; pointer-events: none; }
|
|
61
|
+
.buttons h3 { margin-top: 10px; text-shadow: 0 0 2px rgba(255, 255, 255, 0.5); }
|
|
62
|
+
.buttons button { pointer-events: auto; display: block; font-size: 14px; color: #FFF; background: #5a6268; padding: 3px 10px; border: 1px solid #333; margin-right: 2px; border-radius: 2px; cursor: pointer; margin-top: 10px; }
|
|
63
|
+
.buttons button:active { background: #333; }
|
|
64
|
+
</style>
|
|
65
|
+
<script src="./three.min.js"></script>
|
|
66
|
+
<script src="./five.js"></script>
|
|
67
|
+
<script>const workJSON = <%- JSON.stringify(work_json) %></script>
|
|
68
|
+
</head>
|
|
69
|
+
<body>
|
|
70
|
+
<!-- 试图渲染容器 -->
|
|
71
|
+
<div id="app"></div>
|
|
72
|
+
<script>
|
|
73
|
+
const five = new FiveSDK.Five();
|
|
74
|
+
five.appendTo(document.getElementById("app"));
|
|
75
|
+
const work = FiveSDK.parseWork(workJSON, { baseURL: "./", shortPath: <%- JSON.stringify(short_path) %>, jsonp: <%- JSON.stringify(jsonp) %> });
|
|
76
|
+
five.load(work);
|
|
77
|
+
|
|
78
|
+
const modeButtons = [
|
|
79
|
+
{ mode: "Panorama", label: "全景漫游模式" },
|
|
80
|
+
{ mode: "Model", label: "模型漫游模式" },
|
|
81
|
+
{ mode: "Floorplan", label: "模型纵览模式" },
|
|
82
|
+
{ mode: "Topview", label: "模型俯视模式" },
|
|
83
|
+
{ mode: "Mapview", label: "模型自由模式" },
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
const buttons = document.createElement("div");
|
|
87
|
+
buttons.className = "buttons";
|
|
88
|
+
document.body.appendChild(buttons);
|
|
89
|
+
buttons.appendChild(document.createElement("h3")).innerHTML = "模式控制";
|
|
90
|
+
|
|
91
|
+
// 模态按钮
|
|
92
|
+
for (let i = 0; i < modeButtons.length; i++) {
|
|
93
|
+
const button = document.createElement("button");
|
|
94
|
+
button.innerHTML = modeButtons[i].label;
|
|
95
|
+
button.addEventListener('click', () => {
|
|
96
|
+
// 通过 changeMode 方法可以切换模态
|
|
97
|
+
five.changeMode(FiveSDK.Five.Mode[modeButtons[i].mode]);
|
|
98
|
+
});
|
|
99
|
+
buttons.appendChild(button);
|
|
100
|
+
}
|
|
101
|
+
window.addEventListener("resize", () => five.refresh(), false);
|
|
102
|
+
</script>
|
|
103
|
+
</body>
|
|
104
|
+
</html>
|
|
105
|
+
`;
|
|
106
|
+
|
|
107
|
+
function getThreeJsBuffer() {
|
|
108
|
+
let tempPath = path.resolve(__dirname);
|
|
109
|
+
while (!(tempPath === '/' || tempPath === ".")) {
|
|
110
|
+
const threeFilePath = path.join(tempPath, "node_modules/three/build/three.min.js");
|
|
111
|
+
if (fs.existsSync(threeFilePath)) {
|
|
112
|
+
return fs.readFileSync(threeFilePath);
|
|
113
|
+
}
|
|
114
|
+
tempPath = path.dirname(tempPath);
|
|
115
|
+
}
|
|
116
|
+
throw new Error("three.js is not found");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function getFiveJsBuffer() {
|
|
120
|
+
return fs.readFileSync(path.join(__dirname, "../umd/five.js"));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function staticify(work, output, shortPath = false, jsonp = false, preview = true) {
|
|
124
|
+
const zipFilename = /\.zip$/.test(output) ? output : output + ".zip";
|
|
125
|
+
const outputStream = fs.createWriteStream(zipFilename);
|
|
126
|
+
const archive = archiver("zip", { zlib: { level: 9 } });
|
|
127
|
+
archive.on("error", (err) => { throw err; });
|
|
128
|
+
outputStream.on("close", function() {
|
|
129
|
+
console.info(`zip ${archive.pointer()} total bytes`);
|
|
130
|
+
console.info(`dist ${zipFilename}`);
|
|
131
|
+
});
|
|
132
|
+
archive.pipe(outputStream);
|
|
133
|
+
|
|
134
|
+
const resources = [];
|
|
135
|
+
const workJSONObject = JSON.parse(fs.readFileSync(work, "utf8"));
|
|
136
|
+
parseWork(workJSONObject, {
|
|
137
|
+
shortPath,
|
|
138
|
+
jsonp,
|
|
139
|
+
traverseResource(resource) {
|
|
140
|
+
resources.push(resource);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const textureCount = resources.filter(({ type }) => type === "texture").length;
|
|
145
|
+
let textureSize;
|
|
146
|
+
if (textureCount > 50) {
|
|
147
|
+
textureSize = 64;
|
|
148
|
+
} else if (textureCount > 40) {
|
|
149
|
+
textureSize = 128;
|
|
150
|
+
} else if (textureCount > 30) {
|
|
151
|
+
textureSize = 256;
|
|
152
|
+
} else if (textureCount > 15) {
|
|
153
|
+
textureSize = 512;
|
|
154
|
+
} else if (textureCount > 10) {
|
|
155
|
+
textureSize = 1024;
|
|
156
|
+
}
|
|
157
|
+
if (textureSize) {
|
|
158
|
+
for (const resource of resources) {
|
|
159
|
+
if (resource.type === "texture") {
|
|
160
|
+
resource.origin = defaultImageURLTransform(resource.origin, { size: textureSize, key: resource.type });
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
for (const { origin, relative } of resources) {
|
|
165
|
+
const buffer = await download(origin, matchJsonpFunctionName(relative));
|
|
166
|
+
console.info(`${origin} -> ${relative}`);
|
|
167
|
+
archive.append(buffer, { name: relative });
|
|
168
|
+
}
|
|
169
|
+
archive.append(fs.readFileSync(work), { name: "work.json" });
|
|
170
|
+
|
|
171
|
+
if (preview) {
|
|
172
|
+
archive.append(getFiveJsBuffer(), { name: "five.js" });
|
|
173
|
+
archive.append(getThreeJsBuffer(), { name: "three.min.js" });
|
|
174
|
+
|
|
175
|
+
const data = {
|
|
176
|
+
work_json: workJSONObject,
|
|
177
|
+
short_path: Boolean(shortPath),
|
|
178
|
+
jsonp: Boolean(jsonp),
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const html = typeof preview === 'string' ? ejs.render(fs.readFileSync(preview, "utf8"), data) : ejs.render(template, data);
|
|
182
|
+
archive.append(html, { name: "index.html" });
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
archive.finalize();
|
|
186
|
+
}
|
|
5
187
|
|
|
6
188
|
program
|
|
7
189
|
.requiredOption("--work <work>", "work 的 json 文件")
|
|
@@ -15,7 +197,6 @@ program.parse(process.argv);
|
|
|
15
197
|
|
|
16
198
|
async function main(program) {
|
|
17
199
|
let { work, output, shortPath, jsonp, preview, template } = program.opts();
|
|
18
|
-
console.log(template)
|
|
19
200
|
if (preview !== false && template) {
|
|
20
201
|
preview = template;
|
|
21
202
|
}
|
package/sticker/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
3
|
* @realsee/five
|
|
4
|
-
* Generated:
|
|
5
|
-
* Version: 6.0.0-alpha.
|
|
4
|
+
* Generated: 1/3/2024
|
|
5
|
+
* Version: 6.0.0-alpha.75
|
|
6
6
|
* Terms:
|
|
7
7
|
* Realsee SDK License Agreement
|
|
8
8
|
* Update: July 28, 2021
|
|
@@ -252,4 +252,4 @@
|
|
|
252
252
|
* No amendment to or modification of this Agreement will be binding unless in
|
|
253
253
|
* writing and signed by Realsee. You and Realsee hereto confirm that this
|
|
254
254
|
* Agreement and all related documents shall be drafted in English.
|
|
255
|
-
*/"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("three");function w(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,i.get?i:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const a=w(g);var m=function(t,n){return m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])},m(t,n)};function h(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");m(t,n);function e(){this.constructor=t}t.prototype=n===null?Object.create(n):(e.prototype=n.prototype,new e)}var E=new Float32Array([-.5,-.5,0,.5,-.5,0,-.5,.5,0,.5,.5,0]),T=new Float32Array([0,0,1,0,0,1,1,1]),_=new Uint8Array([0,1,2,1,3,2]),d=new a.BufferGeometry;d.setAttribute("position",new a.BufferAttribute(E,3));d.setAttribute("uv",new a.BufferAttribute(T,2));d.setIndex(new a.BufferAttribute(_,1));var u=window,y=u.requestAnimationFrame||u.mozRequestAnimationFrame||u.webkitRequestAnimationFrame||u.msRequestAnimationFrame||function(t){return setTimeout(t,16)},R=typeof performance!="undefined"&&typeof performance.timing!="undefined"?performance.timing.navigationStart:Date.now(),l=typeof performance!="undefined"?function(){return R+performance.now()}:function(){return Date.now()};function S(t,n){t.naturalWidth>0&&y(function(){return n()});var e=function(){return n()};return t.addEventListener("load",e,!1),function(){return t.removeEventListener("load",e,!1)}}function A(t,n){var e=l(),i=!1,r=function(){i=!0,n();var s=l();s-e<3e3?y(r):i=!1},o=function(){e=l(),i===!1&&r()};return t.addEventListener("timeupdate",o,!1),function(){t.removeEventListener("timeupdate",o,!1),i=!1}}function v(t,n){var e=t.dispose;t.dispose=function(){n(),e.call(t)}}var b=function(t){h(n,t);function n(e,i,r){var o=this,s=new a.MeshBasicMaterial;if(o=t.call(this,d,s)||this,o._needsRender=!1,o.scale.set(e,i,1),typeof r=="string"){s.transparent=/\.png$/.test(r);var c=new Image;c.src=r,c.crossOrigin="",r=c}if(r instanceof HTMLImageElement){var p=s.map=new a.Texture;p.wrapS=a.ClampToEdgeWrapping,p.wrapT=a.ClampToEdgeWrapping,p.minFilter=a.LinearFilter,p.encoding=a.sRGBEncoding,v(p,S(r,function(){p.image=r,p.needsUpdate=!0,o._needsRender=!0}))}else if(r instanceof HTMLCanvasElement)s.map=new a.CanvasTexture(r);else if(r instanceof HTMLVideoElement){var f=s.map=new a.VideoTexture(r);f.wrapS=a.ClampToEdgeWrapping,f.wrapT=a.ClampToEdgeWrapping,f.minFilter=a.LinearFilter,f.encoding=a.sRGBEncoding,v(f,A(r,function(){o._needsRender=!0}))}return o}return Object.defineProperty(n,"version",{get:function(){return"6.0.0-alpha.
|
|
255
|
+
*/"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("three");function w(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,i.get?i:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const a=w(g);var m=function(t,n){return m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])},m(t,n)};function h(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");m(t,n);function e(){this.constructor=t}t.prototype=n===null?Object.create(n):(e.prototype=n.prototype,new e)}var E=new Float32Array([-.5,-.5,0,.5,-.5,0,-.5,.5,0,.5,.5,0]),T=new Float32Array([0,0,1,0,0,1,1,1]),_=new Uint8Array([0,1,2,1,3,2]),d=new a.BufferGeometry;d.setAttribute("position",new a.BufferAttribute(E,3));d.setAttribute("uv",new a.BufferAttribute(T,2));d.setIndex(new a.BufferAttribute(_,1));var u=window,y=u.requestAnimationFrame||u.mozRequestAnimationFrame||u.webkitRequestAnimationFrame||u.msRequestAnimationFrame||function(t){return setTimeout(t,16)},R=typeof performance!="undefined"&&typeof performance.timing!="undefined"?performance.timing.navigationStart:Date.now(),l=typeof performance!="undefined"?function(){return R+performance.now()}:function(){return Date.now()};function S(t,n){t.naturalWidth>0&&y(function(){return n()});var e=function(){return n()};return t.addEventListener("load",e,!1),function(){return t.removeEventListener("load",e,!1)}}function A(t,n){var e=l(),i=!1,r=function(){i=!0,n();var s=l();s-e<3e3?y(r):i=!1},o=function(){e=l(),i===!1&&r()};return t.addEventListener("timeupdate",o,!1),function(){t.removeEventListener("timeupdate",o,!1),i=!1}}function v(t,n){var e=t.dispose;t.dispose=function(){n(),e.call(t)}}var b=function(t){h(n,t);function n(e,i,r){var o=this,s=new a.MeshBasicMaterial;if(o=t.call(this,d,s)||this,o._needsRender=!1,o.scale.set(e,i,1),typeof r=="string"){s.transparent=/\.png$/.test(r);var c=new Image;c.src=r,c.crossOrigin="",r=c}if(r instanceof HTMLImageElement){var p=s.map=new a.Texture;p.wrapS=a.ClampToEdgeWrapping,p.wrapT=a.ClampToEdgeWrapping,p.minFilter=a.LinearFilter,p.encoding=a.sRGBEncoding,v(p,S(r,function(){p.image=r,p.needsUpdate=!0,o._needsRender=!0}))}else if(r instanceof HTMLCanvasElement)s.map=new a.CanvasTexture(r);else if(r instanceof HTMLVideoElement){var f=s.map=new a.VideoTexture(r);f.wrapS=a.ClampToEdgeWrapping,f.wrapT=a.ClampToEdgeWrapping,f.minFilter=a.LinearFilter,f.encoding=a.sRGBEncoding,v(f,A(r,function(){o._needsRender=!0}))}return o}return Object.defineProperty(n,"version",{get:function(){return"6.0.0-alpha.75"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"needsRender",{get:function(){return this._needsRender},set:function(e){this._needsRender=e,e===!0&&this.material.map&&(this.material.map.needsUpdate=!0)},enumerable:!1,configurable:!0}),n.prototype.setSize=function(e,i){this.scale.set(e,i,1),this._needsRender=!0},n.prototype.setTransparent=function(e){this.material.transparent=e,this._needsRender=!0},n.prototype.locationWithIntersection=function(e,i){i===void 0&&(i=.005);var r=e.point,o=e.face;this.position.copy(r),o&&(this.position.add(o.normal.clone().setLength(i)),this.lookAt(r.clone().add(o.normal))),this._needsRender=!0},n.prototype.dispose=function(){var e;(e=this.material.map)===null||e===void 0||e.dispose(),this.material.dispose()},n}(a.Mesh);exports.Sticker=b;
|
package/sticker/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
3
|
* @realsee/five
|
|
4
|
-
* Generated:
|
|
5
|
-
* Version: 6.0.0-alpha.
|
|
4
|
+
* Generated: 1/3/2024
|
|
5
|
+
* Version: 6.0.0-alpha.75
|
|
6
6
|
* Terms:
|
|
7
7
|
* Realsee SDK License Agreement
|
|
8
8
|
* Update: July 28, 2021
|
|
@@ -367,7 +367,7 @@ var A = (
|
|
|
367
367
|
}
|
|
368
368
|
return Object.defineProperty(n, "version", {
|
|
369
369
|
get: function() {
|
|
370
|
-
return "6.0.0-alpha.
|
|
370
|
+
return "6.0.0-alpha.75";
|
|
371
371
|
},
|
|
372
372
|
enumerable: !1,
|
|
373
373
|
configurable: !0
|