@2112-lab/central-plant 0.1.3 → 0.1.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/dist/bundle/index.js +1 -1
- package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +1 -1
- package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -1
- package/dist/cjs/node_modules/three/examples/jsm/exporters/GLTFExporter.js +1 -0
- package/dist/cjs/node_modules/three/examples/jsm/exporters/OBJExporter.js +1 -0
- package/dist/cjs/node_modules/three/examples/jsm/exporters/PLYExporter.js +1 -0
- package/dist/cjs/node_modules/three/examples/jsm/exporters/STLExporter.js +1 -0
- package/dist/cjs/node_modules/three/examples/jsm/loaders/DRACOLoader.js +1 -0
- package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +1 -1
- package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +1 -1
- package/dist/cjs/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +1 -0
- package/dist/cjs/src/analysis/analysis.js +1 -0
- package/dist/cjs/src/analysis/testing.js +1 -0
- package/dist/cjs/src/core/centralPlant.js +1 -0
- package/dist/cjs/src/core/debugLogger.js +1 -0
- package/dist/cjs/src/core/mathUtils.js +1 -0
- package/dist/cjs/src/core/nameUtils.js +1 -0
- package/dist/cjs/src/data/export.js +1 -0
- package/dist/cjs/src/data/import.js +1 -0
- package/dist/cjs/src/data/numerics.js +1 -0
- package/dist/cjs/src/helpers/sceneHelper.js +1 -0
- package/dist/cjs/src/index.js +1 -1
- package/dist/cjs/src/managers/components/animationManager.js +1 -0
- package/dist/cjs/src/managers/components/componentManager.js +1 -0
- package/dist/cjs/src/managers/components/pathfindingManager.js +1 -0
- package/dist/cjs/src/managers/controls/TransformControls.js +1 -0
- package/dist/cjs/src/managers/controls/cameraControlsManager.js +1 -0
- package/dist/cjs/src/managers/controls/dragDropManager.js +1 -0
- package/dist/cjs/src/managers/controls/keyboardControlsManager.js +1 -0
- package/dist/cjs/src/managers/controls/transformControlsManager.js +1 -0
- package/dist/cjs/src/managers/environment/environmentManager.js +1 -0
- package/dist/cjs/src/managers/environment/textureConfig.js +1 -0
- package/dist/cjs/src/managers/scene/sceneExportManager.js +1 -0
- package/dist/cjs/src/managers/scene/sceneInitializationManager.js +1 -0
- package/dist/cjs/src/managers/scene/sceneOperationsManager.js +1 -0
- package/dist/cjs/src/managers/scene/sceneTooltipsManager.js +1 -0
- package/dist/cjs/src/managers/system/disposalManager.js +1 -0
- package/dist/cjs/src/managers/system/hotReloadManager.js +1 -0
- package/dist/cjs/src/managers/system/performanceMonitor.js +1 -0
- package/dist/cjs/src/rendering/modelPreloader.js +1 -0
- package/dist/cjs/src/rendering/rendering2D.js +1 -0
- package/dist/cjs/src/rendering/rendering3D.js +1 -0
- package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +1 -1
- package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -1
- package/dist/esm/node_modules/three/examples/jsm/exporters/GLTFExporter.js +1 -0
- package/dist/esm/node_modules/three/examples/jsm/exporters/OBJExporter.js +1 -0
- package/dist/esm/node_modules/three/examples/jsm/exporters/PLYExporter.js +1 -0
- package/dist/esm/node_modules/three/examples/jsm/exporters/STLExporter.js +1 -0
- package/dist/esm/node_modules/three/examples/jsm/loaders/DRACOLoader.js +1 -0
- package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +1 -1
- package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +1 -1
- package/dist/esm/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +1 -0
- package/dist/esm/src/analysis/analysis.js +1 -0
- package/dist/esm/src/analysis/testing.js +1 -0
- package/dist/esm/src/core/centralPlant.js +1 -0
- package/dist/esm/src/core/debugLogger.js +1 -0
- package/dist/esm/src/core/mathUtils.js +1 -0
- package/dist/esm/src/core/nameUtils.js +1 -0
- package/dist/esm/src/data/export.js +1 -0
- package/dist/esm/src/data/import.js +1 -0
- package/dist/esm/src/data/numerics.js +1 -0
- package/dist/esm/src/helpers/sceneHelper.js +1 -0
- package/dist/esm/src/index.js +1 -1
- package/dist/esm/src/managers/components/animationManager.js +1 -0
- package/dist/esm/src/managers/components/componentManager.js +1 -0
- package/dist/esm/src/managers/components/pathfindingManager.js +1 -0
- package/dist/esm/src/managers/controls/TransformControls.js +1 -0
- package/dist/esm/src/managers/controls/cameraControlsManager.js +1 -0
- package/dist/esm/src/managers/controls/dragDropManager.js +1 -0
- package/dist/esm/src/managers/controls/keyboardControlsManager.js +1 -0
- package/dist/esm/src/managers/controls/transformControlsManager.js +1 -0
- package/dist/esm/src/managers/environment/environmentManager.js +1 -0
- package/dist/esm/src/managers/environment/textureConfig.js +1 -0
- package/dist/esm/src/managers/scene/sceneExportManager.js +1 -0
- package/dist/esm/src/managers/scene/sceneInitializationManager.js +1 -0
- package/dist/esm/src/managers/scene/sceneOperationsManager.js +1 -0
- package/dist/esm/src/managers/scene/sceneTooltipsManager.js +1 -0
- package/dist/esm/src/managers/system/disposalManager.js +1 -0
- package/dist/esm/src/managers/system/hotReloadManager.js +1 -0
- package/dist/esm/src/managers/system/performanceMonitor.js +1 -0
- package/dist/esm/src/rendering/modelPreloader.js +1 -0
- package/dist/esm/src/rendering/rendering2D.js +1 -0
- package/dist/esm/src/rendering/rendering3D.js +1 -0
- package/dist/index.d.ts +52 -255
- package/package.json +3 -6
- package/dist/cjs/node_modules/three/examples/jsm/controls/TransformControls.js +0 -1
- package/dist/cjs/src/animationManager.js +0 -1
- package/dist/cjs/src/componentManager.js +0 -1
- package/dist/cjs/src/debugLogger.js +0 -1
- package/dist/cjs/src/disposalManager.js +0 -1
- package/dist/cjs/src/environmentManager.js +0 -1
- package/dist/cjs/src/hotReloadManager.js +0 -1
- package/dist/cjs/src/keyboardControlsManager.js +0 -1
- package/dist/cjs/src/nameUtils.js +0 -1
- package/dist/cjs/src/pathfindingManager.js +0 -1
- package/dist/cjs/src/performanceMonitor.js +0 -1
- package/dist/cjs/src/sceneExportManager.js +0 -1
- package/dist/cjs/src/sceneInitializationManager.js +0 -1
- package/dist/cjs/src/textureConfig.js +0 -1
- package/dist/cjs/src/transformControlsManager.js +0 -1
- package/dist/esm/node_modules/three/examples/jsm/controls/TransformControls.js +0 -1
- package/dist/esm/src/animationManager.js +0 -1
- package/dist/esm/src/componentManager.js +0 -1
- package/dist/esm/src/debugLogger.js +0 -1
- package/dist/esm/src/disposalManager.js +0 -1
- package/dist/esm/src/environmentManager.js +0 -1
- package/dist/esm/src/hotReloadManager.js +0 -1
- package/dist/esm/src/keyboardControlsManager.js +0 -1
- package/dist/esm/src/nameUtils.js +0 -1
- package/dist/esm/src/pathfindingManager.js +0 -1
- package/dist/esm/src/performanceMonitor.js +0 -1
- package/dist/esm/src/sceneExportManager.js +0 -1
- package/dist/esm/src/sceneInitializationManager.js +0 -1
- package/dist/esm/src/textureConfig.js +0 -1
- package/dist/esm/src/transformControlsManager.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"t",{value:!0});var t=require("../../../_virtual/_rollupPluginBabelHelpers.js"),n=function(){return t.createClass(function n(i){t.classCallCheck(this,n),this.sceneViewer=i,this.isDev="development"===process.env.NODE_ENV},[{key:"enhancedDisposal",value:(i=t.asyncToGenerator(t.regenerator().m(function n(){return t.regenerator().w(function(t){for(;;)switch(t.n){case 0:return this.isDev,this.forceStopOperations(),t.n=1,this.enhancedSceneCleanup();case 1:this.enhancedRendererCleanup(),this.sceneViewer.hotReloadManager&&this.sceneViewer.hotReloadManager.clearPendingOperations(),this.isDev&&this.sceneViewer.hotReloadManager&&this.sceneViewer.hotReloadManager.forceGarbageCollectionHint();case 2:return t.a(2)}},n,this)})),function(){return i.apply(this,arguments)})},{key:"forceStopOperations",value:function(){this.sceneViewer.isDestroyed=!0,this.sceneViewer.isLoading=!1,this.sceneViewer.currentTransition=null,this.sceneViewer.animationId&&(cancelAnimationFrame(this.sceneViewer.animationId),this.sceneViewer.animationId=null),this.isDev}},{key:"enhancedSceneCleanup",value:(n=t.asyncToGenerator(t.regenerator().m(function n(){var i,e=this;return t.regenerator().w(function(t){for(;;)switch(t.n){case 0:if(i={textures:0,materials:0,geometries:0,objects:0},this.sceneViewer.scene){for(this.sceneViewer.scene.traverse(function(t){t.material&&(Array.isArray(t.material)?t.material.forEach(function(t){i.textures+=e.disposeMaterialTextures(t),t.dispose(),i.materials++}):(i.textures+=e.disposeMaterialTextures(t.material),t.material.dispose(),i.materials++)),t.geometry&&(t.geometry.dispose(),i.geometries++),i.objects++});this.sceneViewer.scene.children.length>0;)this.sceneViewer.scene.remove(this.sceneViewer.scene.children[0]);this.isDev}case 1:return t.a(2)}},n,this)})),function(){return n.apply(this,arguments)})},{key:"disposeMaterialTextures",value:function(t){var n=0;return["map","normalMap","roughnessMap","metalnessMap","envMap","lightMap","bumpMap","specularMap"].forEach(function(i){t[i]&&(t[i].dispose(),n++)}),n}},{key:"enhancedRendererCleanup",value:function(){if(this.sceneViewer.renderer){var t=this.sceneViewer.renderer.getContext();if(t&&"function"==typeof t.getExtension){var n=t.getExtension("WEBGL_lose_context");n&&n.loseContext()}this.sceneViewer.renderer.dispose(),this.sceneViewer.renderer.forceContextLoss(),this.sceneViewer.renderer=null,this.isDev}}},{key:"cleanupScene",value:function(){var t=this;if(this.sceneViewer.scene){var n=[];this.sceneViewer.scene.traverse(function(t){n.push(t)});for(var i=function(){var i=n[e];i.geometry&&i.geometry.dispose(),i.material&&(Array.isArray(i.material)?i.material.forEach(function(n){return t.disposeMaterial(n)}):t.disposeMaterial(i.material));["map","lightMap","bumpMap","normalMap","specularMap","envMap"].forEach(function(t){i[t]&&i[t].dispose()}),i.parent&&i.parent.remove(i)},e=n.length-1;e>=0;e--)i();this.sceneViewer.scene.environment&&(this.sceneViewer.scene.environment.dispose(),this.sceneViewer.scene.environment=null),this.sceneViewer.scene.background&&this.sceneViewer.scene.background.dispose&&(this.sceneViewer.scene.background.dispose(),this.sceneViewer.scene.background=null),this.sceneViewer.scene.clear(),this.sceneViewer.scene=null}}},{key:"disposeMaterial",value:function(n){for(var i=0,e=Object.entries(n);i<e.length;i++){var s=t.slicedToArray(e[i],2);s[0];var u=s[1];u&&"object"===t.typeof(u)&&"function"==typeof u.dispose&&u.dispose()}n.dispose()}},{key:"cleanupRenderer",value:function(){this.sceneViewer.renderer&&(this.sceneViewer.renderer.domElement&&this.sceneViewer.renderer.domElement.parentNode&&this.sceneViewer.renderer.domElement.parentNode.removeChild(this.sceneViewer.renderer.domElement),this.sceneViewer.renderer.dispose(),this.sceneViewer.renderer.forceContextLoss(),this.sceneViewer.renderer=null)}},{key:"cleanupControls",value:function(){this.sceneViewer.controls&&(this.sceneViewer.controls.dispose(),this.sceneViewer.controls=null)}},{key:"cleanupEventListeners",value:function(){this.sceneViewer.handleResize&&(window.removeEventListener("resize",this.sceneViewer.handleResize),this.sceneViewer.handleResize=null),this.sceneViewer.resizeObserver&&(this.sceneViewer.resizeObserver.disconnect(),this.sceneViewer.resizeObserver=null),this.sceneViewer.handleKeyDown&&(window.removeEventListener("keydown",this.sceneViewer.handleKeyDown),this.sceneViewer.handleKeyDown=null),window._performanceKeyHandler&&(window.removeEventListener("keydown",window._performanceKeyHandler),delete window._performanceKeyHandler)}},{key:"cleanupPerformanceMonitoring",value:function(){if(this.sceneViewer.performanceMonitor){try{this.sceneViewer.performanceMonitor.stop()}catch(t){}this.sceneViewer.performanceMonitor=null}if(this.sceneViewer.performanceUI){try{"function"==typeof this.sceneViewer.performanceUI.dispose?this.sceneViewer.performanceUI.dispose():this.sceneViewer.performanceUI.hide()}catch(t){}this.sceneViewer.performanceUI=null}try{var t=document.querySelectorAll("#performance-monitor-ui");t.length>0&&t.forEach(function(t){t.parentNode&&t.parentNode.removeChild(t)})}catch(t){}}},{key:"cleanupGlobalReferences",value:function(){var t=this.parent;if(t){if(t.tooltipsManager)try{t.tooltipsManager.dispose()}catch(t){}finally{t.tooltipsManager=null}t.hotReloadManager=null,t.sceneExportManager=null,t.componentManager=null,t.sceneInitializationManager=null,t.environmentManager=null,t.keyboardControlsManager=null,t.pathfindingManager=null,t.sceneOperationsManager=null,t.animationManager=null,t.cameraControlsManager=null,t.disposalManager=null}}},{key:"cleanupNuxtEventListeners",value:function(){window.$nuxt&&window.$nuxt.$off&&(window.$nuxt.$off("loadNewScene"),window.$nuxt.$off("createNewScene"))}}]);var n,i}();exports.DisposalManager=n;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"t",{value:!0});var t=require("../../../_virtual/_rollupPluginBabelHelpers.js"),i=function(){return t.createClass(function i(n){t.classCallCheck(this,i),this.sceneViewer=n||null,this.isDev="development"===process.env.NODE_ENV,this.instanceId=Date.now()+Math.random(),this.hotReloadCleanupHandler=null,this.visibilityChangeHandler=null,this.nuxtHotReloadHandler=null,this.memoryCheckInterval=null,this.timeoutIds=new Set,this.intervalIds=new Set},[{key:"setupHotReloadHandling",value:function(){var t=this;if(this.sceneViewer&&this.isDev){window._sceneViewerInstances||(window._sceneViewerInstances=new Set);try{window._sceneViewerInstances.add(this.sceneViewer)}catch(t){}this.hotReloadCleanupHandler=function(){if(t.sceneViewer){if(t.sceneViewer&&t.sceneViewer.tooltipsManager)try{t.sceneViewer.tooltipsManager.dispose(),t.sceneViewer.tooltipsManager=null}catch(t){}try{"function"==typeof t.sceneViewer.enhancedDisposal&&t.sceneViewer.enhancedDisposal()}catch(t){}try{Promise.resolve().then(function(){return require("./performanceMonitor.js")}).then(function(t){var i=t.PerformanceUI;i&&"function"==typeof i.cleanupAllInstances&&i.cleanupAllInstances()}).catch(function(t){})}catch(t){}if(window._sceneViewerInstances)try{window._sceneViewerInstances.delete(t.sceneViewer)}catch(t){}}};try{window.addEventListener("beforeunload",this.hotReloadCleanupHandler),window.addEventListener("pagehide",this.hotReloadCleanupHandler)}catch(t){}}}},{key:"cleanupHotReloadHandlers",value:function(){if(this.isDev)try{this.hotReloadCleanupHandler&&(window.removeEventListener("beforeunload",this.hotReloadCleanupHandler),window.removeEventListener("pagehide",this.hotReloadCleanupHandler),this.hotReloadCleanupHandler=null),this.visibilityChangeHandler&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null),this.nuxtHotReloadHandler&&window.$nuxt&&window.$nuxt.$off&&(window.$nuxt.$off("routeChanged",this.nuxtHotReloadHandler),window.$nuxt.$off("$nuxtReady",this.nuxtHotReloadHandler),this.nuxtHotReloadHandler=null),this.memoryCheckInterval&&(clearInterval(this.memoryCheckInterval),this.memoryCheckInterval=null);this.sceneViewer;if(window._sceneViewerInstances&&this.sceneViewer)try{window._sceneViewerInstances.delete(this.sceneViewer)}catch(t){}this.sceneViewer=null,window._sceneViewerInstances&&0===window._sceneViewerInstances.size&&delete window._sceneViewerInstances}catch(t){}}},{key:"clearPendingOperations",value:function(){this.timeoutIds&&(this.timeoutIds.forEach(function(t){return clearTimeout(t)}),this.timeoutIds.clear()),this.intervalIds&&(this.intervalIds.forEach(function(t){return clearInterval(t)}),this.intervalIds.clear()),this.isDev}},{key:"forceGarbageCollectionHint",value:function(){this.isDev&&setTimeout(function(){window.gc?window.gc():new Array(1e6).fill(0).length=0},100)}},{key:"addTimeout",value:function(t){this.timeoutIds.add(t)}},{key:"addInterval",value:function(t){this.intervalIds.add(t)}},{key:"removeTimeout",value:function(t){this.timeoutIds.delete(t)}},{key:"removeInterval",value:function(t){this.intervalIds.delete(t)}}])}();exports.HotReloadManager=i;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"t",{value:!0});var t=require("../../../_virtual/_rollupPluginBabelHelpers.js"),e=function(){return t.createClass(function e(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;t.classCallCheck(this,e),this.renderer=i,this.stats={fps:{current:0,average:0,min:1/0,max:0,history:[]},frameTime:{current:0,average:0,min:1/0,max:0,history:[]},memory:{geometries:0,textures:0,programs:0,heapUsed:0,heapTotal:0},drawCalls:{current:0,average:0,triangles:0,points:0,lines:0},gpu:{memoryUsage:0,extensions:[]},scene:{objects:0,lights:0,meshes:0,materials:0,visible:0}},this.frameCount=0,this.lastTime=performance.now(),this.updateInterval=100,this.maxHistoryLength=300,this.thresholds={fps:{good:55,warning:45,critical:30},frameTime:{good:16.67,warning:22.22,critical:33.33},memory:{warning:200,critical:300},drawCalls:{warning:500,critical:1e3}},this.callbacks=new Map,this.isMonitoring=!1,this.update=this.update.bind(this),this.getGPUInfo=this.getGPUInfo.bind(this)},[{key:"start",value:function(){this.isMonitoring=!0,this.lastTime=performance.now(),this.getGPUInfo()}},{key:"stop",value:function(){this.isMonitoring=!1}},{key:"update",value:function(){if(this.isMonitoring){var t=performance.now(),e=t-this.lastTime;this.frameCount++;var i=1e3/e,s=e;this.stats.fps.current=i,this.stats.frameTime.current=s,this.addToHistory(this.stats.fps,i),this.addToHistory(this.stats.frameTime,s),this.frameCount%this.updateInterval===0&&(this.updateAverages(),this.updateMemoryStats(),this.updateDrawCallStats(),this.updateSceneStats(),this.checkThresholds()),this.lastTime=t}}},{key:"addToHistory",value:function(t,e){t.history.push(e),t.history.length>this.maxHistoryLength&&t.history.shift(),t.min=Math.min(t.min,e),t.max=Math.max(t.max,e)}},{key:"updateAverages",value:function(){this.stats.fps.history.length>0&&(this.stats.fps.average=this.stats.fps.history.reduce(function(t,e){return t+e},0)/this.stats.fps.history.length),this.stats.frameTime.history.length>0&&(this.stats.frameTime.average=this.stats.frameTime.history.reduce(function(t,e){return t+e},0)/this.stats.frameTime.history.length)}},{key:"updateMemoryStats",value:function(){var t;if(this.renderer){var e=this.renderer.info;this.stats.memory.geometries=e.memory.geometries,this.stats.memory.textures=e.memory.textures,this.stats.memory.programs=(null===(t=e.programs)||void 0===t?void 0:t.length)||0,performance.memory&&(this.stats.memory.heapUsed=Math.round(performance.memory.usedJSHeapSize/1024/1024),this.stats.memory.heapTotal=Math.round(performance.memory.totalJSHeapSize/1024/1024))}}},{key:"updateDrawCallStats",value:function(){if(this.renderer){var t=this.renderer.info.render;this.stats.drawCalls.current=t.calls,this.stats.drawCalls.triangles=t.triangles,this.stats.drawCalls.points=t.points,this.stats.drawCalls.lines=t.lines,this.stats.drawCalls.history||(this.stats.drawCalls.history=[]),this.addToHistory(this.stats.drawCalls,t.calls),this.stats.drawCalls.history.length>0&&(this.stats.drawCalls.average=this.stats.drawCalls.history.reduce(function(t,e){return t+e},0)/this.stats.drawCalls.history.length)}}},{key:"updateSceneStats",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(e){var i,s=0,n=0,a=0,r=new Set,o=0,l=t.createForOfIteratorHelper(e.children);try{for(l.s();!(i=l.n()).done;){var h=i.value;s++,h.visible&&o++,h.isLight&&n++,h.isMesh&&(a++,h.material&&(Array.isArray(h.material)?h.material.forEach(function(t){return r.add(t.uuid)}):r.add(h.material.uuid)))}}catch(t){l.e(t)}finally{l.f()}this.stats.scene={objects:s,lights:n,meshes:a,materials:r.size,visible:o}}}},{key:"getGPUInfo",value:function(){if(this.renderer){var t=this.renderer.getContext();this.stats.gpu.extensions=t.getSupportedExtensions()||[];var e=t.getExtension("WEBGL_debug_renderer_info");e&&(this.stats.gpu.renderer=t.getParameter(e.UNMASKED_RENDERER_WEBGL),this.stats.gpu.vendor=t.getParameter(e.UNMASKED_VENDOR_WEBGL))}}},{key:"checkThresholds",value:function(){var t=[];this.stats.fps.average<this.thresholds.fps.critical?t.push({type:"critical",category:"FPS",value:this.stats.fps.average.toFixed(1),threshold:this.thresholds.fps.critical}):this.stats.fps.average<this.thresholds.fps.warning&&t.push({type:"warning",category:"FPS",value:this.stats.fps.average.toFixed(1),threshold:this.thresholds.fps.warning}),this.stats.frameTime.average>this.thresholds.frameTime.critical?t.push({type:"critical",category:"Frame Time",value:this.stats.frameTime.average.toFixed(2)+"ms",threshold:this.thresholds.frameTime.critical+"ms"}):this.stats.frameTime.average>this.thresholds.frameTime.warning&&t.push({type:"warning",category:"Frame Time",value:this.stats.frameTime.average.toFixed(2)+"ms",threshold:this.thresholds.frameTime.warning+"ms"}),this.stats.memory.heapUsed>this.thresholds.memory.critical?t.push({type:"critical",category:"Memory",value:this.stats.memory.heapUsed+"MB",threshold:this.thresholds.memory.critical+"MB"}):this.stats.memory.heapUsed>this.thresholds.memory.warning&&t.push({type:"warning",category:"Memory",value:this.stats.memory.heapUsed+"MB",threshold:this.thresholds.memory.warning+"MB"}),this.stats.drawCalls.average>this.thresholds.drawCalls.critical?t.push({type:"critical",category:"Draw Calls",value:Math.round(this.stats.drawCalls.average),threshold:this.thresholds.drawCalls.critical}):this.stats.drawCalls.average>this.thresholds.drawCalls.warning&&t.push({type:"warning",category:"Draw Calls",value:Math.round(this.stats.drawCalls.average),threshold:this.thresholds.drawCalls.warning}),t.length>0&&this.triggerCallback("warning",t)}},{key:"on",value:function(t,e){this.callbacks.has(t)||this.callbacks.set(t,[]),this.callbacks.get(t).push(e)}},{key:"off",value:function(t,e){if(this.callbacks.has(t)){var i=this.callbacks.get(t),s=i.indexOf(e);s>-1&&i.splice(s,1)}}},{key:"triggerCallback",value:function(t,e){this.callbacks.has(t)&&this.callbacks.get(t).forEach(function(t){return t(e)})}},{key:"getSummary",value:function(){return{fps:{current:Math.round(this.stats.fps.current),average:Math.round(this.stats.fps.average),min:Math.round(this.stats.fps.min),max:Math.round(this.stats.fps.max)},frameTime:{current:this.stats.frameTime.current.toFixed(2)+"ms",average:this.stats.frameTime.average.toFixed(2)+"ms"},memory:{geometries:this.stats.memory.geometries,textures:this.stats.memory.textures,heapUsed:this.stats.memory.heapUsed+"MB",heapTotal:this.stats.memory.heapTotal+"MB"},drawCalls:{current:this.stats.drawCalls.current,average:Math.round(this.stats.drawCalls.average),triangles:this.stats.drawCalls.triangles.toLocaleString()},scene:this.stats.scene}}},{key:"logSummary",value:function(){this.getSummary()}},{key:"reset",value:function(){var t=this;Object.keys(this.stats).forEach(function(e){t.stats[e].history&&(t.stats[e].history=[]),void 0!==t.stats[e].min&&(t.stats[e].min=1/0,t.stats[e].max=0,t.stats[e].average=0)}),this.frameCount=0}},{key:"exportData",value:function(){return{timestamp:(new Date).toISOString(),stats:JSON.parse(JSON.stringify(this.stats)),thresholds:this.thresholds,frameCount:this.frameCount}}}])}(),i=function(){return t.createClass(function e(i){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document.body,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"dark";t.classCallCheck(this,e),this.monitor=i,this.container=s,this.element=null,this.isVisible=!1,this.updateInterval=null,this.theme=n},[{key:"show",value:function(){var t=this;this.cleanupExistingElements(),this.element&&this.hide(),this.element=document.createElement("div"),this.element.id="performance-monitor-ui",this.element.innerHTML=this.getHTML(),this.addStyles(),this.container.appendChild(this.element),this.isVisible=!0,this.startUpdating(),this.element.querySelector("#perf-toggle").addEventListener("click",function(){return t.toggleDetails()}),this.toggleDetails()}},{key:"cleanupExistingElements",value:function(){document.querySelectorAll("#performance-monitor-ui").forEach(function(t){try{t.parentNode&&t.parentNode.removeChild(t)}catch(t){}})}},{key:"hide",value:function(){this.stopUpdating(),this.removeDOMElement(),this.isVisible=!1}},{key:"dispose",value:function(){this.hide(),this.cleanupExistingElements(),this.monitor=null,this.container=null,this.element=null}},{key:"stopUpdating",value:function(){this.updateInterval&&(clearInterval(this.updateInterval),this.updateInterval=null)}},{key:"removeDOMElement",value:function(){if(this.element){try{this.element.parentNode&&this.container&&this.container.contains(this.element)?this.container.removeChild(this.element):this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch(t){try{this.element.remove&&this.element.remove()}catch(t){}}this.element=null}}},{key:"toggleDetails",value:function(){var t=this.element.querySelector("#perf-details"),e="none"===t.style.display;t.style.display=e?"block":"none",this.element.querySelector("#perf-toggle").textContent=e?"▼":"▲"}},{key:"startUpdating",value:function(){var t=this;this.updateInterval=setInterval(function(){t.isVisible&&t.element&&t.updateContent()},500)}},{key:"updateContent",value:function(){var t=this.monitor.getSummary();this.updateElement("#fps-value",t.fps.current),this.updateElement("#frametime-value",t.frameTime.current),this.updateElement("#memory-value",t.memory.heapUsed),this.updateElement("#drawcalls-value",t.drawCalls.current),this.updateElement("#fps-avg",t.fps.average),this.updateElement("#fps-min",t.fps.min),this.updateElement("#fps-max",t.fps.max),this.updateElement("#geometries-value",t.memory.geometries),this.updateElement("#textures-value",t.memory.textures),this.updateElement("#triangles-value",t.drawCalls.triangles),this.updateElement("#objects-value",t.scene.objects),this.updateElement("#meshes-value",t.scene.meshes),this.updatePerformanceIndicators(t)}},{key:"updateElement",value:function(t,e){var i=this.element.querySelector(t);i&&(i.textContent=e)}},{key:"updatePerformanceIndicators",value:function(t){var e=this.element.querySelector("#fps-value"),i=this.element.querySelector("#frametime-value");if(e){var s=t.fps.current;e.className=this.getPerformanceClass("fps",s)}if(i){var n=parseFloat(t.frameTime.current);i.className=this.getPerformanceClass("frameTime",n)}}},{key:"getPerformanceClass",value:function(t,e){var i=this.monitor.thresholds[t];return"fps"===t?e>=i.good?"perf-good":e>=i.warning?"perf-warning":"perf-critical":"frameTime"===t?e<=i.good?"perf-good":e<=i.warning?"perf-warning":"perf-critical":""}},{key:"getHTML",value:function(){return'\n <div class="perf-header">\n <span class="perf-title">Performance</span>\n <button id="perf-toggle">▼</button>\n </div>\n <div class="perf-main">\n <div class="perf-stat">\n <span class="perf-label">FPS:</span>\n <span id="fps-value" class="perf-value">0</span>\n </div>\n <div class="perf-stat">\n <span class="perf-label">Frame:</span>\n <span id="frametime-value" class="perf-value">0ms</span>\n </div>\n <div class="perf-stat">\n <span class="perf-label">Memory:</span>\n <span id="memory-value" class="perf-value">0MB</span>\n </div>\n <div class="perf-stat">\n <span class="perf-label">Calls:</span>\n <span id="drawcalls-value" class="perf-value">0</span>\n </div>\n </div>\n <div id="perf-details" class="perf-details">\n <div class="perf-section">\n <div class="perf-section-title">FPS Stats</div>\n <div class="perf-detail">Avg: <span id="fps-avg">0</span></div>\n <div class="perf-detail">Min: <span id="fps-min">0</span></div>\n <div class="perf-detail">Max: <span id="fps-max">0</span></div>\n </div>\n <div class="perf-section">\n <div class="perf-section-title">Memory</div>\n <div class="perf-detail">Geometries: <span id="geometries-value">0</span></div>\n <div class="perf-detail">Textures: <span id="textures-value">0</span></div>\n </div>\n <div class="perf-section">\n <div class="perf-section-title">Rendering</div>\n <div class="perf-detail">Triangles: <span id="triangles-value">0</span></div>\n <div class="perf-detail">Objects: <span id="objects-value">0</span></div>\n <div class="perf-detail">Meshes: <span id="meshes-value">0</span></div>\n </div>\n </div>\n '}},{key:"addStyles",value:function(){if(!document.getElementById("performance-monitor-styles")){var t=document.createElement("style");t.id="performance-monitor-styles";var e={dark:{background:"rgba(0, 0, 0, 0.8)",color:"white",borderColor:"rgba(255, 255, 255, 0.1)",separatorColor:"rgba(255, 255, 255, 0.2)",sectionTitleColor:"#FFC107",goodColor:"#4CAF50",warningColor:"#FF9800",criticalColor:"#F44336"},light:{background:"rgba(255, 255, 255, 0.95)",color:"#333333",borderColor:"rgba(0, 0, 0, 0.15)",separatorColor:"rgba(0, 0, 0, 0.1)",sectionTitleColor:"#1565C0",goodColor:"#2E7D32",warningColor:"#E65100",criticalColor:"#C62828"}},i=e[this.theme]||e.dark;t.textContent=" #performance-monitor-ui {\n position: fixed;\n bottom: 10px;\n right: 10px;\n background: ".concat(i.background,";\n color: ").concat(i.color,";\n font-family: 'Consolas', 'Monaco', 'Courier New', monospace;\n font-size: 12px;\n padding: 10px;\n border-radius: 5px;\n z-index: 10000;\n min-width: 150px;\n backdrop-filter: blur(5px);\n border: 1px solid ").concat(i.borderColor,";\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n }\n\n .perf-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 8px;\n border-bottom: 1px solid ").concat(i.separatorColor,";\n padding-bottom: 5px;\n }\n\n .perf-title {\n font-weight: bold;\n font-size: 14px;\n }\n\n #perf-toggle {\n background: none;\n border: none;\n color: ").concat(i.color,";\n cursor: pointer;\n font-size: 12px;\n padding: 0;\n width: 20px;\n height: 20px;\n }\n\n .perf-main {\n display: grid;\n grid-template-columns: 1fr;\n gap: 4px;\n }\n\n .perf-stat {\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n\n .perf-label {\n opacity: 0.8;\n }\n\n .perf-value {\n font-weight: bold;\n text-align: right;\n min-width: 50px;\n } .perf-good {\n color: ").concat(i.goodColor,";\n }\n\n .perf-warning {\n color: ").concat(i.warningColor,";\n }\n\n .perf-critical {\n color: ").concat(i.criticalColor,";\n }\n\n .perf-details {\n margin-top: 10px;\n padding-top: 8px;\n border-top: 1px solid ").concat(i.separatorColor,";\n }\n\n .perf-section {\n margin-bottom: 8px;\n }\n\n .perf-section-title {\n font-weight: bold;\n font-size: 11px;\n margin-bottom: 3px;\n color: ").concat(i.sectionTitleColor,";\n }\n\n .perf-detail {\n font-size: 10px;\n display: flex;\n justify-content: space-between;\n margin-bottom: 2px;\n opacity: 0.9;\n }\n "),document.head.appendChild(t)}}},{key:"setTheme",value:function(t){if("light"===t||"dark"===t){this.theme=t;var e=document.getElementById("performance-monitor-styles");e&&e.remove(),this.addStyles()}}}],[{key:"cleanupAllInstances",value:function(){var t=document.querySelectorAll("#performance-monitor-ui"),e=0;if(t.forEach(function(t){try{t.parentNode&&(t.parentNode.removeChild(t),e++)}catch(t){}}),0===document.querySelectorAll("#performance-monitor-ui").length){var i=document.getElementById("performance-monitor-styles");i&&i.remove()}return e}}])}();exports.PerformanceMonitor=e,exports.PerformanceUI=i;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"t",{value:!0});var t=require("../../_virtual/_rollupPluginBabelHelpers.js");require("three");var e=require("../../node_modules/three/examples/jsm/loaders/GLTFLoader.js"),i=function(){return t.createClass(function i(){t.classCallCheck(this,i),this.modelCache=new Map,this.loadingPromises=new Map,this.gltfLoader=new e.GLTFLoader,this.isPreloading=!1,this.preloadingPromise=null,this.componentDictionary=null},[{key:"preloadAllModels",value:(r=t.asyncToGenerator(t.regenerator().m(function e(i){var n,r,s=this;return t.regenerator().w(function(e){for(;;)switch(e.n){case 0:if(!this.isPreloading){e.n=1;break}return e.a(2,this.preloadingPromise);case 1:if(i&&"object"===t.typeof(i)){e.n=2;break}return e.a(2,Promise.reject(new Error("Invalid component dictionary")));case 2:return this.componentDictionary=i,this.isPreloading=!0,n=[],r=[],Object.keys(i).forEach(function(t){var e=i[t];e&&e.modelKey&&(n.includes(e.modelKey)||n.push(e.modelKey))}),n.forEach(function(t){r.push(s.preloadSingleModel(t))}),this.preloadingPromise=Promise.allSettled(r).then(function(t){var e=t.filter(function(t){return"fulfilled"===t.status}).length,i=t.filter(function(t){return"rejected"===t.status}).length;return s.isPreloading=!1,{successful:e,failed:i,total:n.length,cache:s.modelCache}}),e.a(2,this.preloadingPromise)}},e,this)})),function(t){return r.apply(this,arguments)})},{key:"preloadSingleModel",value:(n=t.asyncToGenerator(t.regenerator().m(function e(i){var n,r=this;return t.regenerator().w(function(t){for(;;)switch(t.n){case 0:if(!this.modelCache.has(i)){t.n=1;break}return t.a(2,this.modelCache.get(i));case 1:if(!this.loadingPromises.has(i)){t.n=2;break}return t.a(2,this.loadingPromises.get(i));case 2:return n=new Promise(function(t,e){r.gltfLoader.load("/library/models/".concat(i),function(e){r.modelCache.set(i,e.scene),r.loadingPromises.delete(i),t(e.scene)},function(t){t.loaded,t.total},function(t){r.loadingPromises.delete(i),e(t)})}),this.loadingPromises.set(i,n),t.a(2,n)}},e,this)})),function(t){return n.apply(this,arguments)})},{key:"getCachedModel",value:function(t){return this.modelCache.has(t)?this.modelCache.get(t).clone():null}},{key:"getCachedModelWithDimensions",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(this.modelCache.has(t)){var i=this.modelCache.get(t).clone();if(e&&this.componentDictionary){var n=this.componentDictionary[e];n&&n.boundingBox&&(i.userData||(i.userData={}),i.userData.dimensions={x:n.boundingBox.x,y:n.boundingBox.y,z:n.boundingBox.z})}return i}return null}},{key:"addDimensionsToModel",value:function(t,e){if(!t||!e)return t;if(this.componentDictionary){var i=this.componentDictionary[e];i&&i.boundingBox&&(t.userData||(t.userData={}),t.userData.dimensions={x:i.boundingBox.x,y:i.boundingBox.y,z:i.boundingBox.z})}return t}},{key:"getStatus",value:function(){return{isPreloading:this.isPreloading,cachedModels:Array.from(this.modelCache.keys()),totalCached:this.modelCache.size,currentlyLoading:Array.from(this.loadingPromises.keys())}}},{key:"reloadModel",value:(i=t.asyncToGenerator(t.regenerator().m(function e(i){return t.regenerator().w(function(t){for(;;)if(0===t.n)return this.modelCache.delete(i),this.loadingPromises.delete(i),t.a(2,this.preloadSingleModel(i))},e,this)})),function(t){return i.apply(this,arguments)})},{key:"clearCache",value:function(){this.modelCache.forEach(function(t,e){t&&t.traverse&&t.traverse(function(t){t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(function(t){return t.dispose()}):t.material.dispose())})}),this.modelCache.clear(),this.loadingPromises.clear(),this.isPreloading=!1,this.preloadingPromise=null}},{key:"getCacheStats",value:function(){var t={totalModels:this.modelCache.size,loadingModels:this.loadingPromises.size,isPreloading:this.isPreloading,memoryUsage:0};return this.modelCache.forEach(function(e){e&&e.traverse&&e.traverse(function(e){var i;e.geometry&&(t.memoryUsage+=12*((null===(i=e.geometry.attributes.position)||void 0===i?void 0:i.count)||0))})}),t}}]);var i,n,r}(),n=new i;exports.ModelPreloader=i,exports.default=n;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"t",{value:!0});var t=require("../../_virtual/_rollupPluginBabelHelpers.js"),i=function(){return t.createClass(function i(n){var e=this;t.classCallCheck(this,i),t.defineProperty(this,"draw",{line:function(t,i,n,r){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};e.ctx&&(e.save(),e.setStyles(o),e.ctx.beginPath(),e.ctx.moveTo(t,i),e.ctx.lineTo(n,r),e.ctx.stroke(),e.restore())},rect:function(t,i,n,r){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};e.ctx&&(e.save(),e.setStyles(o),o.fillStyle&&e.ctx.fillRect(t,i,n,r),o.strokeStyle&&e.ctx.strokeRect(t,i,n,r),e.restore())},circle:function(t,i,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};e.ctx&&(e.save(),e.setStyles(r),e.ctx.beginPath(),e.ctx.arc(t,i,n,0,2*Math.PI),r.fillStyle&&e.ctx.fill(),r.strokeStyle&&e.ctx.stroke(),e.restore())},ellipse:function(t,i,n,r){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};e.ctx&&(e.save(),e.setStyles(s),e.ctx.beginPath(),e.ctx.ellipse(t,i,n,r,o,0,2*Math.PI),s.fillStyle&&e.ctx.fill(),s.strokeStyle&&e.ctx.stroke(),e.restore())},polygon:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e.ctx&&!(t.length<3)){e.save(),e.setStyles(i),e.ctx.beginPath(),e.ctx.moveTo(t[0][0],t[0][1]);for(var n=1;n<t.length;n++)e.ctx.lineTo(t[n][0],t[n][1]);e.ctx.closePath(),i.fillStyle&&e.ctx.fill(),i.strokeStyle&&e.ctx.stroke(),e.restore()}},bezierCurve:function(t,i,n,r,o,s,u,a){var h=arguments.length>8&&void 0!==arguments[8]?arguments[8]:{};e.ctx&&(e.save(),e.setStyles(h),e.ctx.beginPath(),e.ctx.moveTo(t,i),e.ctx.bezierCurveTo(n,r,o,s,u,a),e.ctx.stroke(),e.restore())},text:function(t,i,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};e.ctx&&(e.save(),e.setStyles(r),r.fillStyle&&e.ctx.fillText(t,i,n),r.strokeStyle&&e.ctx.strokeText(t,i,n),e.restore())},image:function(t,i,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;e.ctx&&t&&(r&&o?e.ctx.drawImage(t,i,n,r,o):e.ctx.drawImage(t,i,n))}}),t.defineProperty(this,"transform",{translate:function(t,i){e.ctx&&e.ctx.translate(t,i)},rotate:function(t){e.ctx&&e.ctx.rotate(t)},scale:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;e.ctx&&e.ctx.scale(t,i)},transform:function(t,i,n,r,o,s){e.ctx&&e.ctx.transform(t,i,n,r,o,s)},setTransform:function(t,i,n,r,o,s){e.ctx&&e.ctx.setTransform(t,i,n,r,o,s)},resetTransform:function(){e.ctx&&e.ctx.resetTransform()}}),t.defineProperty(this,"gradient",{linear:function(t,i,n,r,o){if(!e.ctx)return null;var s=e.ctx.createLinearGradient(t,i,n,r);return o.forEach(function(t){s.addColorStop(t.offset,t.color)}),s},radial:function(t,i,n,r,o,s,u){if(!e.ctx)return null;var a=e.ctx.createRadialGradient(t,i,n,r,o,s);return u.forEach(function(t){a.addColorStop(t.offset,t.color)}),a}}),t.defineProperty(this,"pattern",{fromImage:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"repeat";return e.ctx&&t?e.ctx.createPattern(t,i):null},fromCanvas:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"repeat";return e.ctx&&t?e.ctx.createPattern(t,i):null}}),t.defineProperty(this,"path",{begin:function(){e.ctx&&e.ctx.beginPath()},close:function(){e.ctx&&e.ctx.closePath()},moveTo:function(t,i){e.ctx&&e.ctx.moveTo(t,i)},lineTo:function(t,i){e.ctx&&e.ctx.lineTo(t,i)},arc:function(t,i,n,r,o){var s=arguments.length>5&&void 0!==arguments[5]&&arguments[5];e.ctx&&e.ctx.arc(t,i,n,r,o,s)},quadraticCurveTo:function(t,i,n,r){e.ctx&&e.ctx.quadraticCurveTo(t,i,n,r)},bezierCurveTo:function(t,i,n,r,o,s){e.ctx&&e.ctx.bezierCurveTo(t,i,n,r,o,s)},fill:function(){e.ctx&&e.ctx.fill()},stroke:function(){e.ctx&&e.ctx.stroke()},clip:function(){e.ctx&&e.ctx.clip()}}),t.defineProperty(this,"measure",{textWidth:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!e.ctx)return 0;if(i){var n=e.ctx.font;e.ctx.font=i;var r=e.ctx.measureText(t).width;return e.ctx.font=n,r}return e.ctx.measureText(t).width},textMetrics:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!e.ctx)return null;if(i){var n=e.ctx.font;e.ctx.font=i;var r=e.ctx.measureText(t);return e.ctx.font=n,r}return e.ctx.measureText(t)}}),t.defineProperty(this,"export",{toDataURL:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"image/png",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.92;return e.canvas?e.canvas.toDataURL(t,i):""},toBlob:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"image/png",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.92;return e.canvas?new Promise(function(n){e.canvas.toBlob(n,t,i)}):Promise.resolve(null)}}),this.canvas=n,this.ctx=null==n?void 0:n.getContext("2d"),this.width=(null==n?void 0:n.width)||800,this.height=(null==n?void 0:n.height)||600,this.pixelRatio=window.devicePixelRatio||1,this.state={transforms:[],styles:[]},this.setupCanvas()},[{key:"setupCanvas",value:function(){this.canvas&&this.ctx&&(this.canvas.width=this.width*this.pixelRatio,this.canvas.height=this.height*this.pixelRatio,this.ctx.scale(this.pixelRatio,this.pixelRatio),this.canvas.style.width=this.width+"px",this.canvas.style.height=this.height+"px")}},{key:"clear",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.ctx&&(t?(this.ctx.fillStyle=t,this.ctx.fillRect(0,0,this.width,this.height)):this.ctx.clearRect(0,0,this.width,this.height))}},{key:"save",value:function(){this.ctx&&(this.ctx.save(),this.state.transforms.push(this.ctx.getTransform()),this.state.styles.push({fillStyle:this.ctx.fillStyle,strokeStyle:this.ctx.strokeStyle,lineWidth:this.ctx.lineWidth,font:this.ctx.font,textAlign:this.ctx.textAlign,textBaseline:this.ctx.textBaseline}))}},{key:"restore",value:function(){this.ctx&&(this.ctx.restore(),this.state.transforms.pop(),this.state.styles.pop())}},{key:"setStyles",value:function(t){var i=this;this.ctx&&Object.keys(t).forEach(function(n){void 0!==i.ctx[n]&&(i.ctx[n]=t[n])})}},{key:"resize",value:function(t,i){this.width=t,this.height=i,this.setupCanvas()}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height,pixelRatio:this.pixelRatio}}},{key:"dispose",value:function(){this.state.transforms=[],this.state.styles=[],this.canvas=null,this.ctx=null}}])}();exports.Rendering2D=i;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"i",{value:!0});var i=require("../../_virtual/_rollupPluginBabelHelpers.js"),e=require("three"),t=require("../core/debugLogger.js");function n(i){if(i&&i.i)return i;var e=Object.create(null);return i&&Object.keys(i).forEach(function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:function(){return i[t]}})}}),e.default=i,Object.freeze(e)}var r=n(e),o=function(){return i.createClass(function e(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i.classCallCheck(this,e),i.defineProperty(this,"lighting",{addAmbient:function(){var i,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4210752,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.4,o=new r.AmbientLight(e,n);return null===(i=t.scene)||void 0===i||i.add(o),o},addDirectional:function(){var e,n,o,s,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},v=a.color,d=void 0===v?16777215:v,u=a.intensity,h=void 0===u?1:u,l=a.position,c=void 0===l?[10,10,5]:l,f=a.target,p=void 0===f?[0,0,0]:f,w=a.castShadow,g=void 0===w||w,m=a.shadowMapSize,y=void 0===m?2048:m,b=a.shadowCameraNear,M=void 0===b?.5:b,x=a.shadowCameraFar,S=void 0===x?50:x,j=a.shadowCameraLeft,k=void 0===j?-10:j,D=a.shadowCameraRight,P=void 0===D?10:D,_=a.shadowCameraTop,R=void 0===_?10:_,O=a.shadowCameraBottom,B=void 0===O?-10:O,C=new r.DirectionalLight(d,h);return(e=C.position).set.apply(e,i.toConsumableArray(c)),(n=C.target.position).set.apply(n,i.toConsumableArray(p)),g&&(C.castShadow=!0,C.shadow.mapSize.width=y,C.shadow.mapSize.height=y,C.shadow.camera.near=M,C.shadow.camera.far=S,C.shadow.camera.left=k,C.shadow.camera.right=P,C.shadow.camera.top=R,C.shadow.camera.bottom=B),null===(o=t.scene)||void 0===o||o.add(C),null===(s=t.scene)||void 0===s||s.add(C.target),C},addPoint:function(){var e,n,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=o.color,a=void 0===s?16777215:s,v=o.intensity,d=void 0===v?1:v,u=o.distance,h=void 0===u?0:u,l=o.decay,c=void 0===l?2:l,f=o.position,p=void 0===f?[0,10,0]:f,w=o.castShadow,g=void 0!==w&&w,m=o.shadowMapSize,y=void 0===m?1024:m,b=new r.PointLight(a,d,h,c);return(e=b.position).set.apply(e,i.toConsumableArray(p)),g&&(b.castShadow=!0,b.shadow.mapSize.width=y,b.shadow.mapSize.height=y,b.shadow.camera.near=.1,b.shadow.camera.far=25),null===(n=t.scene)||void 0===n||n.add(b),b},addSpot:function(){var e,n,o,s,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},v=a.color,d=void 0===v?16777215:v,u=a.intensity,h=void 0===u?1:u,l=a.distance,c=void 0===l?0:l,f=a.angle,p=void 0===f?Math.PI/3:f,w=a.penumbra,g=void 0===w?0:w,m=a.decay,y=void 0===m?2:m,b=a.position,M=void 0===b?[0,10,0]:b,x=a.target,S=void 0===x?[0,0,0]:x,j=a.castShadow,k=void 0===j||j,D=a.shadowMapSize,P=void 0===D?1024:D,_=new r.SpotLight(d,h,c,p,g,y);return(e=_.position).set.apply(e,i.toConsumableArray(M)),(n=_.target.position).set.apply(n,i.toConsumableArray(S)),k&&(_.castShadow=!0,_.shadow.mapSize.width=P,_.shadow.mapSize.height=P,_.shadow.camera.near=.5,_.shadow.camera.far=50),null===(o=t.scene)||void 0===o||o.add(_),null===(s=t.scene)||void 0===s||s.add(_.target),_}}),i.defineProperty(this,"materials",{createStandard:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r.MeshStandardMaterial(i.objectSpread2({color:16777215,metalness:0,roughness:.5},e))},createPhysical:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r.MeshPhysicalMaterial(i.objectSpread2({color:16777215,metalness:0,roughness:.5,clearcoat:0,clearcoatRoughness:0},e))},createBasic:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r.MeshBasicMaterial(i.objectSpread2({color:16777215},e))},createShader:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r.ShaderMaterial({vertexShader:i.vertexShader||"\n void main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:i.fragmentShader||"\n void main() {\n gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n }\n ",uniforms:i.uniforms||{}})}}),i.defineProperty(this,"geometry",{createBox:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return new r.BoxGeometry(i,e,t)},createSphere:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:32,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:16;return new r.SphereGeometry(i,e,t)},createCylinder:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:32;return new r.CylinderGeometry(i,e,t,n)},createPlane:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return new r.PlaneGeometry(i,e)}}),i.defineProperty(this,"renderTargets",{create:function(e,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=new r.WebGLRenderTarget(e,n,i.objectSpread2({minFilter:r.LinearFilter,magFilter:r.LinearFilter,format:r.RGBAFormat,type:r.UnsignedByteType},o)),a="rt_".concat(Date.now(),"_").concat(Math.random().toString(36).substr(2,9));return t.renderTargets.set(a,s),{id:a,renderTarget:s}},get:function(i){return t.renderTargets.get(i)},remove:function(i){var e=t.renderTargets.get(i);e&&(e.dispose(),t.renderTargets.delete(i))}}),i.defineProperty(this,"animation",{createMixer:function(i){return t.animationMixer=new r.AnimationMixer(i),t.animationMixer},addClip:function(i){if(!t.animationMixer)throw new Error("Animation mixer not created");return t.animationMixer.clipAction(i)},update:function(i){t.animationMixer&&t.animationMixer.update(i)}}),i.defineProperty(this,"screenshot",{toDataURL:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"image/png",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return t.renderer?t.renderer.domElement.toDataURL(i,e):""},toBlob:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"image/png",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return t.renderer?new Promise(function(n){t.renderer.domElement.toBlob(n,i,e)}):Promise.resolve(null)}}),this.options=i.objectSpread2({antialias:!0,alpha:!0,shadowMapEnabled:!0,shadowMapType:r.PCFSoftShadowMap,toneMapping:r.ACESFilmicToneMapping,toneMappingExposure:1,outputColorSpace:r.SRGBColorSpace},n),this.renderer=null,this.scene=null,this.camera=null,this.controls=null,this.renderTargets=new Map,this.postProcessing={composer:null,passes:[]},this.stats={triangles:0,geometries:0,textures:0,calls:0,frameTime:0},this.animationMixer=null,this.clock=new r.Clock},[{key:"initializeRenderer",value:function(i){this.renderer&&this.dispose();try{return this.renderer=new r.WebGLRenderer({antialias:this.options.antialias,alpha:this.options.alpha,preserveDrawingBuffer:!1,powerPreference:"high-performance"}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.setSize(i.clientWidth,i.clientHeight),this.renderer.setClearColor(0,0),this.options.shadowMapEnabled&&(this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=this.options.shadowMapType),this.renderer.toneMapping=this.options.toneMapping,this.renderer.toneMappingExposure=this.options.toneMappingExposure,this.renderer.outputColorSpace=this.options.outputColorSpace,this.renderer.useLegacyLights=!1,i.appendChild(this.renderer.domElement),t.logger.info("✅ 3D Renderer initialized"),this.renderer}catch(i){throw t.logger.error("❌ Failed to initialize 3D renderer:",i),i}}},{key:"createScene",value:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=i.background,n=void 0===e?null:e,o=i.environment,s=void 0===o?null:o,a=i.fog,v=void 0===a?null:a;return this.scene=new r.Scene,n&&("string"==typeof n?this.scene.background=new r.Color(n):n.isTexture&&(this.scene.background=n)),s&&s.isTexture&&(this.scene.environment=s),v&&("linear"===v.type?this.scene.fog=new r.Fog(v.color,v.near,v.far):"exponential"===v.type&&(this.scene.fog=new r.FogExp2(v.color,v.density))),t.logger.info("✅ 3D Scene created"),this.scene}},{key:"createCamera",value:function(){var e,n,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"perspective",s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=null===(e=this.renderer)||void 0===e||null===(e=e.domElement)||void 0===e?void 0:e.parentElement,v=a?a.clientWidth/a.clientHeight:1;if("perspective"===o){var d=s.fov,u=void 0===d?75:d,h=s.near,l=void 0===h?.1:h,c=s.far,f=void 0===c?1e3:c;s.position,this.camera=new r.PerspectiveCamera(u,v,l,f)}else if("orthographic"===o){var p=s.left,w=void 0===p?-10:p,g=s.right,m=void 0===g?10:g,y=s.top,b=void 0===y?10:y,M=s.bottom,x=void 0===M?-10:M,S=s.near,j=void 0===S?.1:S,k=s.far,D=void 0===k?1e3:k;s.position,this.camera=new r.OrthographicCamera(w,m,b,x,j,D)}this.camera&&((n=this.camera.position).set.apply(n,i.toConsumableArray(position)),t.logger.info("✅ ".concat(o," camera created")));return this.camera}},{key:"render",value:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(this.renderer){var n=i||this.scene,r=e||this.camera;if(n&&r){var o=performance.now(),s=this.clock.getDelta();this.animation.update(s),this.renderer.render(n,r,t),this.stats.frameTime=performance.now()-o,this.updateRenderStats()}}}},{key:"updateRenderStats",value:function(){if(this.renderer){var i=this.renderer.info;this.stats.triangles=i.render.triangles,this.stats.geometries=i.memory.geometries,this.stats.textures=i.memory.textures,this.stats.calls=i.render.calls}}},{key:"getRenderStats",value:function(){return i.objectSpread2({},this.stats)}},{key:"resize",value:function(i,e){if(this.renderer){if(this.renderer.setSize(i,e),this.camera){if(this.camera.isPerspectiveCamera)this.camera.aspect=i/e;else if(this.camera.isOrthographicCamera){var t=i/e;this.camera.left=-10*t,this.camera.right=10*t,this.camera.top=10,this.camera.bottom=-10}this.camera.updateProjectionMatrix()}this.renderTargets.forEach(function(t){t.setSize(i,e)})}}},{key:"dispose",value:function(){this.renderTargets.forEach(function(i){i.dispose()}),this.renderTargets.clear(),this.animationMixer&&(this.animationMixer.stopAllAction(),this.animationMixer=null),this.renderer&&(this.renderer.dispose(),this.renderer.forceContextLoss(),this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.renderer=null),this.scene=null,this.camera=null,this.controls=null,t.logger.info("✅ 3D Rendering disposed")}}])}();exports.Rendering3D=o;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function t(t,r){(null==r||r>t.length)&&(r=t.length);for(var n=0,e=Array(r);n<r;n++)e[n]=t[n];return e}function r(t){if(Array.isArray(t))return t}function n(r){if(Array.isArray(r))return t(r)}function e(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function o(t,r,n,e,o,i,u){try{var a=t[i](u),f=a.value}catch(t){return void n(t)}a.done?r(f):Promise.resolve(f).then(e,o)}function i(t){return function(){var r=this,n=arguments;return new Promise(function(e,i){var u=t.apply(r,n);function a(t){o(u,e,i,a,f,"next",t)}function f(t){o(u,e,i,a,f,"throw",t)}a(void 0)})}}function u(t,r,n){return r=p(r),T(t,m()?Reflect.construct(r,n||[],p(t).constructor):r.apply(t,n))}function a(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function f(t,r,n){if(m())return Reflect.construct.apply(null,arguments);var e=[null];e.push.apply(e,r);var o=new(t.bind.apply(t,e));return n&&I(o,n.prototype),o}function c(t,r){for(var n=0;n<r.length;n++){var e=r[n];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,k(e.key),e)}}function l(t,r,n){return r&&c(t.prototype,r),n&&c(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,r){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=N(t))||r&&t&&"number"==typeof t.length){n&&(t=n);var e=0,o=function(){};return{s:o,n:function(){return e>=t.length?{done:!0}:{done:!1,value:t[e++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return u=t.done,t},e:function(t){a=!0,i=t},f:function(){try{u||null==n.return||n.return()}finally{if(a)throw i}}}}function b(t,r,n){return(r=k(r))in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function y(){return y="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,r,n){var e=R(t,r);if(e){var o=Object.getOwnPropertyDescriptor(e,r);return o.get?o.get.call(arguments.length<3?t:n):o.value}},y.apply(null,arguments)}function p(t){return p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},p(t)}function v(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&I(t,r)}function m(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(m=function(){return!!t})()}function d(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function h(t,r){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var e,o,i,u,a=[],f=!0,c=!1;try{if(i=(n=n.call(t)).next,0===r){if(Object(n)!==n)return;f=!1}else for(;!(f=(e=i.call(n)).done)&&(a.push(e.value),a.length!==r);f=!0);}catch(t){c=!0,o=t}finally{try{if(!f&&null!=n.return&&(u=n.return(),Object(u)!==u))return}finally{if(c)throw o}}return a}}function j(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function O(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function w(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);r&&(e=e.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,e)}return n}function S(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?w(Object(n),!0).forEach(function(r){b(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function T(t,r){if(r&&("object"==typeof r||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return e(t)}function g(){var t,r,n="function"==typeof Symbol?Symbol:{},e=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,e,o,i){var f=e&&e.prototype instanceof a?e:a,c=Object.create(f.prototype);return A(c,"_invoke",function(n,e,o){var i,a,f,c=0,l=o||[],s=!1,b={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(r,n){return i=r,a=0,f=t,b.n=n,u}};function y(n,e){for(a=n,f=e,r=0;!s&&c&&!o&&r<l.length;r++){var o,i=l[r],y=b.p,p=i[2];n>3?(o=p===e)&&(f=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=t):i[0]<=y&&((o=n<2&&y<i[1])?(a=0,b.v=e,b.n=i[1]):y<p&&(o=n<3||i[0]>e||e>p)&&(i[4]=n,i[5]=e,b.n=p,a=0))}if(o||n>1)return u;throw s=!0,e}return function(o,l,p){if(c>1)throw TypeError("Generator is already running");for(s&&1===l&&y(l,p),a=l,f=p;(r=a<2?t:f)||!s;){i||(a?a<3?(a>1&&(b.n=-1),y(a,f)):b.n=f:b.v=f);try{if(c=2,i){if(a||(o="next"),r=i[o]){if(!(r=r.call(i,f)))throw TypeError("iterator result is not an object");if(!r.done)return r;f=r.value,a<2&&(a=0)}else 1===a&&(r=i.return)&&r.call(i),a<2&&(f=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=t}else if((r=(s=b.n<0)?f:n.call(e,b))!==u)break}catch(r){i=t,a=1,f=r}finally{c=1}}return{value:r,done:s}}}(n,o,i),!0),c}var u={};function a(){}function f(){}function c(){}r=Object.getPrototypeOf;var l=[][e]?r(r([][e]())):(A(r={},e,function(){return this}),r),s=c.prototype=a.prototype=Object.create(l);function b(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,A(t,o,"GeneratorFunction")),t.prototype=Object.create(s),t}return f.prototype=c,A(s,"constructor",c),A(c,"constructor",f),f.displayName="GeneratorFunction",A(c,o,"GeneratorFunction"),A(s),A(s,o,"Generator"),A(s,e,function(){return this}),A(s,"toString",function(){return"[object Generator]"}),(g=function(){return{w:i,m:b}})()}function A(t,r,n,e){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}A=function(t,r,n,e){if(r)o?o(t,r,{value:n,enumerable:!e,configurable:!e,writable:!e}):t[r]=n;else{function i(r,n){A(t,r,function(t){return this.t(r,n,t)})}i("next",0),i("throw",1),i("return",2)}},A(t,r,n,e)}function E(t){if(null!=t){var r=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}throw new TypeError(typeof t+" is not iterable")}function I(t,r){return I=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},I(t,r)}function P(t,n){return r(t)||h(t,n)||N(t,n)||j()}function R(t,r){for(;!{}.hasOwnProperty.call(t,r)&&null!==(t=p(t)););return t}function C(t,r,n,e){var o=y(p(1&e?t.prototype:t),r,n);return 2&e&&"function"==typeof o?function(t){return o.apply(n,t)}:o}function G(t){return n(t)||d(t)||N(t)||O()}function x(t,r){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var e=n.call(t,r||"default");if("object"!=typeof e)return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}function k(t){var r=x(t,"string");return"symbol"==typeof r?r:r+""}function F(t){return F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},F(t)}function N(r,n){if(r){if("string"==typeof r)return t(r,n);var e={}.toString.call(r).slice(8,-1);return"Object"===e&&r.constructor&&(e=r.constructor.name),"Map"===e||"Set"===e?Array.from(r):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?t(r,n):void 0}}export{t as arrayLikeToArray,r as arrayWithHoles,n as arrayWithoutHoles,e as assertThisInitialized,i as asyncToGenerator,u as callSuper,a as classCallCheck,f as construct,l as createClass,s as createForOfIteratorHelper,b as defineProperty,y as get,p as getPrototypeOf,v as inherits,m as isNativeReflectConstruct,d as iterableToArray,h as iterableToArrayLimit,j as nonIterableRest,O as nonIterableSpread,S as objectSpread2,T as possibleConstructorReturn,g as regenerator,A as regeneratorDefine,E as regeneratorValues,I as setPrototypeOf,P as slicedToArray,R as superPropBase,C as superPropGet,G as toConsumableArray,x as toPrimitive,k as toPropertyKey,F as typeof,N as unsupportedIterableToArray};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EventDispatcher as t,Vector3 as n,MOUSE as e,TOUCH as i,Quaternion as s,Spherical as c,Vector2 as o}from"three";const r={type:"change"},h={type:"start"},u={type:"end"};class a extends t{constructor(t,a){super(),this.object=t,this.domElement=a,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new n,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:e.ROTATE,MIDDLE:e.DOLLY,RIGHT:e.PAN},this.touches={ONE:i.ROTATE,TWO:i.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.t=null,this.getPolarAngle=function(){return k.phi},this.getAzimuthalAngle=function(){return k.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(t){t.addEventListener("keydown",Z),this.t=t},this.stopListenToKeyEvents=function(){this.t.removeEventListener("keydown",Z),this.t=null},this.saveState=function(){f.target0.copy(f.target),f.position0.copy(f.object.position),f.zoom0=f.object.zoom},this.reset=function(){f.target.copy(f.target0),f.object.position.copy(f.position0),f.object.zoom=f.zoom0,f.object.updateProjectionMatrix(),f.dispatchEvent(r),f.update(),l=w.NONE},this.update=function(){const e=new n,i=(new s).setFromUnitVectors(t.up,new n(0,1,0)),c=i.clone().invert(),o=new n,h=new s,u=2*Math.PI;return function(){const t=f.object.position;e.copy(t).sub(f.target),e.applyQuaternion(i),k.setFromVector3(e),f.autoRotate&&l===w.NONE&&_(2*Math.PI/60/60*f.autoRotateSpeed),f.enableDamping?(k.theta+=p.theta*f.dampingFactor,k.phi+=p.phi*f.dampingFactor):(k.theta+=p.theta,k.phi+=p.phi);let n=f.minAzimuthAngle,s=f.maxAzimuthAngle;return isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=u:n>Math.PI&&(n-=u),s<-Math.PI?s+=u:s>Math.PI&&(s-=u),k.theta=n<=s?Math.max(n,Math.min(s,k.theta)):k.theta>(n+s)/2?Math.max(n,k.theta):Math.min(s,k.theta)),k.phi=Math.max(f.minPolarAngle,Math.min(f.maxPolarAngle,k.phi)),k.makeSafe(),k.radius*=b,k.radius=Math.max(f.minDistance,Math.min(f.maxDistance,k.radius)),!0===f.enableDamping?f.target.addScaledVector(d,f.dampingFactor):f.target.add(d),e.setFromSpherical(k),e.applyQuaternion(c),t.copy(f.target).add(e),f.object.lookAt(f.target),!0===f.enableDamping?(p.theta*=1-f.dampingFactor,p.phi*=1-f.dampingFactor,d.multiplyScalar(1-f.dampingFactor)):(p.set(0,0,0),d.set(0,0,0)),b=1,!!(T||o.distanceToSquared(f.object.position)>M||8*(1-h.dot(f.object.quaternion))>M)&&(f.dispatchEvent(r),o.copy(f.object.position),h.copy(f.object.quaternion),T=!1,!0)}}(),this.dispose=function(){f.domElement.removeEventListener("contextmenu",$),f.domElement.removeEventListener("pointerdown",K),f.domElement.removeEventListener("pointercancel",V),f.domElement.removeEventListener("wheel",X),f.domElement.removeEventListener("pointermove",Q),f.domElement.removeEventListener("pointerup",S),null!==f.t&&(f.t.removeEventListener("keydown",Z),f.t=null)};const f=this,w={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let l=w.NONE;const M=1e-6,k=new c,p=new c;let b=1;const d=new n;let T=!1;const O=new o,A=new o,L=new o,E=new o,m=new o,v=new o,y=new o,D=new o,H=new o,N=[],R={};function U(){return Math.pow(.95,f.zoomSpeed)}function _(t){p.theta-=t}function x(t){p.phi-=t}const C=function(){const t=new n;return function(n,e){t.setFromMatrixColumn(e,0),t.multiplyScalar(-n),d.add(t)}}(),F=function(){const t=new n;return function(n,e){!0===f.screenSpacePanning?t.setFromMatrixColumn(e,1):(t.setFromMatrixColumn(e,0),t.crossVectors(f.object.up,t)),t.multiplyScalar(n),d.add(t)}}(),P=function(){const t=new n;return function(n,e){const i=f.domElement;if(f.object.isPerspectiveCamera){const s=f.object.position;t.copy(s).sub(f.target);let c=t.length();c*=Math.tan(f.object.fov/2*Math.PI/180),C(2*n*c/i.clientHeight,f.object.matrix),F(2*e*c/i.clientHeight,f.object.matrix)}else f.object.isOrthographicCamera?(C(n*(f.object.right-f.object.left)/f.object.zoom/i.clientWidth,f.object.matrix),F(e*(f.object.top-f.object.bottom)/f.object.zoom/i.clientHeight,f.object.matrix)):f.enablePan=!1}}();function I(t){f.object.isPerspectiveCamera?b/=t:f.object.isOrthographicCamera?(f.object.zoom=Math.max(f.minZoom,Math.min(f.maxZoom,f.object.zoom*t)),f.object.updateProjectionMatrix(),T=!0):f.enableZoom=!1}function Y(t){f.object.isPerspectiveCamera?b*=t:f.object.isOrthographicCamera?(f.object.zoom=Math.max(f.minZoom,Math.min(f.maxZoom,f.object.zoom/t)),f.object.updateProjectionMatrix(),T=!0):f.enableZoom=!1}function g(t){O.set(t.clientX,t.clientY)}function G(t){E.set(t.clientX,t.clientY)}function B(){if(1===N.length)O.set(N[0].pageX,N[0].pageY);else{const t=.5*(N[0].pageX+N[1].pageX),n=.5*(N[0].pageY+N[1].pageY);O.set(t,n)}}function W(){if(1===N.length)E.set(N[0].pageX,N[0].pageY);else{const t=.5*(N[0].pageX+N[1].pageX),n=.5*(N[0].pageY+N[1].pageY);E.set(t,n)}}function j(){const t=N[0].pageX-N[1].pageX,n=N[0].pageY-N[1].pageY,e=Math.sqrt(t*t+n*n);y.set(0,e)}function q(t){if(1==N.length)A.set(t.pageX,t.pageY);else{const n=et(t),e=.5*(t.pageX+n.x),i=.5*(t.pageY+n.y);A.set(e,i)}L.subVectors(A,O).multiplyScalar(f.rotateSpeed);const n=f.domElement;_(2*Math.PI*L.x/n.clientHeight),x(2*Math.PI*L.y/n.clientHeight),O.copy(A)}function z(t){if(1===N.length)m.set(t.pageX,t.pageY);else{const n=et(t),e=.5*(t.pageX+n.x),i=.5*(t.pageY+n.y);m.set(e,i)}v.subVectors(m,E).multiplyScalar(f.panSpeed),P(v.x,v.y),E.copy(m)}function J(t){const n=et(t),e=t.pageX-n.x,i=t.pageY-n.y,s=Math.sqrt(e*e+i*i);D.set(0,s),H.set(0,Math.pow(D.y/y.y,f.zoomSpeed)),I(H.y),y.copy(D)}function K(t){!1!==f.enabled&&(0===N.length&&(f.domElement.setPointerCapture(t.pointerId),f.domElement.addEventListener("pointermove",Q),f.domElement.addEventListener("pointerup",S)),function(t){N.push(t)}(t),"touch"===t.pointerType?function(t){switch(nt(t),N.length){case 1:switch(f.touches.ONE){case i.ROTATE:if(!1===f.enableRotate)return;B(),l=w.TOUCH_ROTATE;break;case i.PAN:if(!1===f.enablePan)return;W(),l=w.TOUCH_PAN;break;default:l=w.NONE}break;case 2:switch(f.touches.TWO){case i.DOLLY_PAN:if(!1===f.enableZoom&&!1===f.enablePan)return;f.enableZoom&&j(),f.enablePan&&W(),l=w.TOUCH_DOLLY_PAN;break;case i.DOLLY_ROTATE:if(!1===f.enableZoom&&!1===f.enableRotate)return;f.enableZoom&&j(),f.enableRotate&&B(),l=w.TOUCH_DOLLY_ROTATE;break;default:l=w.NONE}break;default:l=w.NONE}l!==w.NONE&&f.dispatchEvent(h)}(t):function(t){let n;switch(t.button){case 0:n=f.mouseButtons.LEFT;break;case 1:n=f.mouseButtons.MIDDLE;break;case 2:n=f.mouseButtons.RIGHT;break;default:n=-1}switch(n){case e.DOLLY:if(!1===f.enableZoom)return;!function(t){y.set(t.clientX,t.clientY)}(t),l=w.DOLLY;break;case e.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===f.enablePan)return;G(t),l=w.PAN}else{if(!1===f.enableRotate)return;g(t),l=w.ROTATE}break;case e.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===f.enableRotate)return;g(t),l=w.ROTATE}else{if(!1===f.enablePan)return;G(t),l=w.PAN}break;default:l=w.NONE}l!==w.NONE&&f.dispatchEvent(h)}(t))}function Q(t){!1!==f.enabled&&("touch"===t.pointerType?function(t){switch(nt(t),l){case w.TOUCH_ROTATE:if(!1===f.enableRotate)return;q(t),f.update();break;case w.TOUCH_PAN:if(!1===f.enablePan)return;z(t),f.update();break;case w.TOUCH_DOLLY_PAN:if(!1===f.enableZoom&&!1===f.enablePan)return;!function(t){f.enableZoom&&J(t),f.enablePan&&z(t)}(t),f.update();break;case w.TOUCH_DOLLY_ROTATE:if(!1===f.enableZoom&&!1===f.enableRotate)return;!function(t){f.enableZoom&&J(t),f.enableRotate&&q(t)}(t),f.update();break;default:l=w.NONE}}(t):function(t){switch(l){case w.ROTATE:if(!1===f.enableRotate)return;!function(t){A.set(t.clientX,t.clientY),L.subVectors(A,O).multiplyScalar(f.rotateSpeed);const n=f.domElement;_(2*Math.PI*L.x/n.clientHeight),x(2*Math.PI*L.y/n.clientHeight),O.copy(A),f.update()}(t);break;case w.DOLLY:if(!1===f.enableZoom)return;!function(t){D.set(t.clientX,t.clientY),H.subVectors(D,y),H.y>0?I(U()):H.y<0&&Y(U()),y.copy(D),f.update()}(t);break;case w.PAN:if(!1===f.enablePan)return;!function(t){m.set(t.clientX,t.clientY),v.subVectors(m,E).multiplyScalar(f.panSpeed),P(v.x,v.y),E.copy(m),f.update()}(t)}}(t))}function S(t){tt(t),0===N.length&&(f.domElement.releasePointerCapture(t.pointerId),f.domElement.removeEventListener("pointermove",Q),f.domElement.removeEventListener("pointerup",S)),f.dispatchEvent(u),l=w.NONE}function V(t){tt(t)}function X(t){!1!==f.enabled&&!1!==f.enableZoom&&l===w.NONE&&(t.preventDefault(),f.dispatchEvent(h),function(t){t.deltaY<0?Y(U()):t.deltaY>0&&I(U()),f.update()}(t),f.dispatchEvent(u))}function Z(t){!1!==f.enabled&&!1!==f.enablePan&&function(t){let n=!1;switch(t.code){case f.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?x(2*Math.PI*f.rotateSpeed/f.domElement.clientHeight):P(0,f.keyPanSpeed),n=!0;break;case f.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?x(-2*Math.PI*f.rotateSpeed/f.domElement.clientHeight):P(0,-f.keyPanSpeed),n=!0;break;case f.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?_(2*Math.PI*f.rotateSpeed/f.domElement.clientHeight):P(f.keyPanSpeed,0),n=!0;break;case f.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?_(-2*Math.PI*f.rotateSpeed/f.domElement.clientHeight):P(-f.keyPanSpeed,0),n=!0}n&&(t.preventDefault(),f.update())}(t)}function $(t){!1!==f.enabled&&t.preventDefault()}function tt(t){delete R[t.pointerId];for(let n=0;n<N.length;n++)if(N[n].pointerId==t.pointerId)return void N.splice(n,1)}function nt(t){let n=R[t.pointerId];void 0===n&&(n=new o,R[t.pointerId]=n),n.set(t.pageX,t.pageY)}function et(t){const n=t.pointerId===N[0].pointerId?N[1]:N[0];return R[n.pointerId]}f.domElement.addEventListener("contextmenu",$),f.domElement.addEventListener("pointerdown",K),f.domElement.addEventListener("pointercancel",V),f.domElement.addEventListener("wheel",X,{passive:!1}),this.update()}}class f extends a{constructor(t,n){super(t,n),this.screenSpacePanning=!1,this.mouseButtons.LEFT=e.PAN,this.mouseButtons.RIGHT=e.ROTATE,this.touches.ONE=i.PAN,this.touches.TWO=i.DOLLY_ROTATE}}export{f as MapControls,a as OrbitControls};
|
|
1
|
+
import{Ray as t,Plane as s,MathUtils as i,Vector3 as h,Controls as e,MOUSE as n,TOUCH as a,Quaternion as o,Spherical as r,Vector2 as c}from"three";const l={type:"change"},u={type:"start"},f={type:"end"},w=new t,d=new s,p=Math.cos(70*i.DEG2RAD),M=new h,_=2*Math.PI,k=-1,b=0,v=1,y=2,T=3,D=4,P=5,g=6,m=1e-6;class R extends e{constructor(t,s=null){super(t,s),this.state=k,this.target=new h,this.cursor=new h,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:n.ROTATE,MIDDLE:n.DOLLY,RIGHT:n.PAN},this.touches={ONE:a.ROTATE,TWO:a.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.t=null,this.i=new h,this.h=new o,this.o=new h,this.l=(new o).setFromUnitVectors(t.up,new h(0,1,0)),this.u=this.l.clone().invert(),this.p=new r,this.M=new r,this._=1,this.k=new h,this.v=new c,this.T=new c,this.D=new c,this.P=new c,this.m=new c,this.R=new c,this.A=new c,this.S=new c,this.L=new c,this.I=new h,this.O=new c,this.F=!1,this.U=[],this.K={},this.W=!1,this.Y=S.bind(this),this.C=A.bind(this),this.G=E.bind(this),this.H=K.bind(this),this.X=O.bind(this),this.Z=x.bind(this),this.B=F.bind(this),this.N=U.bind(this),this.j=L.bind(this),this.q=I.bind(this),this.J=W.bind(this),this.V=Y.bind(this),null!==this.domElement&&this.connect(this.domElement),this.update()}connect(t){super.connect(t),this.domElement.addEventListener("pointerdown",this.C),this.domElement.addEventListener("pointercancel",this.G),this.domElement.addEventListener("contextmenu",this.H),this.domElement.addEventListener("wheel",this.X,{passive:!1});this.domElement.getRootNode().addEventListener("keydown",this.J,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this.C),this.domElement.removeEventListener("pointermove",this.Y),this.domElement.removeEventListener("pointerup",this.G),this.domElement.removeEventListener("pointercancel",this.G),this.domElement.removeEventListener("wheel",this.X),this.domElement.removeEventListener("contextmenu",this.H),this.stopListenToKeyEvents();this.domElement.getRootNode().removeEventListener("keydown",this.J,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this.p.phi}getAzimuthalAngle(){return this.p.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this.Z),this.t=t}stopListenToKeyEvents(){null!==this.t&&(this.t.removeEventListener("keydown",this.Z),this.t=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(l),this.update(),this.state=k}update(t=null){const s=this.object.position;M.copy(s).sub(this.target),M.applyQuaternion(this.l),this.p.setFromVector3(M),this.autoRotate&&this.state===k&&this.$(this.tt(t)),this.enableDamping?(this.p.theta+=this.M.theta*this.dampingFactor,this.p.phi+=this.M.phi*this.dampingFactor):(this.p.theta+=this.M.theta,this.p.phi+=this.M.phi);let i=this.minAzimuthAngle,e=this.maxAzimuthAngle;isFinite(i)&&isFinite(e)&&(i<-Math.PI?i+=_:i>Math.PI&&(i-=_),e<-Math.PI?e+=_:e>Math.PI&&(e-=_),this.p.theta=i<=e?Math.max(i,Math.min(e,this.p.theta)):this.p.theta>(i+e)/2?Math.max(i,this.p.theta):Math.min(e,this.p.theta)),this.p.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this.p.phi)),this.p.makeSafe(),!0===this.enableDamping?this.target.addScaledVector(this.k,this.dampingFactor):this.target.add(this.k),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let n=!1;if(this.zoomToCursor&&this.F||this.object.isOrthographicCamera)this.p.radius=this.st(this.p.radius);else{const t=this.p.radius;this.p.radius=this.st(this.p.radius*this._),n=t!=this.p.radius}if(M.setFromSpherical(this.p),M.applyQuaternion(this.u),s.copy(this.target).add(M),this.object.lookAt(this.target),!0===this.enableDamping?(this.M.theta*=1-this.dampingFactor,this.M.phi*=1-this.dampingFactor,this.k.multiplyScalar(1-this.dampingFactor)):(this.M.set(0,0,0),this.k.set(0,0,0)),this.zoomToCursor&&this.F){let t=null;if(this.object.isPerspectiveCamera){const s=M.length();t=this.st(s*this._);const i=s-t;this.object.position.addScaledVector(this.I,i),this.object.updateMatrixWorld(),n=!!i}else if(this.object.isOrthographicCamera){const s=new h(this.O.x,this.O.y,0);s.unproject(this.object);const i=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._)),this.object.updateProjectionMatrix(),n=i!==this.object.zoom;const e=new h(this.O.x,this.O.y,0);e.unproject(this.object),this.object.position.sub(e).add(s),this.object.updateMatrixWorld(),t=M.length()}else this.zoomToCursor=!1;null!==t&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(t).add(this.object.position):(w.origin.copy(this.object.position),w.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(w.direction))<p?this.object.lookAt(this.target):(d.setFromNormalAndCoplanarPoint(this.object.up,this.target),w.intersectPlane(d,this.target))))}else if(this.object.isOrthographicCamera){const t=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._)),t!==this.object.zoom&&(this.object.updateProjectionMatrix(),n=!0)}return this._=1,this.F=!1,!!(n||this.i.distanceToSquared(this.object.position)>m||8*(1-this.h.dot(this.object.quaternion))>m||this.o.distanceToSquared(this.target)>m)&&(this.dispatchEvent(l),this.i.copy(this.object.position),this.h.copy(this.object.quaternion),this.o.copy(this.target),!0)}tt(t){return null!==t?_/60*this.autoRotateSpeed*t:_/60/60*this.autoRotateSpeed}it(t){const s=Math.abs(.01*t);return Math.pow(.95,this.zoomSpeed*s)}$(t){this.M.theta-=t}ht(t){this.M.phi-=t}et(t,s){M.setFromMatrixColumn(s,0),M.multiplyScalar(-t),this.k.add(M)}nt(t,s){!0===this.screenSpacePanning?M.setFromMatrixColumn(s,1):(M.setFromMatrixColumn(s,0),M.crossVectors(this.object.up,M)),M.multiplyScalar(t),this.k.add(M)}ot(t,s){const i=this.domElement;if(this.object.isPerspectiveCamera){const h=this.object.position;M.copy(h).sub(this.target);let e=M.length();e*=Math.tan(this.object.fov/2*Math.PI/180),this.et(2*t*e/i.clientHeight,this.object.matrix),this.nt(2*s*e/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this.et(t*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this.nt(s*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):this.enablePan=!1}rt(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._/=t:this.enableZoom=!1}ct(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._*=t:this.enableZoom=!1}lt(t,s){if(!this.zoomToCursor)return;this.F=!0;const i=this.domElement.getBoundingClientRect(),h=t-i.left,e=s-i.top,n=i.width,a=i.height;this.O.x=h/n*2-1,this.O.y=-e/a*2+1,this.I.set(this.O.x,this.O.y,1).unproject(this.object).sub(this.object.position).normalize()}st(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}ut(t){this.v.set(t.clientX,t.clientY)}ft(t){this.lt(t.clientX,t.clientX),this.A.set(t.clientX,t.clientY)}wt(t){this.P.set(t.clientX,t.clientY)}dt(t){this.T.set(t.clientX,t.clientY),this.D.subVectors(this.T,this.v).multiplyScalar(this.rotateSpeed);const s=this.domElement;this.$(_*this.D.x/s.clientHeight),this.ht(_*this.D.y/s.clientHeight),this.v.copy(this.T),this.update()}Mt(t){this.S.set(t.clientX,t.clientY),this.L.subVectors(this.S,this.A),this.L.y>0?this.rt(this.it(this.L.y)):this.L.y<0&&this.ct(this.it(this.L.y)),this.A.copy(this.S),this.update()}_t(t){this.m.set(t.clientX,t.clientY),this.R.subVectors(this.m,this.P).multiplyScalar(this.panSpeed),this.ot(this.R.x,this.R.y),this.P.copy(this.m),this.update()}kt(t){this.lt(t.clientX,t.clientY),t.deltaY<0?this.ct(this.it(t.deltaY)):t.deltaY>0&&this.rt(this.it(t.deltaY)),this.update()}bt(t){let s=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this.ht(_*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this.ot(0,this.keyPanSpeed),s=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this.ht(-_*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this.ot(0,-this.keyPanSpeed),s=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this.$(_*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this.ot(this.keyPanSpeed,0),s=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this.$(-_*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this.ot(-this.keyPanSpeed,0),s=!0}s&&(t.preventDefault(),this.update())}vt(t){if(1===this.U.length)this.v.set(t.pageX,t.pageY);else{const s=this.yt(t),i=.5*(t.pageX+s.x),h=.5*(t.pageY+s.y);this.v.set(i,h)}}Tt(t){if(1===this.U.length)this.P.set(t.pageX,t.pageY);else{const s=this.yt(t),i=.5*(t.pageX+s.x),h=.5*(t.pageY+s.y);this.P.set(i,h)}}Dt(t){const s=this.yt(t),i=t.pageX-s.x,h=t.pageY-s.y,e=Math.sqrt(i*i+h*h);this.A.set(0,e)}Pt(t){this.enableZoom&&this.Dt(t),this.enablePan&&this.Tt(t)}gt(t){this.enableZoom&&this.Dt(t),this.enableRotate&&this.vt(t)}Rt(t){if(1==this.U.length)this.T.set(t.pageX,t.pageY);else{const s=this.yt(t),i=.5*(t.pageX+s.x),h=.5*(t.pageY+s.y);this.T.set(i,h)}this.D.subVectors(this.T,this.v).multiplyScalar(this.rotateSpeed);const s=this.domElement;this.$(_*this.D.x/s.clientHeight),this.ht(_*this.D.y/s.clientHeight),this.v.copy(this.T)}At(t){if(1===this.U.length)this.m.set(t.pageX,t.pageY);else{const s=this.yt(t),i=.5*(t.pageX+s.x),h=.5*(t.pageY+s.y);this.m.set(i,h)}this.R.subVectors(this.m,this.P).multiplyScalar(this.panSpeed),this.ot(this.R.x,this.R.y),this.P.copy(this.m)}St(t){const s=this.yt(t),i=t.pageX-s.x,h=t.pageY-s.y,e=Math.sqrt(i*i+h*h);this.S.set(0,e),this.L.set(0,Math.pow(this.S.y/this.A.y,this.zoomSpeed)),this.rt(this.L.y),this.A.copy(this.S);const n=.5*(t.pageX+s.x),a=.5*(t.pageY+s.y);this.lt(n,a)}Et(t){this.enableZoom&&this.St(t),this.enablePan&&this.At(t)}Lt(t){this.enableZoom&&this.St(t),this.enableRotate&&this.Rt(t)}It(t){this.U.push(t.pointerId)}Ot(t){delete this.K[t.pointerId];for(let s=0;s<this.U.length;s++)if(this.U[s]==t.pointerId)return void this.U.splice(s,1)}xt(t){for(let s=0;s<this.U.length;s++)if(this.U[s]==t.pointerId)return!0;return!1}Ft(t){let s=this.K[t.pointerId];void 0===s&&(s=new c,this.K[t.pointerId]=s),s.set(t.pageX,t.pageY)}yt(t){const s=t.pointerId===this.U[0]?this.U[1]:this.U[0];return this.K[s]}Ut(t){const s=t.deltaMode,i={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(s){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100}return t.ctrlKey&&!this.W&&(i.deltaY*=10),i}}function A(t){!1!==this.enabled&&(0===this.U.length&&(this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this.Y),this.domElement.addEventListener("pointerup",this.G)),this.xt(t)||(this.It(t),"touch"===t.pointerType?this.B(t):this.j(t)))}function S(t){!1!==this.enabled&&("touch"===t.pointerType?this.N(t):this.q(t))}function E(t){switch(this.Ot(t),this.U.length){case 0:this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this.Y),this.domElement.removeEventListener("pointerup",this.G),this.dispatchEvent(f),this.state=k;break;case 1:const s=this.U[0],i=this.K[s];this.B({pointerId:s,pageX:i.x,pageY:i.y})}}function L(t){let s;switch(t.button){case 0:s=this.mouseButtons.LEFT;break;case 1:s=this.mouseButtons.MIDDLE;break;case 2:s=this.mouseButtons.RIGHT;break;default:s=-1}switch(s){case n.DOLLY:if(!1===this.enableZoom)return;this.ft(t),this.state=v;break;case n.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===this.enablePan)return;this.wt(t),this.state=y}else{if(!1===this.enableRotate)return;this.ut(t),this.state=b}break;case n.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(!1===this.enableRotate)return;this.ut(t),this.state=b}else{if(!1===this.enablePan)return;this.wt(t),this.state=y}break;default:this.state=k}this.state!==k&&this.dispatchEvent(u)}function I(t){switch(this.state){case b:if(!1===this.enableRotate)return;this.dt(t);break;case v:if(!1===this.enableZoom)return;this.Mt(t);break;case y:if(!1===this.enablePan)return;this._t(t)}}function O(t){!1!==this.enabled&&!1!==this.enableZoom&&this.state===k&&(t.preventDefault(),this.dispatchEvent(u),this.kt(this.Ut(t)),this.dispatchEvent(f))}function x(t){!1!==this.enabled&&this.bt(t)}function F(t){switch(this.Ft(t),this.U.length){case 1:switch(this.touches.ONE){case a.ROTATE:if(!1===this.enableRotate)return;this.vt(t),this.state=T;break;case a.PAN:if(!1===this.enablePan)return;this.Tt(t),this.state=D;break;default:this.state=k}break;case 2:switch(this.touches.TWO){case a.DOLLY_PAN:if(!1===this.enableZoom&&!1===this.enablePan)return;this.Pt(t),this.state=P;break;case a.DOLLY_ROTATE:if(!1===this.enableZoom&&!1===this.enableRotate)return;this.gt(t),this.state=g;break;default:this.state=k}break;default:this.state=k}this.state!==k&&this.dispatchEvent(u)}function U(t){switch(this.Ft(t),this.state){case T:if(!1===this.enableRotate)return;this.Rt(t),this.update();break;case D:if(!1===this.enablePan)return;this.At(t),this.update();break;case P:if(!1===this.enableZoom&&!1===this.enablePan)return;this.Et(t),this.update();break;case g:if(!1===this.enableZoom&&!1===this.enableRotate)return;this.Lt(t),this.update();break;default:this.state=k}}function K(t){!1!==this.enabled&&t.preventDefault()}function W(t){if("Control"===t.key){this.W=!0;this.domElement.getRootNode().addEventListener("keyup",this.V,{passive:!0,capture:!0})}}function Y(t){if("Control"===t.key){this.W=!1;this.domElement.getRootNode().removeEventListener("keyup",this.V,{passive:!0,capture:!0})}}export{R as OrbitControls};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Color as t,REVISION as e,Vector3 as n,CompressedTexture as s,Source as i,NoColorSpace as r,MathUtils as o,RGBAFormat as a,ImageUtils as c,DoubleSide as h,BufferAttribute as l,PropertyBinding as u,InterpolateDiscrete as f,Matrix4 as w,Scene as d,Quaternion as y,InterpolateLinear as m,NearestFilter as p,NearestMipmapNearestFilter as A,NearestMipmapLinearFilter as T,LinearFilter as x,LinearMipmapNearestFilter as g,LinearMipmapLinearFilter as b,ClampToEdgeWrapping as E,RepeatWrapping as M,MirroredRepeatWrapping as _,SRGBColorSpace as v}from"three";const C={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class O{constructor(){this.textureUtils=null,this.pluginCallbacks=[],this.register(function(t){return new at(t)}),this.register(function(t){return new ct(t)}),this.register(function(t){return new ft(t)}),this.register(function(t){return new wt(t)}),this.register(function(t){return new dt(t)}),this.register(function(t){return new yt(t)}),this.register(function(t){return new ht(t)}),this.register(function(t){return new lt(t)}),this.register(function(t){return new ut(t)}),this.register(function(t){return new mt(t)}),this.register(function(t){return new pt(t)}),this.register(function(t){return new At(t)}),this.register(function(t){return new Tt(t)}),this.register(function(t){return new xt(t)})}register(t){return-1===this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.push(t),this}unregister(t){return-1!==this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}setTextureUtils(t){return this.textureUtils=t,this}parse(t,e,n,s){const i=new ot,r=[];for(let t=0,e=this.pluginCallbacks.length;t<e;t++)r.push(this.pluginCallbacks[t](i));i.setPlugins(r),i.setTextureUtils(this.textureUtils),i.writeAsync(t,e,s).catch(n)}parseAsync(t,e){const n=this;return new Promise(function(s,i){n.parse(t,s,i,e)})}}const R=0,I=1,N=2,H=3,L=4,S=5120,F=5121,z=5122,U=5123,B=5124,K=5125,k=5126,D=34962,G=34963,V=9728,P=9729,j=9984,X=9985,J=9986,q=9987,W=33071,Q=33648,Y=10497,$="KHR_mesh_quantization",Z={};Z[p]=V,Z[A]=j,Z[T]=J,Z[x]=P,Z[g]=X,Z[b]=q,Z[E]=W,Z[M]=Y,Z[_]=Q;const tt={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},et=new t;function nt(t,e){return t.length===e.length&&t.every(function(t,n){return t===e[n]})}function st(t){return 4*Math.ceil(t/4)}function it(t,e=0){const n=st(t.byteLength);if(n!==t.byteLength){const s=new Uint8Array(n);if(s.set(new Uint8Array(t)),0!==e)for(let i=t.byteLength;i<n;i++)s[i]=e;return s.buffer}return t}function rt(){return"undefined"==typeof document&&"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas")}class ot{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r"+e}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map},this.textureUtils=null}setPlugins(t){this.plugins=t}setTextureUtils(t){this.textureUtils=t}async writeAsync(t,e,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(t),await Promise.all(this.pending);const s=this,i=s.buffers,r=s.json;n=s.options;const o=s.extensionsUsed,a=s.extensionsRequired,c=new Blob(i,{type:"application/octet-stream"}),h=Object.keys(o),l=Object.keys(a);if(h.length>0&&(r.extensionsUsed=h),l.length>0&&(r.extensionsRequired=l),r.buffers&&r.buffers.length>0&&(r.buffers[0].byteLength=c.size),!0===n.binary){const t=new FileReader;t.readAsArrayBuffer(c),t.onloadend=function(){const n=it(t.result),s=new DataView(new ArrayBuffer(8));s.setUint32(0,n.byteLength,!0),s.setUint32(4,5130562,!0);const i=it((o=JSON.stringify(r),(new TextEncoder).encode(o).buffer),32);var o;const a=new DataView(new ArrayBuffer(8));a.setUint32(0,i.byteLength,!0),a.setUint32(4,1313821514,!0);const c=new ArrayBuffer(12),h=new DataView(c);h.setUint32(0,1179937895,!0),h.setUint32(4,2,!0);const l=12+a.byteLength+i.byteLength+s.byteLength+n.byteLength;h.setUint32(8,l,!0);const u=new Blob([c,a,i,s,n],{type:"application/octet-stream"}),f=new FileReader;f.readAsArrayBuffer(u),f.onloadend=function(){e(f.result)}}}else if(r.buffers&&r.buffers.length>0){const t=new FileReader;t.readAsDataURL(c),t.onloadend=function(){const n=t.result;r.buffers[0].uri=n,e(r)}}else e(r)}serializeUserData(t,e){if(0===Object.keys(t.userData).length)return;const n=this.options,s=this.extensionsUsed;try{const i=JSON.parse(JSON.stringify(t.userData));if(n.includeCustomExtensions&&i.gltfExtensions){void 0===e.extensions&&(e.extensions={});for(const t in i.gltfExtensions)e.extensions[t]=i.gltfExtensions[t],s[t]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(e.extras=i)}catch(t){}}getUID(t,e=!1){if(!1===this.uids.has(t)){const e=new Map;e.set(!0,this.uid++),e.set(!1,this.uid++),this.uids.set(t,e)}return this.uids.get(t).get(e)}isNormalizedNormalAttribute(t){if(this.cache.attributesNormalized.has(t))return!1;const e=new n;for(let n=0,s=t.count;n<s;n++)if(Math.abs(e.fromBufferAttribute(t,n).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(t){const e=this.cache;if(e.attributesNormalized.has(t))return e.attributesNormalized.get(t);const s=t.clone(),i=new n;for(let t=0,e=s.count;t<e;t++)i.fromBufferAttribute(s,t),0===i.x&&0===i.y&&0===i.z?i.setX(1):i.normalize(),s.setXYZ(t,i.x,i.y,i.z);return e.attributesNormalized.set(t,s),s}applyTextureTransform(t,e){let n=!1;const s={};0===e.offset.x&&0===e.offset.y||(s.offset=e.offset.toArray(),n=!0),0!==e.rotation&&(s.rotation=e.rotation,n=!0),1===e.repeat.x&&1===e.repeat.y||(s.scale=e.repeat.toArray(),n=!0),n&&(t.extensions=t.extensions||{},t.extensions.KHR_texture_transform=s,this.extensionsUsed.KHR_texture_transform=!0)}async buildMetalRoughTextureAsync(t,e){if(t===e)return t;function n(t){return t.colorSpace===v?function(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}:function(t){return t}}t instanceof s&&(t=await this.decompressTextureAsync(t)),e instanceof s&&(e=await this.decompressTextureAsync(e));const o=t?t.image:null,a=e?e.image:null,c=Math.max(o?o.width:0,a?a.width:0),h=Math.max(o?o.height:0,a?a.height:0),l=rt();l.width=c,l.height=h;const u=l.getContext("2d",{willReadFrequently:!0});u.fillStyle="#00ffff",u.fillRect(0,0,c,h);const f=u.getImageData(0,0,c,h);if(o){u.drawImage(o,0,0,c,h);const e=n(t),s=u.getImageData(0,0,c,h).data;for(let t=2;t<s.length;t+=4)f.data[t]=256*e(s[t]/256)}if(a){u.drawImage(a,0,0,c,h);const t=n(e),s=u.getImageData(0,0,c,h).data;for(let e=1;e<s.length;e+=4)f.data[e]=256*t(s[e]/256)}u.putImageData(f,0,0);const w=(t||e).clone();return w.source=new i(l),w.colorSpace=r,w.channel=(t||e).channel,t&&e&&(t.channel,e.channel),w}async decompressTextureAsync(t,e=1/0){if(null===this.textureUtils)throw new Error("THREE.GLTFExporter: setTextureUtils() must be called to process compressed textures.");return await this.textureUtils.decompress(t,e)}processBuffer(t){const e=this.json,n=this.buffers;return e.buffers||(e.buffers=[{byteLength:0}]),n.push(t),0}processBufferView(t,e,n,s,i){const r=this.json;let a;switch(r.bufferViews||(r.bufferViews=[]),e){case S:case F:a=1;break;case z:case U:a=2;break;default:a=4}let c=t.itemSize*a;i===D&&(c=4*Math.ceil(c/4));const h=st(s*c),l=new DataView(new ArrayBuffer(h));let u=0;for(let i=n;i<n+s;i++){for(let n=0;n<t.itemSize;n++){let s;t.itemSize>4?s=t.array[i*t.itemSize+n]:(0===n?s=t.getX(i):1===n?s=t.getY(i):2===n?s=t.getZ(i):3===n&&(s=t.getW(i)),!0===t.normalized&&(s=o.normalize(s,t.array))),e===k?l.setFloat32(u,s,!0):e===B?l.setInt32(u,s,!0):e===K?l.setUint32(u,s,!0):e===z?l.setInt16(u,s,!0):e===U?l.setUint16(u,s,!0):e===S?l.setInt8(u,s):e===F&&l.setUint8(u,s),u+=a}u%c!==0&&(u+=c-u%c)}const f={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:h};void 0!==i&&(f.target=i),i===D&&(f.byteStride=c),this.byteOffset+=h,r.bufferViews.push(f);return{id:r.bufferViews.length-1,byteLength:0}}processBufferViewImage(t){const e=this,n=e.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(s){const i=new FileReader;i.readAsArrayBuffer(t),i.onloadend=function(){const t=it(i.result),r={buffer:e.processBuffer(t),byteOffset:e.byteOffset,byteLength:t.byteLength};e.byteOffset+=t.byteLength,s(n.bufferViews.push(r)-1)}})}processAccessor(t,e,n,s){const i=this.json;let r;if(t.array.constructor===Float32Array)r=k;else if(t.array.constructor===Int32Array)r=B;else if(t.array.constructor===Uint32Array)r=K;else if(t.array.constructor===Int16Array)r=z;else if(t.array.constructor===Uint16Array)r=U;else if(t.array.constructor===Int8Array)r=S;else{if(t.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+t.array.constructor.name);r=F}if(void 0===n&&(n=0),void 0!==s&&s!==1/0||(s=t.count),0===s)return null;const a=function(t,e,n){const s={min:new Array(t.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(t.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let i=e;i<e+n;i++)for(let e=0;e<t.itemSize;e++){let n;t.itemSize>4?n=t.array[i*t.itemSize+e]:(0===e?n=t.getX(i):1===e?n=t.getY(i):2===e?n=t.getZ(i):3===e&&(n=t.getW(i)),!0===t.normalized&&(n=o.normalize(n,t.array))),s.min[e]=Math.min(s.min[e],n),s.max[e]=Math.max(s.max[e],n)}return s}(t,n,s);let c;void 0!==e&&(c=t===e.index?G:D);const h=this.processBufferView(t,r,n,s,c),l={bufferView:h.id,byteOffset:h.byteOffset,componentType:r,count:s,max:a.max,min:a.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[t.itemSize]};return!0===t.normalized&&(l.normalized=!0),i.accessors||(i.accessors=[]),i.accessors.push(l)-1}processImage(t,e,n,s="image/png"){if(null!==t){const e=this,i=e.cache,r=e.json,o=e.options,a=e.pending;i.images.has(t)||i.images.set(t,{});const h=i.images.get(t),l=s+":flipY/"+n.toString();if(void 0!==h[l])return h[l];r.images||(r.images=[]);const u={mimeType:s},f=rt();f.width=Math.min(t.width,o.maxTextureSize),f.height=Math.min(t.height,o.maxTextureSize);const w=f.getContext("2d",{willReadFrequently:!0});if(!0===n&&(w.translate(0,f.height),w.scale(1,-1)),void 0!==t.data){t.width>o.maxTextureSize||(t.height,o.maxTextureSize);const e=new Uint8ClampedArray(t.height*t.width*4);for(let n=0;n<e.length;n+=4)e[n+0]=t.data[n+0],e[n+1]=t.data[n+1],e[n+2]=t.data[n+2],e[n+3]=t.data[n+3];w.putImageData(new ImageData(e,t.width,t.height),0,0)}else{if(!("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas))throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");w.drawImage(t,0,0,f.width,f.height)}!0===o.binary?a.push(function(t,e){if(void 0!==t.toBlob)return new Promise(n=>t.toBlob(n,e));let n;return"image/jpeg"===e?n=.92:"image/webp"===e&&(n=.8),t.convertToBlob({type:e,quality:n})}(f,s).then(t=>e.processBufferViewImage(t)).then(t=>{u.bufferView=t})):u.uri=c.getDataURL(f,s);const d=r.images.push(u)-1;return h[l]=d,d}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(t){const e=this.json;e.samplers||(e.samplers=[]);const n={magFilter:Z[t.magFilter],minFilter:Z[t.minFilter],wrapS:Z[t.wrapS],wrapT:Z[t.wrapT]};return e.samplers.push(n)-1}async processTextureAsync(t){const e=this.options,n=this.cache,i=this.json;if(n.textures.has(t))return n.textures.get(t);i.textures||(i.textures=[]),t instanceof s&&(t=await this.decompressTextureAsync(t,e.maxTextureSize));let r=t.userData.mimeType;"image/webp"===r&&(r="image/png");const o={sampler:this.processSampler(t),source:this.processImage(t.image,t.format,t.flipY,r)};t.name&&(o.name=t.name),await this.t(async function(e){e.writeTexture&&await e.writeTexture(t,o)});const a=i.textures.push(o)-1;return n.textures.set(t,a),a}async processMaterialAsync(t){const e=this.cache,n=this.json;if(e.materials.has(t))return e.materials.get(t);if(t.isShaderMaterial)return null;n.materials||(n.materials=[]);const s={pbrMetallicRoughness:{}};!0!==t.isMeshStandardMaterial&&t.isMeshBasicMaterial;const i=t.color.toArray().concat([t.opacity]);if(nt(i,[1,1,1,1])||(s.pbrMetallicRoughness.baseColorFactor=i),t.isMeshStandardMaterial?(s.pbrMetallicRoughness.metallicFactor=t.metalness,s.pbrMetallicRoughness.roughnessFactor=t.roughness):(s.pbrMetallicRoughness.metallicFactor=0,s.pbrMetallicRoughness.roughnessFactor=1),t.metalnessMap||t.roughnessMap){const e=await this.buildMetalRoughTextureAsync(t.metalnessMap,t.roughnessMap),n={index:await this.processTextureAsync(e),texCoord:e.channel};this.applyTextureTransform(n,e),s.pbrMetallicRoughness.metallicRoughnessTexture=n}if(t.map){const e={index:await this.processTextureAsync(t.map),texCoord:t.map.channel};this.applyTextureTransform(e,t.map),s.pbrMetallicRoughness.baseColorTexture=e}if(t.emissive){const e=t.emissive;if(Math.max(e.r,e.g,e.b)>0&&(s.emissiveFactor=t.emissive.toArray()),t.emissiveMap){const e={index:await this.processTextureAsync(t.emissiveMap),texCoord:t.emissiveMap.channel};this.applyTextureTransform(e,t.emissiveMap),s.emissiveTexture=e}}if(t.normalMap){const e={index:await this.processTextureAsync(t.normalMap),texCoord:t.normalMap.channel};t.normalScale&&1!==t.normalScale.x&&(e.scale=t.normalScale.x),this.applyTextureTransform(e,t.normalMap),s.normalTexture=e}if(t.aoMap){const e={index:await this.processTextureAsync(t.aoMap),texCoord:t.aoMap.channel};1!==t.aoMapIntensity&&(e.strength=t.aoMapIntensity),this.applyTextureTransform(e,t.aoMap),s.occlusionTexture=e}t.transparent?s.alphaMode="BLEND":t.alphaTest>0&&(s.alphaMode="MASK",s.alphaCutoff=t.alphaTest),t.side===h&&(s.doubleSided=!0),""!==t.name&&(s.name=t.name),this.serializeUserData(t,s),await this.t(async function(e){e.writeMaterialAsync&&await e.writeMaterialAsync(t,s)});const r=n.materials.push(s)-1;return e.materials.set(t,r),r}async processMeshAsync(t){const e=this.cache,n=this.json,s=[t.geometry.uuid];if(Array.isArray(t.material))for(let e=0,n=t.material.length;e<n;e++)s.push(t.material[e].uuid);else s.push(t.material.uuid);const i=s.join(":");if(e.meshes.has(i))return e.meshes.get(i);const r=t.geometry;let o;o=t.isLineSegments?I:t.isLineLoop?N:t.isLine?H:t.isPoints?R:t.material.wireframe?I:L;const a={},c={},h=[],u=[],f={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},w=r.getAttribute("normal");void 0===w||this.isNormalizedNormalAttribute(w)||r.setAttribute("normal",this.createNormalizedNormalAttribute(w));let d=null;for(let t in r.attributes){if("morph"===t.slice(0,5))continue;const n=r.attributes[t];t=f[t]||t.toUpperCase();if(/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(t)||(t="_"+t),e.attributes.has(this.getUID(n))){c[t]=e.attributes.get(this.getUID(n));continue}d=null;const s=n.array;"JOINTS_0"!==t||s instanceof Uint16Array||s instanceof Uint8Array?(s instanceof Uint32Array||s instanceof Int32Array)&&!t.startsWith("_")&&(d=O.Utils.toFloat32BufferAttribute(n)):d=new l(new Uint16Array(s),n.itemSize,n.normalized);const i=this.processAccessor(d||n,r);null!==i&&(t.startsWith("_")||this.detectMeshQuantization(t,n),c[t]=i,e.attributes.set(this.getUID(n),i))}if(void 0!==w&&r.setAttribute("normal",w),0===Object.keys(c).length)return null;if(void 0!==t.morphTargetInfluences&&t.morphTargetInfluences.length>0){const n=[],s=[],i={};if(void 0!==t.morphTargetDictionary)for(const e in t.morphTargetDictionary)i[t.morphTargetDictionary[e]]=e;for(let o=0;o<t.morphTargetInfluences.length;++o){const a={};let c=!1;for(const t in r.morphAttributes){if("position"!==t&&"normal"!==t){c||(c=!0);continue}const n=r.morphAttributes[t][o],s=t.toUpperCase(),i=r.attributes[t];if(e.attributes.has(this.getUID(n,!0))){a[s]=e.attributes.get(this.getUID(n,!0));continue}const h=n.clone();if(!r.morphTargetsRelative)for(let t=0,e=n.count;t<e;t++)for(let e=0;e<n.itemSize;e++)0===e&&h.setX(t,n.getX(t)-i.getX(t)),1===e&&h.setY(t,n.getY(t)-i.getY(t)),2===e&&h.setZ(t,n.getZ(t)-i.getZ(t)),3===e&&h.setW(t,n.getW(t)-i.getW(t));a[s]=this.processAccessor(h,r),e.attributes.set(this.getUID(i,!0),a[s])}u.push(a),n.push(t.morphTargetInfluences[o]),void 0!==t.morphTargetDictionary&&s.push(i[o])}a.weights=n,s.length>0&&(a.extras={},a.extras.targetNames=s)}const y=Array.isArray(t.material);if(y&&0===r.groups.length)return null;let m=!1;if(y&&null===r.index){const t=[];for(let e=0,n=r.attributes.position.count;e<n;e++)t[e]=e;r.setIndex(t),m=!0}const p=y?t.material:[t.material],A=y?r.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let t=0,n=A.length;t<n;t++){const n={mode:o,attributes:c};if(this.serializeUserData(r,n),u.length>0&&(n.targets=u),null!==r.index){let s=this.getUID(r.index);void 0===A[t].start&&void 0===A[t].count||(s+=":"+A[t].start+":"+A[t].count),e.attributes.has(s)?n.indices=e.attributes.get(s):(n.indices=this.processAccessor(r.index,r,A[t].start,A[t].count),e.attributes.set(s,n.indices)),null===n.indices&&delete n.indices}const s=await this.processMaterialAsync(p[A[t].materialIndex]);null!==s&&(n.material=s),h.push(n)}!0===m&&r.setIndex(null),a.primitives=h,n.meshes||(n.meshes=[]),await this.t(function(e){e.writeMesh&&e.writeMesh(t,a)});const T=n.meshes.push(a)-1;return e.meshes.set(i,T),T}detectMeshQuantization(t,e){if(this.extensionsUsed[$])return;let n;switch(e.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}e.normalized&&(n+=" normalized");const s=t.split("_",1)[0];C[s]&&C[s].includes(n)&&(this.extensionsUsed[$]=!0,this.extensionsRequired[$]=!0)}processCamera(t){const e=this.json;e.cameras||(e.cameras=[]);const n=t.isOrthographicCamera,s={type:n?"orthographic":"perspective"};return n?s.orthographic={xmag:2*t.right,ymag:2*t.top,zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near}:s.perspective={aspectRatio:t.aspect,yfov:o.degToRad(t.fov),zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near},""!==t.name&&(s.name=t.type),e.cameras.push(s)-1}processAnimation(t,e){const n=this.json,s=this.nodeMap;n.animations||(n.animations=[]);const i=(t=O.Utils.mergeMorphTargetTracks(t.clone(),e)).tracks,r=[],o=[];for(let t=0;t<i.length;++t){const n=i[t],a=u.parseTrackName(n.name);let c=u.findNode(e,a.nodeName);const h=tt[a.propertyName];if("bones"===a.objectName&&(c=!0===c.isSkinnedMesh?c.skeleton.getBoneByName(a.objectIndex):void 0),!c||!h)continue;const w=1;let d,y=n.values.length/n.times.length;h===tt.morphTargetInfluences&&(y/=c.morphTargetInfluences.length),!0===n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(d="CUBICSPLINE",y/=3):d=n.getInterpolation()===f?"STEP":"LINEAR",o.push({input:this.processAccessor(new l(n.times,w)),output:this.processAccessor(new l(n.values,y)),interpolation:d}),r.push({sampler:o.length-1,target:{node:s.get(c),path:h}})}return n.animations.push({name:t.name||"clip_"+n.animations.length,samplers:o,channels:r}),n.animations.length-1}processSkin(t){const e=this.json,n=this.nodeMap,s=e.nodes[n.get(t)],i=t.skeleton;if(void 0===i)return null;const r=t.skeleton.bones[0];if(void 0===r)return null;const o=[],a=new Float32Array(16*i.bones.length),c=new w;for(let e=0;e<i.bones.length;++e)o.push(n.get(i.bones[e])),c.copy(i.boneInverses[e]),c.multiply(t.bindMatrix).toArray(a,16*e);void 0===e.skins&&(e.skins=[]),e.skins.push({inverseBindMatrices:this.processAccessor(new l(a,16)),joints:o,skeleton:n.get(r)});return s.skin=e.skins.length-1}async processNodeAsync(t){const e=this.json,n=this.options,s=this.nodeMap;e.nodes||(e.nodes=[]);const i={};if(n.trs){const e=t.quaternion.toArray(),n=t.position.toArray(),s=t.scale.toArray();nt(e,[0,0,0,1])||(i.rotation=e),nt(n,[0,0,0])||(i.translation=n),nt(s,[1,1,1])||(i.scale=s)}else t.matrixAutoUpdate&&t.updateMatrix(),!1===nt(t.matrix.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])&&(i.matrix=t.matrix.elements);if(""!==t.name&&(i.name=String(t.name)),this.serializeUserData(t,i),t.isMesh||t.isLine||t.isPoints){const e=await this.processMeshAsync(t);null!==e&&(i.mesh=e)}else t.isCamera&&(i.camera=this.processCamera(t));t.isSkinnedMesh&&this.skins.push(t);const r=e.nodes.push(i)-1;if(s.set(t,r),t.children.length>0){const e=[];for(let s=0,i=t.children.length;s<i;s++){const i=t.children[s];if(i.visible||!1===n.onlyVisible){const t=await this.processNodeAsync(i);null!==t&&e.push(t)}}e.length>0&&(i.children=e)}return await this.t(function(e){e.writeNode&&e.writeNode(t,i)}),r}async processSceneAsync(t){const e=this.json,n=this.options;e.scenes||(e.scenes=[],e.scene=0);const s={};""!==t.name&&(s.name=t.name),e.scenes.push(s);const i=[];for(let e=0,s=t.children.length;e<s;e++){const s=t.children[e];if(s.visible||!1===n.onlyVisible){const t=await this.processNodeAsync(s);null!==t&&i.push(t)}}i.length>0&&(s.nodes=i),this.serializeUserData(t,s)}async processObjectsAsync(t){const e=new d;e.name="AuxScene";for(let n=0;n<t.length;n++)e.children.push(t[n]);await this.processSceneAsync(e)}async processInputAsync(t){const e=this.options;t=t instanceof Array?t:[t],await this.t(function(e){e.beforeParse&&e.beforeParse(t)});const n=[];for(let e=0;e<t.length;e++)t[e]instanceof d?await this.processSceneAsync(t[e]):n.push(t[e]);n.length>0&&await this.processObjectsAsync(n);for(let t=0;t<this.skins.length;++t)this.processSkin(this.skins[t]);for(let n=0;n<e.animations.length;++n)this.processAnimation(e.animations[n],t[0]);await this.t(function(e){e.afterParse&&e.afterParse(t)})}async t(t){for(let e=0,n=this.plugins.length;e<n;e++)await t(this.plugins[e])}}class at{constructor(t){this.writer=t,this.name="KHR_lights_punctual"}writeNode(t,e){if(!t.isLight)return;if(!t.isDirectionalLight&&!t.isPointLight&&!t.isSpotLight)return;const n=this.writer,s=n.json,i=n.extensionsUsed,r={};t.name&&(r.name=t.name),r.color=t.color.toArray(),r.intensity=t.intensity,t.isDirectionalLight?r.type="directional":t.isPointLight?(r.type="point",t.distance>0&&(r.range=t.distance)):t.isSpotLight&&(r.type="spot",t.distance>0&&(r.range=t.distance),r.spot={},r.spot.innerConeAngle=(1-t.penumbra)*t.angle,r.spot.outerConeAngle=t.angle),void 0!==t.decay&&t.decay,t.target&&(t.target.parent!==t||0!==t.target.position.x||0!==t.target.position.y||t.target.position.z),i[this.name]||(s.extensions=s.extensions||{},s.extensions[this.name]={lights:[]},i[this.name]=!0);const o=s.extensions[this.name].lights;o.push(r),e.extensions=e.extensions||{},e.extensions[this.name]={light:o.length-1}}}class ct{constructor(t){this.writer=t,this.name="KHR_materials_unlit"}async writeMaterialAsync(t,e){if(!t.isMeshBasicMaterial)return;const n=this.writer.extensionsUsed;e.extensions=e.extensions||{},e.extensions[this.name]={},n[this.name]=!0,e.pbrMetallicRoughness.metallicFactor=0,e.pbrMetallicRoughness.roughnessFactor=.9}}class ht{constructor(t){this.writer=t,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.clearcoat)return;const n=this.writer,s=n.extensionsUsed,i={};if(i.clearcoatFactor=t.clearcoat,t.clearcoatMap){const e={index:await n.processTextureAsync(t.clearcoatMap),texCoord:t.clearcoatMap.channel};n.applyTextureTransform(e,t.clearcoatMap),i.clearcoatTexture=e}if(i.clearcoatRoughnessFactor=t.clearcoatRoughness,t.clearcoatRoughnessMap){const e={index:await n.processTextureAsync(t.clearcoatRoughnessMap),texCoord:t.clearcoatRoughnessMap.channel};n.applyTextureTransform(e,t.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=e}if(t.clearcoatNormalMap){const e={index:await n.processTextureAsync(t.clearcoatNormalMap),texCoord:t.clearcoatNormalMap.channel};1!==t.clearcoatNormalScale.x&&(e.scale=t.clearcoatNormalScale.x),n.applyTextureTransform(e,t.clearcoatNormalMap),i.clearcoatNormalTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=i,s[this.name]=!0}}class lt{constructor(t){this.writer=t,this.name="KHR_materials_dispersion"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.dispersion)return;const n=this.writer.extensionsUsed,s={};s.dispersion=t.dispersion,e.extensions=e.extensions||{},e.extensions[this.name]=s,n[this.name]=!0}}class ut{constructor(t){this.writer=t,this.name="KHR_materials_iridescence"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.iridescence)return;const n=this.writer,s=n.extensionsUsed,i={};if(i.iridescenceFactor=t.iridescence,t.iridescenceMap){const e={index:await n.processTextureAsync(t.iridescenceMap),texCoord:t.iridescenceMap.channel};n.applyTextureTransform(e,t.iridescenceMap),i.iridescenceTexture=e}if(i.iridescenceIor=t.iridescenceIOR,i.iridescenceThicknessMinimum=t.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=t.iridescenceThicknessRange[1],t.iridescenceThicknessMap){const e={index:await n.processTextureAsync(t.iridescenceThicknessMap),texCoord:t.iridescenceThicknessMap.channel};n.applyTextureTransform(e,t.iridescenceThicknessMap),i.iridescenceThicknessTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=i,s[this.name]=!0}}class ft{constructor(t){this.writer=t,this.name="KHR_materials_transmission"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.transmission)return;const n=this.writer,s=n.extensionsUsed,i={};if(i.transmissionFactor=t.transmission,t.transmissionMap){const e={index:await n.processTextureAsync(t.transmissionMap),texCoord:t.transmissionMap.channel};n.applyTextureTransform(e,t.transmissionMap),i.transmissionTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=i,s[this.name]=!0}}class wt{constructor(t){this.writer=t,this.name="KHR_materials_volume"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.transmission)return;const n=this.writer,s=n.extensionsUsed,i={};if(i.thicknessFactor=t.thickness,t.thicknessMap){const e={index:await n.processTextureAsync(t.thicknessMap),texCoord:t.thicknessMap.channel};n.applyTextureTransform(e,t.thicknessMap),i.thicknessTexture=e}t.attenuationDistance!==1/0&&(i.attenuationDistance=t.attenuationDistance),i.attenuationColor=t.attenuationColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=i,s[this.name]=!0}}class dt{constructor(t){this.writer=t,this.name="KHR_materials_ior"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||1.5===t.ior)return;const n=this.writer.extensionsUsed,s={};s.ior=t.ior,e.extensions=e.extensions||{},e.extensions[this.name]=s,n[this.name]=!0}}class yt{constructor(t){this.writer=t,this.name="KHR_materials_specular"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||1===t.specularIntensity&&t.specularColor.equals(et)&&!t.specularIntensityMap&&!t.specularColorMap)return;const n=this.writer,s=n.extensionsUsed,i={};if(t.specularIntensityMap){const e={index:await n.processTextureAsync(t.specularIntensityMap),texCoord:t.specularIntensityMap.channel};n.applyTextureTransform(e,t.specularIntensityMap),i.specularTexture=e}if(t.specularColorMap){const e={index:await n.processTextureAsync(t.specularColorMap),texCoord:t.specularColorMap.channel};n.applyTextureTransform(e,t.specularColorMap),i.specularColorTexture=e}i.specularFactor=t.specularIntensity,i.specularColorFactor=t.specularColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=i,s[this.name]=!0}}class mt{constructor(t){this.writer=t,this.name="KHR_materials_sheen"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0==t.sheen)return;const n=this.writer,s=n.extensionsUsed,i={};if(t.sheenRoughnessMap){const e={index:await n.processTextureAsync(t.sheenRoughnessMap),texCoord:t.sheenRoughnessMap.channel};n.applyTextureTransform(e,t.sheenRoughnessMap),i.sheenRoughnessTexture=e}if(t.sheenColorMap){const e={index:await n.processTextureAsync(t.sheenColorMap),texCoord:t.sheenColorMap.channel};n.applyTextureTransform(e,t.sheenColorMap),i.sheenColorTexture=e}i.sheenRoughnessFactor=t.sheenRoughness,i.sheenColorFactor=t.sheenColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=i,s[this.name]=!0}}class pt{constructor(t){this.writer=t,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0==t.anisotropy)return;const n=this.writer,s=n.extensionsUsed,i={};if(t.anisotropyMap){const e={index:await n.processTextureAsync(t.anisotropyMap)};n.applyTextureTransform(e,t.anisotropyMap),i.anisotropyTexture=e}i.anisotropyStrength=t.anisotropy,i.anisotropyRotation=t.anisotropyRotation,e.extensions=e.extensions||{},e.extensions[this.name]=i,s[this.name]=!0}}class At{constructor(t){this.writer=t,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(t,e){if(!t.isMeshStandardMaterial||1===t.emissiveIntensity)return;const n=this.writer.extensionsUsed,s={};s.emissiveStrength=t.emissiveIntensity,e.extensions=e.extensions||{},e.extensions[this.name]=s,n[this.name]=!0}}class Tt{constructor(t){this.writer=t,this.name="EXT_materials_bump"}async writeMaterialAsync(t,e){if(!t.isMeshStandardMaterial||1===t.bumpScale&&!t.bumpMap)return;const n=this.writer,s=n.extensionsUsed,i={};if(t.bumpMap){const e={index:await n.processTextureAsync(t.bumpMap),texCoord:t.bumpMap.channel};n.applyTextureTransform(e,t.bumpMap),i.bumpTexture=e}i.bumpFactor=t.bumpScale,e.extensions=e.extensions||{},e.extensions[this.name]=i,s[this.name]=!0}}class xt{constructor(t){this.writer=t,this.name="EXT_mesh_gpu_instancing"}writeNode(t,e){if(!t.isInstancedMesh)return;const s=this.writer,i=t,r=new Float32Array(3*i.count),o=new Float32Array(4*i.count),a=new Float32Array(3*i.count),c=new w,h=new n,u=new y,f=new n;for(let t=0;t<i.count;t++)i.getMatrixAt(t,c),c.decompose(h,u,f),h.toArray(r,3*t),u.toArray(o,4*t),f.toArray(a,3*t);const d={TRANSLATION:s.processAccessor(new l(r,3)),ROTATION:s.processAccessor(new l(o,4)),SCALE:s.processAccessor(new l(a,3))};i.instanceColor&&(d.i=s.processAccessor(i.instanceColor)),e.extensions=e.extensions||{},e.extensions[this.name]={attributes:d},s.extensionsUsed[this.name]=!0,s.extensionsRequired[this.name]=!0}}O.Utils={insertKeyframe:function(t,e){const n=.001,s=t.getValueSize(),i=new t.TimeBufferType(t.times.length+1),r=new t.ValueBufferType(t.values.length+s),o=t.createInterpolant(new t.ValueBufferType(s));let a;if(0===t.times.length){i[0]=e;for(let t=0;t<s;t++)r[t]=0;a=0}else if(e<t.times[0]){if(Math.abs(t.times[0]-e)<n)return 0;i[0]=e,i.set(t.times,1),r.set(o.evaluate(e),0),r.set(t.values,s),a=0}else if(e>t.times[t.times.length-1]){if(Math.abs(t.times[t.times.length-1]-e)<n)return t.times.length-1;i[i.length-1]=e,i.set(t.times,0),r.set(t.values,0),r.set(o.evaluate(e),t.values.length),a=i.length-1}else for(let c=0;c<t.times.length;c++){if(Math.abs(t.times[c]-e)<n)return c;if(t.times[c]<e&&t.times[c+1]>e){i.set(t.times.slice(0,c+1),0),i[c+1]=e,i.set(t.times.slice(c+1),c+2),r.set(t.values.slice(0,(c+1)*s),0),r.set(o.evaluate(e),(c+1)*s),r.set(t.values.slice((c+1)*s),(c+2)*s),a=c+1;break}}return t.times=i,t.values=r,a},mergeMorphTargetTracks:function(t,e){const n=[],s={},i=t.tracks;for(let t=0;t<i.length;++t){let r=i[t];const o=u.parseTrackName(r.name),a=u.findNode(e,o.nodeName);if("morphTargetInfluences"!==o.propertyName||void 0===o.propertyIndex){n.push(r);continue}if(r.createInterpolant!==r.InterpolantFactoryMethodDiscrete&&r.createInterpolant!==r.InterpolantFactoryMethodLinear){if(r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");r=r.clone(),r.setInterpolation(m)}const c=a.morphTargetInfluences.length,h=a.morphTargetDictionary[o.propertyIndex];if(void 0===h)throw new Error("THREE.GLTFExporter: Morph target name not found: "+o.propertyIndex);let l;if(void 0===s[a.uuid]){l=r.clone();const t=new l.ValueBufferType(c*l.times.length);for(let e=0;e<l.times.length;e++)t[e*c+h]=l.values[e];l.name=(o.nodeName||"")+".morphTargetInfluences",l.values=t,s[a.uuid]=l,n.push(l);continue}const f=r.createInterpolant(new r.ValueBufferType(1));l=s[a.uuid];for(let t=0;t<l.times.length;t++)l.values[t*c+h]=f.evaluate(l.times[t]);for(let t=0;t<r.times.length;t++){const e=this.insertKeyframe(l,r.times[t]);l.values[e*c+h]=r.values[t]}}return t.tracks=n,t},toFloat32BufferAttribute:function(t){const e=new l(new Float32Array(t.count*t.itemSize),t.itemSize,!1);if(!t.normalized&&!t.isInterleavedBufferAttribute)return e.array.set(t.array),e;for(let n=0,s=t.count;n<s;n++)for(let s=0;s<t.itemSize;s++)e.setComponent(n,s,t.getComponent(n,s));return e}};export{O as GLTFExporter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Vector3 as n,Color as o,Vector2 as t,Matrix3 as e,ColorManagement as f,SRGBColorSpace as i}from"three";class l{parse(l){let r="",s=0,c=0,v=0;const u=new n,p=new o,d=new n,m=new t,w=[];return l.traverse(function(n){!0===n.isMesh&&function(n){let o=0,t=0,f=0;const i=n.geometry,l=new e,p=i.getAttribute("position"),a=i.getAttribute("normal"),L=i.getAttribute("uv"),g=i.getIndex();if(r+="o "+n.name+"\n",n.material&&n.material.name&&(r+="usemtl "+n.material.name+"\n"),void 0!==p)for(let t=0,e=p.count;t<e;t++,o++)u.fromBufferAttribute(p,t),u.applyMatrix4(n.matrixWorld),r+="v "+u.x+" "+u.y+" "+u.z+"\n";if(void 0!==L)for(let n=0,o=L.count;n<o;n++,f++)m.fromBufferAttribute(L,n),r+="vt "+m.x+" "+m.y+"\n";if(void 0!==a){l.getNormalMatrix(n.matrixWorld);for(let n=0,o=a.count;n<o;n++,t++)d.fromBufferAttribute(a,n),d.applyMatrix3(l).normalize(),r+="vn "+d.x+" "+d.y+" "+d.z+"\n"}if(null!==g)for(let n=0,o=g.count;n<o;n+=3){for(let o=0;o<3;o++){const t=g.getX(n+o)+1;w[o]=s+t+(a||L?"/"+(L?c+t:"")+(a?"/"+(v+t):""):"")}r+="f "+w.join(" ")+"\n"}else for(let n=0,o=p.count;n<o;n+=3){for(let o=0;o<3;o++){const t=n+o+1;w[o]=s+t+(a||L?"/"+(L?c+t:"")+(a?"/"+(v+t):""):"")}r+="f "+w.join(" ")+"\n"}s+=o,c+=f,v+=t}(n),!0===n.isLine&&function(n){let o=0;const t=n.geometry,e=n.type,f=t.getAttribute("position");if(r+="o "+n.name+"\n",void 0!==f)for(let t=0,e=f.count;t<e;t++,o++)u.fromBufferAttribute(f,t),u.applyMatrix4(n.matrixWorld),r+="v "+u.x+" "+u.y+" "+u.z+"\n";if("Line"===e){r+="l ";for(let n=1,o=f.count;n<=o;n++)r+=s+n+" ";r+="\n"}if("LineSegments"===e)for(let n=1,o=n+1,t=f.count;n<t;n+=2,o=n+1)r+="l "+(s+n)+" "+(s+o)+"\n";s+=o}(n),!0===n.isPoints&&function(n){let o=0;const t=n.geometry,e=t.getAttribute("position"),l=t.getAttribute("color");if(r+="o "+n.name+"\n",void 0!==e){for(let t=0,s=e.count;t<s;t++,o++)u.fromBufferAttribute(e,t),u.applyMatrix4(n.matrixWorld),r+="v "+u.x+" "+u.y+" "+u.z,void 0!==l&&(p.fromBufferAttribute(l,t),f.workingToColorSpace(p,i),r+=" "+p.r+" "+p.g+" "+p.b),r+="\n";r+="p ";for(let n=1,o=e.count;n<=o;n++)r+=s+n+" ";r+="\n"}s+=o}(n)}),r}}export{l as OBJExporter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Color as n,Vector3 as t,Matrix3 as e,ColorManagement as o,SRGBColorSpace as r}from"three";class l{parse(l,i,a={}){function f(n){l.traverse(function(t){if(!0===t.isMesh||t.isPoints){const e=t,o=e.geometry;!0===o.hasAttribute("position")&&n(e,o)}})}const p=(a=Object.assign({binary:!1,excludeAttributes:[],littleEndian:!1},a)).excludeAttributes;let u=!0,c=!1,s=!1,y=!1,d=0,h=0;l.traverse(function(n){if(!0===n.isMesh){const t=n.geometry,e=t.getAttribute("position"),o=t.getAttribute("normal"),r=t.getAttribute("uv"),l=t.getAttribute("color"),i=t.getIndex();if(void 0===e)return;d+=e.count,h+=i?i.count/3:e.count/3,void 0!==o&&(c=!0),void 0!==r&&(y=!0),void 0!==l&&(s=!0)}else if(n.isPoints){const t=n.geometry,e=t.getAttribute("position"),o=t.getAttribute("normal"),r=t.getAttribute("color");d+=e.count,void 0!==o&&(c=!0),void 0!==r&&(s=!0),u=!1}});const $=new n;if(u=u&&-1===p.indexOf("index"),c=c&&-1===p.indexOf("normal"),s=s&&-1===p.indexOf("color"),y=y&&-1===p.indexOf("uv"),u&&h!==Math.floor(h))return null;let m=`ply\nformat ${a.binary?a.littleEndian?"binary_little_endian":"binary_big_endian":"ascii"} 1.0\nelement vertex ${d}\nproperty float x\nproperty float y\nproperty float z\n`;!0===c&&(m+="property float nx\nproperty float ny\nproperty float nz\n"),!0===y&&(m+="property float s\nproperty float t\n"),!0===s&&(m+="property uchar red\nproperty uchar green\nproperty uchar blue\n"),!0===u&&(m+=`element face ${h}\nproperty list uchar int vertex_index\n`),m+="end_header\n";const v=new t,x=new e;let w=null;if(!0===a.binary){const n=(new TextEncoder).encode(m),t=d*(12+(c?12:0)+(s?3:0)+(y?8:0)),e=u?13*h:0,l=new DataView(new ArrayBuffer(n.length+t+e));new Uint8Array(l.buffer).set(n,0);let i=n.length,p=n.length+t,b=0;f(function(n,t){const e=t.getAttribute("position"),f=t.getAttribute("normal"),d=t.getAttribute("uv"),h=t.getAttribute("color"),m=t.getIndex();x.getNormalMatrix(n.matrixWorld);for(let t=0,p=e.count;t<p;t++)v.fromBufferAttribute(e,t),v.applyMatrix4(n.matrixWorld),l.setFloat32(i,v.x,a.littleEndian),i+=4,l.setFloat32(i,v.y,a.littleEndian),i+=4,l.setFloat32(i,v.z,a.littleEndian),i+=4,!0===c&&(null!=f?(v.fromBufferAttribute(f,t),v.applyMatrix3(x).normalize(),l.setFloat32(i,v.x,a.littleEndian),i+=4,l.setFloat32(i,v.y,a.littleEndian),i+=4,l.setFloat32(i,v.z,a.littleEndian),i+=4):(l.setFloat32(i,0,a.littleEndian),i+=4,l.setFloat32(i,0,a.littleEndian),i+=4,l.setFloat32(i,0,a.littleEndian),i+=4)),!0===y&&(null!=d?(l.setFloat32(i,d.getX(t),a.littleEndian),i+=4,l.setFloat32(i,d.getY(t),a.littleEndian),i+=4):(l.setFloat32(i,0,a.littleEndian),i+=4,l.setFloat32(i,0,a.littleEndian),i+=4)),!0===s&&(null!=h?($.fromBufferAttribute(h,t),o.workingToColorSpace($,r),l.setUint8(i,Math.floor(255*$.r)),i+=1,l.setUint8(i,Math.floor(255*$.g)),i+=1,l.setUint8(i,Math.floor(255*$.b)),i+=1):(l.setUint8(i,255),i+=1,l.setUint8(i,255),i+=1,l.setUint8(i,255),i+=1));if(!0===u)if(null!==m)for(let n=0,t=m.count;n<t;n+=3)l.setUint8(p,3),p+=1,l.setUint32(p,m.getX(n+0)+b,a.littleEndian),p+=4,l.setUint32(p,m.getX(n+1)+b,a.littleEndian),p+=4,l.setUint32(p,m.getX(n+2)+b,a.littleEndian),p+=4;else for(let n=0,t=e.count;n<t;n+=3)l.setUint8(p,3),p+=1,l.setUint32(p,b+n,a.littleEndian),p+=4,l.setUint32(p,b+n+1,a.littleEndian),p+=4,l.setUint32(p,b+n+2,a.littleEndian),p+=4;b+=e.count}),w=l.buffer}else{let n=0,t="",e="";f(function(l,i){const a=i.getAttribute("position"),f=i.getAttribute("normal"),p=i.getAttribute("uv"),d=i.getAttribute("color"),m=i.getIndex();x.getNormalMatrix(l.matrixWorld);for(let n=0,e=a.count;n<e;n++){v.fromBufferAttribute(a,n),v.applyMatrix4(l.matrixWorld);let e=v.x+" "+v.y+" "+v.z;!0===c&&(null!=f?(v.fromBufferAttribute(f,n),v.applyMatrix3(x).normalize(),e+=" "+v.x+" "+v.y+" "+v.z):e+=" 0 0 0"),!0===y&&(e+=null!=p?" "+p.getX(n)+" "+p.getY(n):" 0 0"),!0===s&&(null!=d?($.fromBufferAttribute(d,n),o.workingToColorSpace($,r),e+=" "+Math.floor(255*$.r)+" "+Math.floor(255*$.g)+" "+Math.floor(255*$.b)):e+=" 255 255 255"),t+=e+"\n"}if(!0===u){if(null!==m)for(let t=0,o=m.count;t<o;t+=3)e+=`3 ${m.getX(t+0)+n}`,e+=` ${m.getX(t+1)+n}`,e+=` ${m.getX(t+2)+n}\n`;else for(let t=0,o=a.count;t<o;t+=3)e+=`3 ${n+t} ${n+t+1} ${n+t+2}\n`;h+=m?m.count/3:a.count/3}n+=a.count}),w=`${m}${t}${u?`${e}\n`:"\n"}`}return"function"==typeof i&&requestAnimationFrame(()=>i(w)),w}}export{l as PLYExporter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Vector3 as e}from"three";class t{parse(t,n={}){const o=(n=Object.assign({binary:!1},n)).binary,r=[];let l,i=0;t.traverse(function(e){if(e.isMesh){const t=e.geometry,n=t.index,o=t.getAttribute("position");i+=null!==n?n.count/3:o.count/3,r.push({object3d:e,geometry:t})}});let f=80;if(!0===o){const e=new ArrayBuffer(2*i+3*i*4*4+80+4);l=new DataView(e),l.setUint32(f,i,!0),f+=4}else l="",l+="solid exported\n";const c=new e,s=new e,a=new e,p=new e,u=new e,w=new e;for(let e=0,t=r.length;e<t;e++){const t=r[e].object3d,n=r[e].geometry,o=n.index,l=n.getAttribute("position");if(null!==o)for(let e=0;e<o.count;e+=3){d(o.getX(e+0),o.getX(e+1),o.getX(e+2),l,t)}else for(let e=0;e<l.count;e+=3){d(e+0,e+1,e+2,l,t)}}return!1===o&&(l+="endsolid exported\n"),l;function d(e,t,n,r,i){c.fromBufferAttribute(r,e),s.fromBufferAttribute(r,t),a.fromBufferAttribute(r,n),!0===i.isSkinnedMesh&&(i.applyBoneTransform(e,c),i.applyBoneTransform(t,s),i.applyBoneTransform(n,a)),c.applyMatrix4(i.matrixWorld),s.applyMatrix4(i.matrixWorld),a.applyMatrix4(i.matrixWorld),function(e,t,n){p.subVectors(n,t),u.subVectors(e,t),p.cross(u).normalize(),w.copy(p).normalize(),!0===o?(l.setFloat32(f,w.x,!0),f+=4,l.setFloat32(f,w.y,!0),f+=4,l.setFloat32(f,w.z,!0),f+=4):(l+="\tfacet normal "+w.x+" "+w.y+" "+w.z+"\n",l+="\t\touter loop\n")}(c,s,a),m(c),m(s),m(a),!0===o?(l.setUint16(f,0,!0),f+=2):(l+="\t\tendloop\n",l+="\tendfacet\n")}function m(e){!0===o?(l.setFloat32(f,e.x,!0),f+=4,l.setFloat32(f,e.y,!0),f+=4,l.setFloat32(f,e.z,!0),f+=4):l+="\t\t\tvertex "+e.x+" "+e.y+" "+e.z+"\n"}}}export{t as STLExporter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Loader as e,FileLoader as t,SRGBColorSpace as r,LinearSRGBColorSpace as s,BufferGeometry as n,BufferAttribute as o,Color as i,ColorManagement as c}from"three";const a=new WeakMap;class h extends e{constructor(e){super(e),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"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,r,s,n){const o=new t(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,e=>{this.parse(e,r,n)},s,n)}parse(e,t,s=()=>{}){this.decodeDracoFile(e,t,null,null,r,s).catch(s)}decodeDracoFile(e,t,r,n,o=s,i=()=>{}){const c={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!r,vertexColorSpace:o};return this.decodeGeometry(e,c).then(t).catch(i)}decodeGeometry(e,t){const r=JSON.stringify(t);if(a.has(e)){const t=a.get(e);if(t.key===r)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let s;const n=this.workerNextTaskID++,o=e.byteLength,i=this.t(n,o).then(r=>(s=r,new Promise((r,o)=>{s.o[n]={resolve:r,reject:o},s.postMessage({type:"decode",id:n,taskConfig:t,buffer:e},[e])}))).then(e=>this.i(e.geometry));return i.catch(()=>!0).then(()=>{s&&n&&this.h(s,n)}),a.set(e,{key:r,promise:i}),i}i(e){const t=new n;e.index&&t.setIndex(new o(e.index.array,1));for(let r=0;r<e.attributes.length;r++){const s=e.attributes[r],n=s.name,i=s.array,c=s.itemSize,a=new o(i,c);"color"===n&&(this.u(a,s.vertexColorSpace),a.normalized=i instanceof Float32Array==!1),t.setAttribute(n,a)}return t}u(e,t){if(t!==r)return;const s=new i;for(let t=0,n=e.count;t<n;t++)s.fromBufferAttribute(e,t),c.colorSpaceToWorking(s,r),e.setXYZ(t,s.r,s.g,s.b)}l(e,r){const s=new t(this.manager);return s.setPath(this.decoderPath),s.setResponseType(r),s.setWithCredentials(this.withCredentials),new Promise((t,r)=>{s.load(e,t,void 0,r)})}preload(){return this.p(),this}p(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this.l("draco_decoder.js","text")):(t.push(this.l("draco_wasm_wrapper.js","text")),t.push(this.l("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(t=>{const r=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const s=u.toString(),n=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([n]))}),this.decoderPending}t(e,t){return this.p().then(()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e.o={},e.m={},e.A=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const r=t.data;switch(r.type){case"decode":e.o[r.id].resolve(r);break;case"error":e.o[r.id].reject(r)}},this.workerPool.push(e)}else this.workerPool.sort(function(e,t){return e.A>t.A?-1:1});const r=this.workerPool[this.workerPool.length-1];return r.m[e]=t,r.A+=t,r})}h(e,t){e.A-=e.m[t],delete e.o[t],delete e.m[t]}debug(){}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}}function u(){let e,t;function r(e,t,r,s,n,o){const i=o.num_components(),c=r.num_points()*i,a=c*n.BYTES_PER_ELEMENT,h=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,n),u=e.D(a);t.GetAttributeDataArrayForAllPoints(r,o,h,a,u);const d=new n(e.HEAPF32.buffer,u,c).slice();return e.O(u),{name:s,array:d,itemSize:i}}onmessage=function(s){const n=s.data;switch(n.type){case"init":e=n.decoderConfig,t=new Promise(function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)});break;case"decode":const s=n.buffer,o=n.taskConfig;t.then(e=>{const t=e.draco,i=new t.Decoder;try{const e=function(e,t,s,n){const o=n.attributeIDs,i=n.attributeTypes;let c,a;const h=t.GetEncodedGeometryType(s);if(h===e.TRIANGULAR_MESH)c=new e.Mesh,a=t.DecodeArrayToMesh(s,s.byteLength,c);else{if(h!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");c=new e.PointCloud,a=t.DecodeArrayToPointCloud(s,s.byteLength,c)}if(!a.ok()||0===c.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+a.error_msg());const u={index:null,attributes:[]};for(const s in o){const a=self[i[s]];let h,d;if(n.useUniqueIDs)d=o[s],h=t.GetAttributeByUniqueId(c,d);else{if(d=t.GetAttributeId(c,e[o[s]]),-1===d)continue;h=t.GetAttribute(c,d)}const l=r(e,t,c,s,a,h);"color"===s&&(l.vertexColorSpace=n.vertexColorSpace),u.attributes.push(l)}h===e.TRIANGULAR_MESH&&(u.index=function(e,t,r){const s=r.num_faces(),n=3*s,o=4*n,i=e.D(o);t.GetTrianglesUInt32Array(r,o,i);const c=new Uint32Array(e.HEAPF32.buffer,i,n).slice();return e.O(i),{array:c,itemSize:1}}(e,t,c));return e.destroy(c),u}(t,i,new Int8Array(s),o),c=e.attributes.map(e=>e.array.buffer);e.index&&c.push(e.index.array.buffer),self.postMessage({type:"decode",id:n.id,geometry:e},c)}catch(e){self.postMessage({type:"error",id:n.id,error:e.message})}finally{t.destroy(i)}})}}}export{h as DRACOLoader};
|