@unikia/upe-renderer 0.0.0-stage → 0.187.11
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/LICENSE +21 -0
- package/LICENSE.types +21 -0
- package/README.md +35 -2
- package/README.three.md +85 -0
- package/UPSTREAM.md +11 -0
- package/build/three.cjs +17 -0
- package/build/three.core.d.ts +1 -0
- package/build/three.core.js +61178 -0
- package/build/three.d.cts +1 -0
- package/build/three.module.d.ts +1 -0
- package/build/three.module.js +19537 -0
- package/build/three.tsl.d.ts +1 -0
- package/build/three.tsl.js +41943 -0
- package/build/three.webgpu.d.ts +1 -0
- package/build/three.webgpu.js +54819 -0
- package/build/three.webgpu.nodes.d.ts +1 -0
- package/build/three.webgpu.nodes.js +96449 -0
- package/examples/jsm/Addons.d.ts +300 -0
- package/examples/jsm/Addons.js +303 -0
- package/examples/jsm/animation/AnimationClipCreator.d.ts +12 -0
- package/examples/jsm/animation/AnimationClipCreator.js +168 -0
- package/examples/jsm/animation/CCDIKSolver.d.ts +44 -0
- package/examples/jsm/animation/CCDIKSolver.js +607 -0
- package/examples/jsm/capabilities/WebGL.d.ts +6 -0
- package/examples/jsm/capabilities/WebGL.js +113 -0
- package/examples/jsm/capabilities/WebGPU.d.ts +7 -0
- package/examples/jsm/capabilities/WebGPU.js +59 -0
- package/examples/jsm/controls/ArcballControls.d.ts +208 -0
- package/examples/jsm/controls/ArcballControls.js +3543 -0
- package/examples/jsm/controls/DragControls.d.ts +81 -0
- package/examples/jsm/controls/DragControls.js +452 -0
- package/examples/jsm/controls/FirstPersonControls.d.ts +105 -0
- package/examples/jsm/controls/FirstPersonControls.js +512 -0
- package/examples/jsm/controls/FlyControls.d.ts +44 -0
- package/examples/jsm/controls/FlyControls.js +384 -0
- package/examples/jsm/controls/MapControls.d.ts +21 -0
- package/examples/jsm/controls/MapControls.js +116 -0
- package/examples/jsm/controls/OrbitControls.d.ts +295 -0
- package/examples/jsm/controls/OrbitControls.js +1985 -0
- package/examples/jsm/controls/PointerLockControls.d.ts +84 -0
- package/examples/jsm/controls/PointerLockControls.js +264 -0
- package/examples/jsm/controls/TrackballControls.d.ts +152 -0
- package/examples/jsm/controls/TrackballControls.js +1106 -0
- package/examples/jsm/controls/TransformControls.d.ts +363 -0
- package/examples/jsm/controls/TransformControls.js +2003 -0
- package/examples/jsm/csm/CSM.d.ts +55 -0
- package/examples/jsm/csm/CSM.js +598 -0
- package/examples/jsm/csm/CSMFrustum.d.ts +85 -0
- package/examples/jsm/csm/CSMFrustum.js +234 -0
- package/examples/jsm/csm/CSMHelper.d.ts +28 -0
- package/examples/jsm/csm/CSMHelper.js +243 -0
- package/examples/jsm/csm/CSMShader.d.ts +4 -0
- package/examples/jsm/csm/CSMShader.js +378 -0
- package/examples/jsm/csm/CSMShadowNode.d.ts +44 -0
- package/examples/jsm/csm/CSMShadowNode.js +619 -0
- package/examples/jsm/curves/CurveExtras.d.ts +68 -0
- package/examples/jsm/curves/CurveExtras.js +694 -0
- package/examples/jsm/curves/NURBSCurve.d.ts +28 -0
- package/examples/jsm/curves/NURBSCurve.js +169 -0
- package/examples/jsm/curves/NURBSSurface.d.ts +13 -0
- package/examples/jsm/curves/NURBSSurface.js +98 -0
- package/examples/jsm/curves/NURBSUtils.d.ts +146 -0
- package/examples/jsm/curves/NURBSUtils.js +532 -0
- package/examples/jsm/curves/NURBSVolume.d.ts +23 -0
- package/examples/jsm/curves/NURBSVolume.js +82 -0
- package/examples/jsm/effects/AnaglyphEffect.d.ts +21 -0
- package/examples/jsm/effects/AnaglyphEffect.js +274 -0
- package/examples/jsm/effects/AsciiEffect.d.ts +18 -0
- package/examples/jsm/effects/AsciiEffect.js +323 -0
- package/examples/jsm/effects/OutlineEffect.d.ts +28 -0
- package/examples/jsm/effects/OutlineEffect.js +489 -0
- package/examples/jsm/effects/ParallaxBarrierEffect.d.ts +11 -0
- package/examples/jsm/effects/ParallaxBarrierEffect.js +155 -0
- package/examples/jsm/effects/StereoEffect.d.ts +9 -0
- package/examples/jsm/effects/StereoEffect.js +91 -0
- package/examples/jsm/environments/ColorEnvironment.d.ts +9 -0
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/DebugEnvironment.d.ts +5 -0
- package/examples/jsm/environments/DebugEnvironment.js +102 -0
- package/examples/jsm/environments/RoomEnvironment.d.ts +6 -0
- package/examples/jsm/environments/RoomEnvironment.js +185 -0
- package/examples/jsm/exporters/DRACOExporter.d.ts +17 -0
- package/examples/jsm/exporters/DRACOExporter.js +332 -0
- package/examples/jsm/exporters/EXRExporter.d.ts +27 -0
- package/examples/jsm/exporters/EXRExporter.js +1275 -0
- package/examples/jsm/exporters/GLTFExporter.d.ts +161 -0
- package/examples/jsm/exporters/GLTFExporter.js +3856 -0
- package/examples/jsm/exporters/KTX2Exporter.d.ts +7 -0
- package/examples/jsm/exporters/KTX2Exporter.js +347 -0
- package/examples/jsm/exporters/OBJExporter.d.ts +7 -0
- package/examples/jsm/exporters/OBJExporter.js +351 -0
- package/examples/jsm/exporters/PLYExporter.d.ts +31 -0
- package/examples/jsm/exporters/PLYExporter.js +786 -0
- package/examples/jsm/exporters/STLExporter.d.ts +21 -0
- package/examples/jsm/exporters/STLExporter.js +221 -0
- package/examples/jsm/exporters/USDZExporter.d.ts +30 -0
- package/examples/jsm/exporters/USDZExporter.js +1489 -0
- package/examples/jsm/generators/CityGenerator.d.ts +131 -0
- package/examples/jsm/generators/CityGenerator.js +679 -0
- package/examples/jsm/generators/ForestGenerator.d.ts +73 -0
- package/examples/jsm/generators/ForestGenerator.js +347 -0
- package/examples/jsm/generators/TerrainGenerator.d.ts +57 -0
- package/examples/jsm/generators/TerrainGenerator.js +516 -0
- package/examples/jsm/generators/TreeGenerator.d.ts +102 -0
- package/examples/jsm/generators/TreeGenerator.js +371 -0
- package/examples/jsm/generators/city/BenchGenerator.d.ts +29 -0
- package/examples/jsm/generators/city/BenchGenerator.js +127 -0
- package/examples/jsm/generators/city/CarGenerator.d.ts +43 -0
- package/examples/jsm/generators/city/CarGenerator.js +479 -0
- package/examples/jsm/generators/city/CityGeneratorUtils.js +31 -0
- package/examples/jsm/generators/city/HydrantGenerator.d.ts +27 -0
- package/examples/jsm/generators/city/HydrantGenerator.js +106 -0
- package/examples/jsm/generators/city/InstancedMeshGenerator.d.ts +29 -0
- package/examples/jsm/generators/city/InstancedMeshGenerator.js +86 -0
- package/examples/jsm/generators/city/PersonGenerator.d.ts +44 -0
- package/examples/jsm/generators/city/PersonGenerator.js +447 -0
- package/examples/jsm/generators/city/SidewalkGenerator.d.ts +40 -0
- package/examples/jsm/generators/city/SidewalkGenerator.js +248 -0
- package/examples/jsm/generators/city/SkyscraperGenerator.d.ts +83 -0
- package/examples/jsm/generators/city/SkyscraperGenerator.js +1799 -0
- package/examples/jsm/generators/city/StreetTreeGenerator.d.ts +30 -0
- package/examples/jsm/generators/city/StreetTreeGenerator.js +231 -0
- package/examples/jsm/generators/city/StreetlightGenerator.d.ts +28 -0
- package/examples/jsm/generators/city/StreetlightGenerator.js +100 -0
- package/examples/jsm/generators/city/TrafficlightGenerator.d.ts +29 -0
- package/examples/jsm/generators/city/TrafficlightGenerator.js +106 -0
- package/examples/jsm/generators/city/TrashcanGenerator.d.ts +24 -0
- package/examples/jsm/generators/city/TrashcanGenerator.js +100 -0
- package/examples/jsm/geometries/BoxLineGeometry.d.ts +12 -0
- package/examples/jsm/geometries/BoxLineGeometry.js +92 -0
- package/examples/jsm/geometries/ConvexGeometry.d.ts +5 -0
- package/examples/jsm/geometries/ConvexGeometry.js +72 -0
- package/examples/jsm/geometries/DecalGeometry.d.ts +16 -0
- package/examples/jsm/geometries/DecalGeometry.js +420 -0
- package/examples/jsm/geometries/LoftGeometry.d.ts +83 -0
- package/examples/jsm/geometries/LoftGeometry.js +355 -0
- package/examples/jsm/geometries/ParametricFunctions.d.ts +8 -0
- package/examples/jsm/geometries/ParametricFunctions.js +100 -0
- package/examples/jsm/geometries/ParametricGeometry.d.ts +18 -0
- package/examples/jsm/geometries/ParametricGeometry.js +172 -0
- package/examples/jsm/geometries/RoundedBoxGeometry.d.ts +5 -0
- package/examples/jsm/geometries/RoundedBoxGeometry.js +216 -0
- package/examples/jsm/geometries/TeapotGeometry.d.ts +37 -0
- package/examples/jsm/geometries/TeapotGeometry.js +689 -0
- package/examples/jsm/geometries/TextGeometry.d.ts +89 -0
- package/examples/jsm/geometries/TextGeometry.js +102 -0
- package/examples/jsm/gpgpu/BitonicSort.d.ts +21 -0
- package/examples/jsm/gpgpu/BitonicSort.js +722 -0
- package/examples/jsm/gpgpu/CountingSort.d.ts +31 -0
- package/examples/jsm/gpgpu/CountingSort.js +271 -0
- package/examples/jsm/helpers/AnimationPathHelper.d.ts +38 -0
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/LightProbeGridHelper.d.ts +12 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +166 -0
- package/examples/jsm/helpers/LightProbeGridHelperWebGL.d.ts +12 -0
- package/examples/jsm/helpers/LightProbeGridHelperWebGL.js +221 -0
- package/examples/jsm/helpers/LightProbeHelper.d.ts +12 -0
- package/examples/jsm/helpers/LightProbeHelper.js +166 -0
- package/examples/jsm/helpers/LightProbeHelperGPU.d.ts +12 -0
- package/examples/jsm/helpers/LightProbeHelperGPU.js +102 -0
- package/examples/jsm/helpers/OctreeHelper.d.ts +17 -0
- package/examples/jsm/helpers/OctreeHelper.js +109 -0
- package/examples/jsm/helpers/PositionalAudioHelper.d.ts +13 -0
- package/examples/jsm/helpers/PositionalAudioHelper.js +169 -0
- package/examples/jsm/helpers/RapierHelper.d.ts +13 -0
- package/examples/jsm/helpers/RapierHelper.js +59 -0
- package/examples/jsm/helpers/RectAreaLightHelper.d.ts +10 -0
- package/examples/jsm/helpers/RectAreaLightHelper.js +118 -0
- package/examples/jsm/helpers/TextureHelper.d.ts +10 -0
- package/examples/jsm/helpers/TextureHelper.js +265 -0
- package/examples/jsm/helpers/TextureHelperGPU.d.ts +10 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +214 -0
- package/examples/jsm/helpers/VertexNormalsHelper.d.ts +14 -0
- package/examples/jsm/helpers/VertexNormalsHelper.js +155 -0
- package/examples/jsm/helpers/VertexTangentsHelper.d.ts +12 -0
- package/examples/jsm/helpers/VertexTangentsHelper.js +133 -0
- package/examples/jsm/helpers/ViewHelper.d.ts +20 -0
- package/examples/jsm/helpers/ViewHelper.js +529 -0
- package/examples/jsm/inspector/Extension.d.ts +22 -0
- package/examples/jsm/inspector/Extension.js +107 -0
- package/examples/jsm/inspector/Inspector.d.ts +54 -0
- package/examples/jsm/inspector/Inspector.js +644 -0
- package/examples/jsm/inspector/RendererInspector.d.ts +9 -0
- package/examples/jsm/inspector/RendererInspector.js +624 -0
- package/examples/jsm/inspector/Storage.js +49 -0
- package/examples/jsm/inspector/extensions/color-grading/ColorGrading.d.ts +34 -0
- package/examples/jsm/inspector/extensions/color-grading/ColorGrading.js +2614 -0
- package/examples/jsm/inspector/extensions/color-grading/ColorWheel.js +352 -0
- package/examples/jsm/inspector/extensions/color-grading/CurveEditor.js +599 -0
- package/examples/jsm/inspector/extensions/color-grading/LUT3DStyle.js +1201 -0
- package/examples/jsm/inspector/extensions/color-grading/LUTMath.js +788 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/BrightnessModule.js +72 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ColorWheelModule.js +112 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ContrastModule.js +82 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/CurvesModule.js +109 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ExposureHueModule.js +110 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ExposureModule.js +73 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/HueModule.js +78 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ImportedCubeModule.js +89 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/Module.js +285 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/OutputModule.js +101 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/RendererModule.js +225 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/SatVibranceModule.js +102 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/SaturationModule.js +76 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/VibranceModule.js +76 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/WhiteBalanceModule.js +86 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.d.ts +20 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +911 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.d.ts +11 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +282 -0
- package/examples/jsm/inspector/tabs/Console.js +420 -0
- package/examples/jsm/inspector/tabs/Memory.js +134 -0
- package/examples/jsm/inspector/tabs/Parameters.d.ts +122 -0
- package/examples/jsm/inspector/tabs/Parameters.js +444 -0
- package/examples/jsm/inspector/tabs/Performance.js +298 -0
- package/examples/jsm/inspector/tabs/Settings.js +310 -0
- package/examples/jsm/inspector/tabs/Timeline.js +1824 -0
- package/examples/jsm/inspector/tabs/Viewer.js +1389 -0
- package/examples/jsm/inspector/ui/Graph.js +232 -0
- package/examples/jsm/inspector/ui/Item.d.ts +5 -0
- package/examples/jsm/inspector/ui/Item.js +249 -0
- package/examples/jsm/inspector/ui/List.js +81 -0
- package/examples/jsm/inspector/ui/Profiler.js +2273 -0
- package/examples/jsm/inspector/ui/Style.js +2268 -0
- package/examples/jsm/inspector/ui/Tab.d.ts +9 -0
- package/examples/jsm/inspector/ui/Tab.js +269 -0
- package/examples/jsm/inspector/ui/Values.d.ts +103 -0
- package/examples/jsm/inspector/ui/Values.js +578 -0
- package/examples/jsm/inspector/ui/utils.js +189 -0
- package/examples/jsm/interaction/InteractionManager.d.ts +18 -0
- package/examples/jsm/interaction/InteractionManager.js +226 -0
- package/examples/jsm/interactive/HTMLMesh.d.ts +13 -0
- package/examples/jsm/interactive/HTMLMesh.js +617 -0
- package/examples/jsm/interactive/InteractiveGroup.d.ts +28 -0
- package/examples/jsm/interactive/InteractiveGroup.js +224 -0
- package/examples/jsm/interactive/SelectionBox.d.ts +16 -0
- package/examples/jsm/interactive/SelectionBox.js +324 -0
- package/examples/jsm/interactive/SelectionHelper.d.ts +17 -0
- package/examples/jsm/interactive/SelectionHelper.js +150 -0
- package/examples/jsm/libs/basis/README.md +45 -0
- package/examples/jsm/libs/basis/basis_transcoder.js +19 -0
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/chevrotain.module.min.js +141 -0
- package/examples/jsm/libs/demuxer_mp4.js +109 -0
- package/examples/jsm/libs/draco/README.md +31 -0
- package/examples/jsm/libs/draco/draco_decoder.js +34 -0
- package/examples/jsm/libs/draco/draco_decoder.wasm +0 -0
- package/examples/jsm/libs/draco/draco_wasm_wrapper.js +117 -0
- package/examples/jsm/libs/draco/gltf/draco_decoder.js +33 -0
- package/examples/jsm/libs/draco/gltf/draco_decoder.wasm +0 -0
- package/examples/jsm/libs/draco/gltf/draco_wasm_wrapper.js +116 -0
- package/examples/jsm/libs/fflate.module.d.ts +1 -0
- package/examples/jsm/libs/fflate.module.js +2699 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -0
- package/examples/jsm/libs/lil-gui.module.min.d.ts +608 -0
- package/examples/jsm/libs/lil-gui.module.min.js +8 -0
- package/examples/jsm/libs/meshopt_clusterizer.module.js +421 -0
- package/examples/jsm/libs/meshopt_decoder.module.d.ts +1 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +196 -0
- package/examples/jsm/libs/meshopt_simplifier.module.js +627 -0
- package/examples/jsm/libs/mikktspace.README.md +27 -0
- package/examples/jsm/libs/mikktspace.module.d.ts +19 -0
- package/examples/jsm/libs/mikktspace.module.js +765 -0
- package/examples/jsm/libs/motion-controllers.module.js +397 -0
- package/examples/jsm/libs/potpack.module.js +125 -0
- package/examples/jsm/libs/stats.module.d.ts +3 -0
- package/examples/jsm/libs/stats.module.js +167 -0
- package/examples/jsm/libs/tween.module.d.ts +2 -0
- package/examples/jsm/libs/tween.module.js +876 -0
- package/examples/jsm/libs/utif.module.js +1665 -0
- package/examples/jsm/libs/zstddec.module.d.ts +5 -0
- package/examples/jsm/libs/zstddec.module.js +1 -0
- package/examples/jsm/lighting/ClusteredLighting.d.ts +45 -0
- package/examples/jsm/lighting/ClusteredLighting.js +153 -0
- package/examples/jsm/lighting/DynamicLighting.d.ts +16 -0
- package/examples/jsm/lighting/DynamicLighting.js +82 -0
- package/examples/jsm/lighting/LightMapper.js +295 -0
- package/examples/jsm/lighting/LightProbeGrid.d.ts +177 -0
- package/examples/jsm/lighting/LightProbeGrid.js +923 -0
- package/examples/jsm/lighting/LightProbeGridUtils.js +107 -0
- package/examples/jsm/lighting/LightProbeGridWebGL.d.ts +178 -0
- package/examples/jsm/lighting/LightProbeGridWebGL.js +846 -0
- package/examples/jsm/lighting/vxgi/VXGIConeTracer.js +243 -0
- package/examples/jsm/lighting/vxgi/VXGIIrradiance.js +43 -0
- package/examples/jsm/lighting/vxgi/VXGINode.d.ts +100 -0
- package/examples/jsm/lighting/vxgi/VXGINode.js +617 -0
- package/examples/jsm/lighting/vxgi/VXGISceneCollector.js +793 -0
- package/examples/jsm/lighting/vxgi/VXGIVolume.d.ts +245 -0
- package/examples/jsm/lighting/vxgi/VXGIVolume.js +1440 -0
- package/examples/jsm/lights/LightProbeGenerator.d.ts +16 -0
- package/examples/jsm/lights/LightProbeGenerator.js +337 -0
- package/examples/jsm/lights/RectAreaLightTexturesLib.d.ts +7 -0
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +127 -0
- package/examples/jsm/lights/RectAreaLightUniformsLib.d.ts +5 -0
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +40 -0
- package/examples/jsm/lights/SunLight.d.ts +53 -0
- package/examples/jsm/lights/SunLight.js +100 -0
- package/examples/jsm/lights/SunLightNode.d.ts +25 -0
- package/examples/jsm/lights/SunLightNode.js +56 -0
- package/examples/jsm/lights/SunLightShadow.d.ts +57 -0
- package/examples/jsm/lights/SunLightShadow.js +319 -0
- package/examples/jsm/lights/SunShadowNode.d.ts +53 -0
- package/examples/jsm/lights/SunShadowNode.js +312 -0
- package/examples/jsm/lines/Line2.d.ts +25 -0
- package/examples/jsm/lines/Line2.js +56 -0
- package/examples/jsm/lines/LineGeometry.d.ts +27 -0
- package/examples/jsm/lines/LineGeometry.js +157 -0
- package/examples/jsm/lines/LineMaterial.d.ts +82 -0
- package/examples/jsm/lines/LineMaterial.js +742 -0
- package/examples/jsm/lines/LineSegments2.d.ts +39 -0
- package/examples/jsm/lines/LineSegments2.js +434 -0
- package/examples/jsm/lines/LineSegmentsGeometry.d.ts +53 -0
- package/examples/jsm/lines/LineSegmentsGeometry.js +298 -0
- package/examples/jsm/lines/Wireframe.d.ts +14 -0
- package/examples/jsm/lines/Wireframe.js +108 -0
- package/examples/jsm/lines/WireframeGeometry2.d.ts +8 -0
- package/examples/jsm/lines/WireframeGeometry2.js +49 -0
- package/examples/jsm/lines/webgpu/Line2.d.ts +14 -0
- package/examples/jsm/lines/webgpu/Line2.js +46 -0
- package/examples/jsm/lines/webgpu/LineSegments2.d.ts +15 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +419 -0
- package/examples/jsm/lines/webgpu/Wireframe.d.ts +13 -0
- package/examples/jsm/lines/webgpu/Wireframe.js +86 -0
- package/examples/jsm/loaders/3DMLoader.d.ts +12 -0
- package/examples/jsm/loaders/3DMLoader.js +1946 -0
- package/examples/jsm/loaders/3MFLoader.d.ts +9 -0
- package/examples/jsm/loaders/3MFLoader.js +1826 -0
- package/examples/jsm/loaders/AMFLoader.d.ts +7 -0
- package/examples/jsm/loaders/AMFLoader.js +543 -0
- package/examples/jsm/loaders/BVHLoader.d.ts +14 -0
- package/examples/jsm/loaders/BVHLoader.js +486 -0
- package/examples/jsm/loaders/ColladaLoader.d.ts +35 -0
- package/examples/jsm/loaders/ColladaLoader.js +161 -0
- package/examples/jsm/loaders/DDSLoader.d.ts +22 -0
- package/examples/jsm/loaders/DDSLoader.js +385 -0
- package/examples/jsm/loaders/DRACOLoader.d.ts +39 -0
- package/examples/jsm/loaders/DRACOLoader.js +776 -0
- package/examples/jsm/loaders/EXRLoader.d.ts +24 -0
- package/examples/jsm/loaders/EXRLoader.js +3411 -0
- package/examples/jsm/loaders/FBXLoader.d.ts +8 -0
- package/examples/jsm/loaders/FBXLoader.js +4660 -0
- package/examples/jsm/loaders/FontLoader.d.ts +41 -0
- package/examples/jsm/loaders/FontLoader.js +262 -0
- package/examples/jsm/loaders/GCodeLoader.d.ts +8 -0
- package/examples/jsm/loaders/GCodeLoader.js +314 -0
- package/examples/jsm/loaders/GLTFGaussianSplatLoaderExtension.d.ts +14 -0
- package/examples/jsm/loaders/GLTFGaussianSplatLoaderExtension.js +330 -0
- package/examples/jsm/loaders/GLTFLoader.d.ts +153 -0
- package/examples/jsm/loaders/GLTFLoader.js +5006 -0
- package/examples/jsm/loaders/GaussianSplatPLYLoader.d.ts +9 -0
- package/examples/jsm/loaders/GaussianSplatPLYLoader.js +388 -0
- package/examples/jsm/loaders/HDRCubeTextureLoader.d.ts +18 -0
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +167 -0
- package/examples/jsm/loaders/HDRLoader.d.ts +12 -0
- package/examples/jsm/loaders/HDRLoader.js +463 -0
- package/examples/jsm/loaders/IESLoader.d.ts +5 -0
- package/examples/jsm/loaders/IESLoader.js +413 -0
- package/examples/jsm/loaders/JXLLoader.js +159 -0
- package/examples/jsm/loaders/KMZLoader.d.ts +9 -0
- package/examples/jsm/loaders/KMZLoader.js +169 -0
- package/examples/jsm/loaders/KSPLATLoader.d.ts +9 -0
- package/examples/jsm/loaders/KSPLATLoader.js +465 -0
- package/examples/jsm/loaders/KTX2Loader.d.ts +58 -0
- package/examples/jsm/loaders/KTX2Loader.js +1321 -0
- package/examples/jsm/loaders/KTXLoader.d.ts +22 -0
- package/examples/jsm/loaders/KTXLoader.js +199 -0
- package/examples/jsm/loaders/LDrawLoader.d.ts +38 -0
- package/examples/jsm/loaders/LDrawLoader.js +2503 -0
- package/examples/jsm/loaders/LUT3dlLoader.d.ts +39 -0
- package/examples/jsm/loaders/LUT3dlLoader.js +209 -0
- package/examples/jsm/loaders/LUTCubeLoader.d.ts +42 -0
- package/examples/jsm/loaders/LUTCubeLoader.js +194 -0
- package/examples/jsm/loaders/LUTImageLoader.d.ts +18 -0
- package/examples/jsm/loaders/LUTImageLoader.js +192 -0
- package/examples/jsm/loaders/LWOLoader.d.ts +25 -0
- package/examples/jsm/loaders/LWOLoader.js +1057 -0
- package/examples/jsm/loaders/MD2Loader.d.ts +7 -0
- package/examples/jsm/loaders/MD2Loader.js +437 -0
- package/examples/jsm/loaders/MDDLoader.d.ts +12 -0
- package/examples/jsm/loaders/MDDLoader.js +151 -0
- package/examples/jsm/loaders/MTLLoader.d.ts +95 -0
- package/examples/jsm/loaders/MTLLoader.js +601 -0
- package/examples/jsm/loaders/MaterialXLoader.d.ts +70 -0
- package/examples/jsm/loaders/MaterialXLoader.js +279 -0
- package/examples/jsm/loaders/NRRDLoader.d.ts +15 -0
- package/examples/jsm/loaders/NRRDLoader.js +720 -0
- package/examples/jsm/loaders/OBJLoader.d.ts +10 -0
- package/examples/jsm/loaders/OBJLoader.js +961 -0
- package/examples/jsm/loaders/PCDLoader.d.ts +8 -0
- package/examples/jsm/loaders/PCDLoader.js +624 -0
- package/examples/jsm/loaders/PDBLoader.d.ts +15 -0
- package/examples/jsm/loaders/PDBLoader.js +274 -0
- package/examples/jsm/loaders/PLYLoader.d.ts +11 -0
- package/examples/jsm/loaders/PLYLoader.js +992 -0
- package/examples/jsm/loaders/PVRLoader.d.ts +16 -0
- package/examples/jsm/loaders/PVRLoader.js +270 -0
- package/examples/jsm/loaders/RGBELoader.d.ts +7 -0
- package/examples/jsm/loaders/RGBELoader.js +18 -0
- package/examples/jsm/loaders/SPLATLoader.d.ts +9 -0
- package/examples/jsm/loaders/SPLATLoader.js +141 -0
- package/examples/jsm/loaders/SPZLoader.d.ts +18 -0
- package/examples/jsm/loaders/SPZLoader.js +563 -0
- package/examples/jsm/loaders/STLLoader.d.ts +7 -0
- package/examples/jsm/loaders/STLLoader.js +423 -0
- package/examples/jsm/loaders/SVGLoader.d.ts +67 -0
- package/examples/jsm/loaders/SVGLoader.js +3297 -0
- package/examples/jsm/loaders/TDSLoader.d.ts +35 -0
- package/examples/jsm/loaders/TDSLoader.js +1146 -0
- package/examples/jsm/loaders/TGALoader.d.ts +7 -0
- package/examples/jsm/loaders/TGALoader.js +539 -0
- package/examples/jsm/loaders/TIFFLoader.d.ts +7 -0
- package/examples/jsm/loaders/TIFFLoader.js +59 -0
- package/examples/jsm/loaders/TTFLoader.d.ts +10 -0
- package/examples/jsm/loaders/TTFLoader.js +263 -0
- package/examples/jsm/loaders/USDLoader.d.ts +14 -0
- package/examples/jsm/loaders/USDLoader.js +317 -0
- package/examples/jsm/loaders/USDZLoader.d.ts +14 -0
- package/examples/jsm/loaders/USDZLoader.js +16 -0
- package/examples/jsm/loaders/UltraHDRLoader.d.ts +28 -0
- package/examples/jsm/loaders/UltraHDRLoader.js +757 -0
- package/examples/jsm/loaders/VOXLoader.d.ts +38 -0
- package/examples/jsm/loaders/VOXLoader.js +922 -0
- package/examples/jsm/loaders/VRMLLoader.d.ts +7 -0
- package/examples/jsm/loaders/VRMLLoader.js +3650 -0
- package/examples/jsm/loaders/VTKLoader.d.ts +13 -0
- package/examples/jsm/loaders/VTKLoader.js +1295 -0
- package/examples/jsm/loaders/XYZLoader.d.ts +7 -0
- package/examples/jsm/loaders/XYZLoader.js +145 -0
- package/examples/jsm/loaders/collada/ColladaComposer.js +3051 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1977 -0
- package/examples/jsm/loaders/lwo/IFFParser.js +1217 -0
- package/examples/jsm/loaders/lwo/LWO2Parser.js +414 -0
- package/examples/jsm/loaders/lwo/LWO3Parser.js +373 -0
- package/examples/jsm/loaders/materialx/MaterialXArchive.js +108 -0
- package/examples/jsm/loaders/materialx/MaterialXDocument.js +1350 -0
- package/examples/jsm/loaders/materialx/MaterialXHextile.d.ts +24 -0
- package/examples/jsm/loaders/materialx/MaterialXHextile.js +183 -0
- package/examples/jsm/loaders/materialx/MaterialXInterfaceValidation.d.ts +8 -0
- package/examples/jsm/loaders/materialx/MaterialXInterfaceValidation.js +293 -0
- package/examples/jsm/loaders/materialx/MaterialXLog.d.ts +33 -0
- package/examples/jsm/loaders/materialx/MaterialXLog.js +79 -0
- package/examples/jsm/loaders/materialx/MaterialXNodeDefs.js +99 -0
- package/examples/jsm/loaders/materialx/MaterialXNodeInterfaceRegistry.js +763 -0
- package/examples/jsm/loaders/materialx/MaterialXNodeLibrary.js +871 -0
- package/examples/jsm/loaders/materialx/MaterialXSurfaceMappings.js +565 -0
- package/examples/jsm/loaders/materialx/MaterialXUtils.js +82 -0
- package/examples/jsm/loaders/materialx/compile/MaterialXCompileRegistry.js +999 -0
- package/examples/jsm/loaders/materialx/parse/MaterialXParser.js +28 -0
- package/examples/jsm/loaders/usd/USDAParser.js +923 -0
- package/examples/jsm/loaders/usd/USDCParser.js +1875 -0
- package/examples/jsm/loaders/usd/USDComposer.js +4660 -0
- package/examples/jsm/materials/LDrawConditionalLineMaterial.d.ts +9 -0
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +183 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.d.ts +9 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +154 -0
- package/examples/jsm/materials/WoodNodeMaterial.d.ts +75 -0
- package/examples/jsm/materials/WoodNodeMaterial.js +431 -0
- package/examples/jsm/math/Capsule.d.ts +26 -0
- package/examples/jsm/math/Capsule.js +159 -0
- package/examples/jsm/math/ColorConverter.d.ts +19 -0
- package/examples/jsm/math/ColorConverter.js +62 -0
- package/examples/jsm/math/ColorSpaces.d.ts +15 -0
- package/examples/jsm/math/ColorSpaces.js +147 -0
- package/examples/jsm/math/ConvexHull.d.ts +89 -0
- package/examples/jsm/math/ConvexHull.js +1695 -0
- package/examples/jsm/math/ImprovedNoise.d.ts +4 -0
- package/examples/jsm/math/ImprovedNoise.js +88 -0
- package/examples/jsm/math/Lut.d.ts +27 -0
- package/examples/jsm/math/Lut.js +317 -0
- package/examples/jsm/math/MeshSurfaceSampler.d.ts +21 -0
- package/examples/jsm/math/MeshSurfaceSampler.js +315 -0
- package/examples/jsm/math/OBB.d.ts +24 -0
- package/examples/jsm/math/OBB.js +535 -0
- package/examples/jsm/math/Octree.d.ts +54 -0
- package/examples/jsm/math/Octree.js +825 -0
- package/examples/jsm/math/SimplexNoise.d.ts +9 -0
- package/examples/jsm/math/SimplexNoise.js +470 -0
- package/examples/jsm/misc/ConvexObjectBreaker.d.ts +25 -0
- package/examples/jsm/misc/ConvexObjectBreaker.js +539 -0
- package/examples/jsm/misc/GPUComputationRenderer.d.ts +55 -0
- package/examples/jsm/misc/GPUComputationRenderer.js +508 -0
- package/examples/jsm/misc/Gyroscope.d.ts +5 -0
- package/examples/jsm/misc/Gyroscope.js +78 -0
- package/examples/jsm/misc/MD2Character.d.ts +33 -0
- package/examples/jsm/misc/MD2Character.js +391 -0
- package/examples/jsm/misc/MD2CharacterComplex.d.ts +55 -0
- package/examples/jsm/misc/MD2CharacterComplex.js +740 -0
- package/examples/jsm/misc/MorphAnimMesh.d.ts +13 -0
- package/examples/jsm/misc/MorphAnimMesh.js +119 -0
- package/examples/jsm/misc/MorphBlendMesh.d.ts +21 -0
- package/examples/jsm/misc/MorphBlendMesh.js +425 -0
- package/examples/jsm/misc/ProgressiveLightMap.d.ts +58 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +370 -0
- package/examples/jsm/misc/ProgressiveLightMapGPU.d.ts +27 -0
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +322 -0
- package/examples/jsm/misc/RollerCoaster.d.ts +26 -0
- package/examples/jsm/misc/RollerCoaster.js +661 -0
- package/examples/jsm/misc/SculptGL.LICENSE.txt +21 -0
- package/examples/jsm/misc/Sculptor.d.ts +259 -0
- package/examples/jsm/misc/Sculptor.js +1679 -0
- package/examples/jsm/misc/SculptorMesh.js +1504 -0
- package/examples/jsm/misc/SculptorTools.js +1180 -0
- package/examples/jsm/misc/SculptorUtils.js +345 -0
- package/examples/jsm/misc/TileCreasedNormalsPlugin.d.ts +49 -0
- package/examples/jsm/misc/TileCreasedNormalsPlugin.js +270 -0
- package/examples/jsm/misc/TubePainter.d.ts +10 -0
- package/examples/jsm/misc/TubePainter.js +611 -0
- package/examples/jsm/misc/Volume.d.ts +37 -0
- package/examples/jsm/misc/Volume.js +520 -0
- package/examples/jsm/misc/VolumeSlice.d.ts +28 -0
- package/examples/jsm/misc/VolumeSlice.js +275 -0
- package/examples/jsm/modifiers/CurveModifier.d.ts +41 -0
- package/examples/jsm/modifiers/CurveModifier.js +374 -0
- package/examples/jsm/modifiers/CurveModifierGPU.d.ts +31 -0
- package/examples/jsm/modifiers/CurveModifierGPU.js +256 -0
- package/examples/jsm/modifiers/EdgeSplitModifier.d.ts +26 -0
- package/examples/jsm/modifiers/EdgeSplitModifier.js +299 -0
- package/examples/jsm/modifiers/SimplifyModifier.d.ts +6 -0
- package/examples/jsm/modifiers/SimplifyModifier.js +139 -0
- package/examples/jsm/modifiers/TessellateModifier.d.ts +9 -0
- package/examples/jsm/modifiers/TessellateModifier.js +340 -0
- package/examples/jsm/objects/GaussianSplat.d.ts +35 -0
- package/examples/jsm/objects/GaussianSplat.js +1040 -0
- package/examples/jsm/objects/GroundedSkybox.d.ts +5 -0
- package/examples/jsm/objects/GroundedSkybox.js +69 -0
- package/examples/jsm/objects/Lensflare.d.ts +21 -0
- package/examples/jsm/objects/Lensflare.js +489 -0
- package/examples/jsm/objects/LensflareMesh.d.ts +21 -0
- package/examples/jsm/objects/LensflareMesh.js +376 -0
- package/examples/jsm/objects/MarchingCubes.d.ts +76 -0
- package/examples/jsm/objects/MarchingCubes.js +1261 -0
- package/examples/jsm/objects/Reflector.d.ts +54 -0
- package/examples/jsm/objects/Reflector.js +390 -0
- package/examples/jsm/objects/ReflectorForSSRPass.d.ts +62 -0
- package/examples/jsm/objects/ReflectorForSSRPass.js +393 -0
- package/examples/jsm/objects/Refractor.d.ts +21 -0
- package/examples/jsm/objects/Refractor.js +389 -0
- package/examples/jsm/objects/ShadowMesh.d.ts +10 -0
- package/examples/jsm/objects/ShadowMesh.js +130 -0
- package/examples/jsm/objects/Sky.d.ts +28 -0
- package/examples/jsm/objects/Sky.js +342 -0
- package/examples/jsm/objects/SkyMesh.d.ts +26 -0
- package/examples/jsm/objects/SkyMesh.js +403 -0
- package/examples/jsm/objects/Water.d.ts +22 -0
- package/examples/jsm/objects/Water.js +374 -0
- package/examples/jsm/objects/Water2.d.ts +21 -0
- package/examples/jsm/objects/Water2.js +403 -0
- package/examples/jsm/objects/Water2Mesh.d.ts +53 -0
- package/examples/jsm/objects/Water2Mesh.js +199 -0
- package/examples/jsm/objects/WaterMesh.d.ts +40 -0
- package/examples/jsm/objects/WaterMesh.js +194 -0
- package/examples/jsm/offscreen/jank.js +45 -0
- package/examples/jsm/offscreen/offscreen.js +8 -0
- package/examples/jsm/offscreen/scene.js +86 -0
- package/examples/jsm/physics/AmmoPhysics.d.ts +9 -0
- package/examples/jsm/physics/AmmoPhysics.js +366 -0
- package/examples/jsm/physics/JoltPhysics.d.ts +10 -0
- package/examples/jsm/physics/JoltPhysics.js +334 -0
- package/examples/jsm/physics/RapierPhysics.d.ts +26 -0
- package/examples/jsm/physics/RapierPhysics.js +461 -0
- package/examples/jsm/pipelines/MeshletDrawingPipeline.js +5571 -0
- package/examples/jsm/pipelines/VisibilityBufferDrawingPipeline.js +954 -0
- package/examples/jsm/postprocessing/AfterimagePass.d.ts +17 -0
- package/examples/jsm/postprocessing/AfterimagePass.js +187 -0
- package/examples/jsm/postprocessing/BloomPass.d.ts +14 -0
- package/examples/jsm/postprocessing/BloomPass.js +274 -0
- package/examples/jsm/postprocessing/BokehPass.d.ts +23 -0
- package/examples/jsm/postprocessing/BokehPass.js +218 -0
- package/examples/jsm/postprocessing/ClearPass.d.ts +9 -0
- package/examples/jsm/postprocessing/ClearPass.js +97 -0
- package/examples/jsm/postprocessing/CubeTexturePass.d.ts +14 -0
- package/examples/jsm/postprocessing/CubeTexturePass.js +146 -0
- package/examples/jsm/postprocessing/DotScreenPass.d.ts +10 -0
- package/examples/jsm/postprocessing/DotScreenPass.js +114 -0
- package/examples/jsm/postprocessing/EffectComposer.d.ts +30 -0
- package/examples/jsm/postprocessing/EffectComposer.js +365 -0
- package/examples/jsm/postprocessing/FXAAPass.d.ts +7 -0
- package/examples/jsm/postprocessing/FXAAPass.js +40 -0
- package/examples/jsm/postprocessing/FilmPass.d.ts +10 -0
- package/examples/jsm/postprocessing/FilmPass.js +113 -0
- package/examples/jsm/postprocessing/GTAOPass.d.ts +121 -0
- package/examples/jsm/postprocessing/GTAOPass.js +735 -0
- package/examples/jsm/postprocessing/GlitchPass.d.ts +16 -0
- package/examples/jsm/postprocessing/GlitchPass.js +177 -0
- package/examples/jsm/postprocessing/HalftonePass.d.ts +37 -0
- package/examples/jsm/postprocessing/HalftonePass.js +134 -0
- package/examples/jsm/postprocessing/LUTPass.d.ts +13 -0
- package/examples/jsm/postprocessing/LUTPass.js +138 -0
- package/examples/jsm/postprocessing/MaskPass.d.ts +14 -0
- package/examples/jsm/postprocessing/MaskPass.js +195 -0
- package/examples/jsm/postprocessing/OutlinePass.d.ts +64 -0
- package/examples/jsm/postprocessing/OutlinePass.js +776 -0
- package/examples/jsm/postprocessing/OutputPass.d.ts +14 -0
- package/examples/jsm/postprocessing/OutputPass.js +148 -0
- package/examples/jsm/postprocessing/Pass.d.ts +31 -0
- package/examples/jsm/postprocessing/Pass.js +191 -0
- package/examples/jsm/postprocessing/RenderPass.d.ts +28 -0
- package/examples/jsm/postprocessing/RenderPass.js +193 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.d.ts +30 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +314 -0
- package/examples/jsm/postprocessing/RenderTransitionPass.d.ts +33 -0
- package/examples/jsm/postprocessing/RenderTransitionPass.js +267 -0
- package/examples/jsm/postprocessing/SAOPass.d.ts +70 -0
- package/examples/jsm/postprocessing/SAOPass.js +407 -0
- package/examples/jsm/postprocessing/SMAAPass.d.ts +21 -0
- package/examples/jsm/postprocessing/SMAAPass.js +230 -0
- package/examples/jsm/postprocessing/SSAARenderPass.d.ts +26 -0
- package/examples/jsm/postprocessing/SSAARenderPass.js +313 -0
- package/examples/jsm/postprocessing/SSAOPass.d.ts +68 -0
- package/examples/jsm/postprocessing/SSAOPass.js +527 -0
- package/examples/jsm/postprocessing/SSRPass.d.ts +99 -0
- package/examples/jsm/postprocessing/SSRPass.js +858 -0
- package/examples/jsm/postprocessing/SavePass.d.ts +12 -0
- package/examples/jsm/postprocessing/SavePass.js +132 -0
- package/examples/jsm/postprocessing/ShaderPass.d.ts +11 -0
- package/examples/jsm/postprocessing/ShaderPass.js +135 -0
- package/examples/jsm/postprocessing/TAARenderPass.d.ts +8 -0
- package/examples/jsm/postprocessing/TAARenderPass.js +243 -0
- package/examples/jsm/postprocessing/TexturePass.d.ts +12 -0
- package/examples/jsm/postprocessing/TexturePass.js +131 -0
- package/examples/jsm/postprocessing/UnrealBloomPass.d.ts +26 -0
- package/examples/jsm/postprocessing/UnrealBloomPass.js +541 -0
- package/examples/jsm/renderers/CSS2DRenderer.d.ts +29 -0
- package/examples/jsm/renderers/CSS2DRenderer.js +352 -0
- package/examples/jsm/renderers/CSS3DRenderer.d.ts +26 -0
- package/examples/jsm/renderers/CSS3DRenderer.js +454 -0
- package/examples/jsm/renderers/Projector.d.ts +60 -0
- package/examples/jsm/renderers/Projector.js +1154 -0
- package/examples/jsm/renderers/SVGRenderer.d.ts +26 -0
- package/examples/jsm/renderers/SVGRenderer.js +800 -0
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.d.ts +11 -0
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +96 -0
- package/examples/jsm/shaders/AfterimageShader.d.ts +12 -0
- package/examples/jsm/shaders/AfterimageShader.js +63 -0
- package/examples/jsm/shaders/BasicShader.d.ts +6 -0
- package/examples/jsm/shaders/BasicShader.js +36 -0
- package/examples/jsm/shaders/BleachBypassShader.d.ts +10 -0
- package/examples/jsm/shaders/BleachBypassShader.js +68 -0
- package/examples/jsm/shaders/BlendShader.d.ts +13 -0
- package/examples/jsm/shaders/BlendShader.js +56 -0
- package/examples/jsm/shaders/BokehShader.d.ts +21 -0
- package/examples/jsm/shaders/BokehShader.js +151 -0
- package/examples/jsm/shaders/BokehShader2.d.ts +44 -0
- package/examples/jsm/shaders/BokehShader2.js +404 -0
- package/examples/jsm/shaders/BrightnessContrastShader.d.ts +12 -0
- package/examples/jsm/shaders/BrightnessContrastShader.js +62 -0
- package/examples/jsm/shaders/ColorCorrectionShader.d.ts +13 -0
- package/examples/jsm/shaders/ColorCorrectionShader.js +59 -0
- package/examples/jsm/shaders/ColorifyShader.d.ts +10 -0
- package/examples/jsm/shaders/ColorifyShader.js +57 -0
- package/examples/jsm/shaders/ConvolutionShader.d.ts +17 -0
- package/examples/jsm/shaders/ConvolutionShader.js +74 -0
- package/examples/jsm/shaders/CopyShader.d.ts +10 -0
- package/examples/jsm/shaders/CopyShader.js +52 -0
- package/examples/jsm/shaders/DOFMipMapShader.d.ts +13 -0
- package/examples/jsm/shaders/DOFMipMapShader.js +63 -0
- package/examples/jsm/shaders/DepthLimitedBlurShader.d.ts +28 -0
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +183 -0
- package/examples/jsm/shaders/DigitalGlitch.d.ts +19 -0
- package/examples/jsm/shaders/DigitalGlitch.js +104 -0
- package/examples/jsm/shaders/DotScreenShader.d.ts +13 -0
- package/examples/jsm/shaders/DotScreenShader.js +75 -0
- package/examples/jsm/shaders/ExposureShader.d.ts +11 -0
- package/examples/jsm/shaders/ExposureShader.js +51 -0
- package/examples/jsm/shaders/FXAAShader.d.ts +11 -0
- package/examples/jsm/shaders/FXAAShader.js +298 -0
- package/examples/jsm/shaders/FilmShader.d.ts +12 -0
- package/examples/jsm/shaders/FilmShader.js +73 -0
- package/examples/jsm/shaders/FocusShader.d.ts +14 -0
- package/examples/jsm/shaders/FocusShader.js +94 -0
- package/examples/jsm/shaders/FreiChenShader.d.ts +11 -0
- package/examples/jsm/shaders/FreiChenShader.js +103 -0
- package/examples/jsm/shaders/GTAOShader.d.ts +59 -0
- package/examples/jsm/shaders/GTAOShader.js +437 -0
- package/examples/jsm/shaders/GammaCorrectionShader.d.ts +9 -0
- package/examples/jsm/shaders/GammaCorrectionShader.js +52 -0
- package/examples/jsm/shaders/HalftoneShader.d.ts +22 -0
- package/examples/jsm/shaders/HalftoneShader.js +332 -0
- package/examples/jsm/shaders/HorizontalBlurShader.d.ts +10 -0
- package/examples/jsm/shaders/HorizontalBlurShader.js +68 -0
- package/examples/jsm/shaders/HorizontalTiltShiftShader.d.ts +12 -0
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +70 -0
- package/examples/jsm/shaders/HueSaturationShader.d.ts +12 -0
- package/examples/jsm/shaders/HueSaturationShader.js +74 -0
- package/examples/jsm/shaders/KaleidoShader.d.ts +12 -0
- package/examples/jsm/shaders/KaleidoShader.js +65 -0
- package/examples/jsm/shaders/LuminosityHighPassShader.d.ts +15 -0
- package/examples/jsm/shaders/LuminosityHighPassShader.js +68 -0
- package/examples/jsm/shaders/LuminosityShader.d.ts +10 -0
- package/examples/jsm/shaders/LuminosityShader.js +54 -0
- package/examples/jsm/shaders/MirrorShader.d.ts +11 -0
- package/examples/jsm/shaders/MirrorShader.js +62 -0
- package/examples/jsm/shaders/NormalMapShader.d.ts +13 -0
- package/examples/jsm/shaders/NormalMapShader.js +60 -0
- package/examples/jsm/shaders/OutputShader.d.ts +11 -0
- package/examples/jsm/shaders/OutputShader.js +103 -0
- package/examples/jsm/shaders/PoissonDenoiseShader.d.ts +28 -0
- package/examples/jsm/shaders/PoissonDenoiseShader.js +230 -0
- package/examples/jsm/shaders/RGBShiftShader.d.ts +11 -0
- package/examples/jsm/shaders/RGBShiftShader.js +61 -0
- package/examples/jsm/shaders/SAOShader.d.ts +29 -0
- package/examples/jsm/shaders/SAOShader.js +201 -0
- package/examples/jsm/shaders/SMAAShader.d.ts +43 -0
- package/examples/jsm/shaders/SMAAShader.js +489 -0
- package/examples/jsm/shaders/SSAOShader.d.ts +49 -0
- package/examples/jsm/shaders/SSAOShader.js +331 -0
- package/examples/jsm/shaders/SSRShader.d.ts +62 -0
- package/examples/jsm/shaders/SSRShader.js +396 -0
- package/examples/jsm/shaders/SepiaShader.d.ts +10 -0
- package/examples/jsm/shaders/SepiaShader.js +57 -0
- package/examples/jsm/shaders/SobelOperatorShader.d.ts +11 -0
- package/examples/jsm/shaders/SobelOperatorShader.js +98 -0
- package/examples/jsm/shaders/SubsurfaceScatteringShader.d.ts +38 -0
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +95 -0
- package/examples/jsm/shaders/TechnicolorShader.d.ts +10 -0
- package/examples/jsm/shaders/TechnicolorShader.js +51 -0
- package/examples/jsm/shaders/ToonShader.d.ts +54 -0
- package/examples/jsm/shaders/ToonShader.js +349 -0
- package/examples/jsm/shaders/TriangleBlurShader.d.ts +11 -0
- package/examples/jsm/shaders/TriangleBlurShader.js +79 -0
- package/examples/jsm/shaders/UnpackDepthRGBAShader.d.ts +11 -0
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +60 -0
- package/examples/jsm/shaders/VelocityShader.d.ts +16 -0
- package/examples/jsm/shaders/VelocityShader.js +137 -0
- package/examples/jsm/shaders/VerticalBlurShader.d.ts +10 -0
- package/examples/jsm/shaders/VerticalBlurShader.js +66 -0
- package/examples/jsm/shaders/VerticalTiltShiftShader.d.ts +12 -0
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +70 -0
- package/examples/jsm/shaders/VignetteShader.d.ts +11 -0
- package/examples/jsm/shaders/VignetteShader.js +56 -0
- package/examples/jsm/shaders/VolumeShader.d.ts +14 -0
- package/examples/jsm/shaders/VolumeShader.js +285 -0
- package/examples/jsm/shaders/WaterRefractionShader.d.ts +14 -0
- package/examples/jsm/shaders/WaterRefractionShader.js +106 -0
- package/examples/jsm/textures/FlakesTexture.d.ts +3 -0
- package/examples/jsm/textures/FlakesTexture.js +54 -0
- package/examples/jsm/transpiler/AST.d.ts +293 -0
- package/examples/jsm/transpiler/AST.js +694 -0
- package/examples/jsm/transpiler/GLSLDecoder.d.ts +7 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +1718 -0
- package/examples/jsm/transpiler/Linker.js +327 -0
- package/examples/jsm/transpiler/ShaderToyDecoder.d.ts +3 -0
- package/examples/jsm/transpiler/ShaderToyDecoder.js +51 -0
- package/examples/jsm/transpiler/TSLEncoder.d.ts +51 -0
- package/examples/jsm/transpiler/TSLEncoder.js +1055 -0
- package/examples/jsm/transpiler/Transpiler.d.ts +5 -0
- package/examples/jsm/transpiler/Transpiler.js +67 -0
- package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
- package/examples/jsm/transpiler/WGSLEncoder.js +868 -0
- package/examples/jsm/tsl/WebGLNodesHandler.d.ts +17 -0
- package/examples/jsm/tsl/WebGLNodesHandler.js +607 -0
- package/examples/jsm/tsl/display/AfterImageNode.d.ts +15 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +256 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.d.ts +42 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +550 -0
- package/examples/jsm/tsl/display/BilateralBlurNode.d.ts +27 -0
- package/examples/jsm/tsl/display/BilateralBlurNode.js +377 -0
- package/examples/jsm/tsl/display/BleachBypass.d.ts +3 -0
- package/examples/jsm/tsl/display/BleachBypass.js +33 -0
- package/examples/jsm/tsl/display/BloomNode.d.ts +44 -0
- package/examples/jsm/tsl/display/BloomNode.js +599 -0
- package/examples/jsm/tsl/display/CRT.d.ts +22 -0
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/ChromaticAberrationNode.d.ts +19 -0
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +163 -0
- package/examples/jsm/tsl/display/DenoiseNode.d.ts +26 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +354 -0
- package/examples/jsm/tsl/display/DepthOfFieldNode.d.ts +28 -0
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +572 -0
- package/examples/jsm/tsl/display/DotScreenNode.d.ts +17 -0
- package/examples/jsm/tsl/display/DotScreenNode.js +104 -0
- package/examples/jsm/tsl/display/FSR1Node.d.ts +17 -0
- package/examples/jsm/tsl/display/FSR1Node.js +481 -0
- package/examples/jsm/tsl/display/FXAANode.d.ts +11 -0
- package/examples/jsm/tsl/display/FXAANode.js +357 -0
- package/examples/jsm/tsl/display/FilmNode.d.ts +17 -0
- package/examples/jsm/tsl/display/FilmNode.js +101 -0
- package/examples/jsm/tsl/display/GTAONode.d.ts +37 -0
- package/examples/jsm/tsl/display/GTAONode.js +727 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.d.ts +56 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +412 -0
- package/examples/jsm/tsl/display/GodraysNode.d.ts +20 -0
- package/examples/jsm/tsl/display/GodraysNode.js +604 -0
- package/examples/jsm/tsl/display/ImportanceSampledEnvironment.d.ts +84 -0
- package/examples/jsm/tsl/display/ImportanceSampledEnvironment.js +564 -0
- package/examples/jsm/tsl/display/LensflareNode.d.ts +34 -0
- package/examples/jsm/tsl/display/LensflareNode.js +282 -0
- package/examples/jsm/tsl/display/Lut3DNode.d.ts +19 -0
- package/examples/jsm/tsl/display/Lut3DNode.js +109 -0
- package/examples/jsm/tsl/display/MotionBlur.d.ts +7 -0
- package/examples/jsm/tsl/display/MotionBlur.js +33 -0
- package/examples/jsm/tsl/display/OITPassNode.d.ts +64 -0
- package/examples/jsm/tsl/display/OITPassNode.js +341 -0
- package/examples/jsm/tsl/display/OutlineNode.d.ts +31 -0
- package/examples/jsm/tsl/display/OutlineNode.js +916 -0
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.d.ts +12 -0
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +90 -0
- package/examples/jsm/tsl/display/PixelationPassNode.d.ts +27 -0
- package/examples/jsm/tsl/display/PixelationPassNode.js +227 -0
- package/examples/jsm/tsl/display/RGBShiftNode.d.ts +15 -0
- package/examples/jsm/tsl/display/RGBShiftNode.js +96 -0
- package/examples/jsm/tsl/display/RecurrentDenoiseNode.d.ts +89 -0
- package/examples/jsm/tsl/display/RecurrentDenoiseNode.js +812 -0
- package/examples/jsm/tsl/display/RetroPassNode.d.ts +17 -0
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.d.ts +17 -0
- package/examples/jsm/tsl/display/SMAANode.js +729 -0
- package/examples/jsm/tsl/display/SSAAPassNode.d.ts +18 -0
- package/examples/jsm/tsl/display/SSAAPassNode.js +344 -0
- package/examples/jsm/tsl/display/SSAONode.d.ts +116 -0
- package/examples/jsm/tsl/display/SSAONode.js +422 -0
- package/examples/jsm/tsl/display/SSGINode.d.ts +33 -0
- package/examples/jsm/tsl/display/SSGINode.js +698 -0
- package/examples/jsm/tsl/display/SSRNode.d.ts +315 -0
- package/examples/jsm/tsl/display/SSRNode.js +1430 -0
- package/examples/jsm/tsl/display/SSSNode.d.ts +20 -0
- package/examples/jsm/tsl/display/SSSNode.js +479 -0
- package/examples/jsm/tsl/display/Sepia.d.ts +3 -0
- package/examples/jsm/tsl/display/Sepia.js +24 -0
- package/examples/jsm/tsl/display/Shape.d.ts +3 -0
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/examples/jsm/tsl/display/SharpenNode.d.ts +22 -0
- package/examples/jsm/tsl/display/SharpenNode.js +284 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.d.ts +11 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +168 -0
- package/examples/jsm/tsl/display/StereoCompositePassNode.d.ts +13 -0
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +190 -0
- package/examples/jsm/tsl/display/StereoPassNode.d.ts +13 -0
- package/examples/jsm/tsl/display/StereoPassNode.js +117 -0
- package/examples/jsm/tsl/display/TAAUNode.d.ts +31 -0
- package/examples/jsm/tsl/display/TAAUNode.js +700 -0
- package/examples/jsm/tsl/display/TRAANode.d.ts +26 -0
- package/examples/jsm/tsl/display/TRAANode.js +609 -0
- package/examples/jsm/tsl/display/TemporalReprojectNode.d.ts +64 -0
- package/examples/jsm/tsl/display/TemporalReprojectNode.js +1024 -0
- package/examples/jsm/tsl/display/TransitionNode.d.ts +31 -0
- package/examples/jsm/tsl/display/TransitionNode.js +141 -0
- package/examples/jsm/tsl/display/boxBlur.d.ts +10 -0
- package/examples/jsm/tsl/display/boxBlur.js +65 -0
- package/examples/jsm/tsl/display/depthAwareBlend.d.ts +15 -0
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/display/depthAwareBlur.d.ts +10 -0
- package/examples/jsm/tsl/display/depthAwareBlur.js +63 -0
- package/examples/jsm/tsl/display/hashBlur.d.ts +12 -0
- package/examples/jsm/tsl/display/hashBlur.js +55 -0
- package/examples/jsm/tsl/display/lensDirt.js +30 -0
- package/examples/jsm/tsl/display/radialBlur.d.ts +12 -0
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/tsl/lighting/ClusteredLightsNode.d.ts +54 -0
- package/examples/jsm/tsl/lighting/ClusteredLightsNode.js +994 -0
- package/examples/jsm/tsl/lighting/DynamicLightsNode.d.ts +21 -0
- package/examples/jsm/tsl/lighting/DynamicLightsNode.js +201 -0
- package/examples/jsm/tsl/lighting/LightProbeGridNode.js +183 -0
- package/examples/jsm/tsl/lighting/data/AmbientLightDataNode.d.ts +9 -0
- package/examples/jsm/tsl/lighting/data/AmbientLightDataNode.js +67 -0
- package/examples/jsm/tsl/lighting/data/DirectionalLightDataNode.d.ts +9 -0
- package/examples/jsm/tsl/lighting/data/DirectionalLightDataNode.js +117 -0
- package/examples/jsm/tsl/lighting/data/HemisphereLightDataNode.d.ts +9 -0
- package/examples/jsm/tsl/lighting/data/HemisphereLightDataNode.js +105 -0
- package/examples/jsm/tsl/lighting/data/PointLightDataNode.d.ts +9 -0
- package/examples/jsm/tsl/lighting/data/PointLightDataNode.js +140 -0
- package/examples/jsm/tsl/lighting/data/SpotLightDataNode.d.ts +9 -0
- package/examples/jsm/tsl/lighting/data/SpotLightDataNode.js +167 -0
- package/examples/jsm/tsl/math/Bayer.d.ts +5 -0
- package/examples/jsm/tsl/math/Bayer.js +84 -0
- package/examples/jsm/tsl/math/curlNoise.d.ts +38 -0
- package/examples/jsm/tsl/math/curlNoise.js +107 -0
- package/examples/jsm/tsl/math/voronoiNoise.d.ts +52 -0
- package/examples/jsm/tsl/math/voronoiNoise.js +112 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.d.ts +14 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.js +542 -0
- package/examples/jsm/tsl/shadows/TileShadowNodeHelper.d.ts +14 -0
- package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +212 -0
- package/examples/jsm/tsl/utils/GroundedSkybox.d.ts +17 -0
- package/examples/jsm/tsl/utils/GroundedSkybox.js +62 -0
- package/examples/jsm/tsl/utils/RNoise.d.ts +12 -0
- package/examples/jsm/tsl/utils/RNoise.js +51 -0
- package/examples/jsm/tsl/utils/Raymarching.d.ts +8 -0
- package/examples/jsm/tsl/utils/Raymarching.js +70 -0
- package/examples/jsm/tsl/utils/SoftParticles.d.ts +21 -0
- package/examples/jsm/tsl/utils/SoftParticles.js +53 -0
- package/examples/jsm/tsl/utils/SpecularHelpers.d.ts +20 -0
- package/examples/jsm/tsl/utils/SpecularHelpers.js +302 -0
- package/examples/jsm/tsl/utils/TAAUtils.js +184 -0
- package/examples/jsm/utils/BufferGeometryUtils.d.ts +37 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +1523 -0
- package/examples/jsm/utils/CameraUtils.d.ts +9 -0
- package/examples/jsm/utils/CameraUtils.js +82 -0
- package/examples/jsm/utils/ColorUtils.d.ts +5 -0
- package/examples/jsm/utils/ColorUtils.js +76 -0
- package/examples/jsm/utils/GaussianSplatUtils.d.ts +68 -0
- package/examples/jsm/utils/GaussianSplatUtils.js +229 -0
- package/examples/jsm/utils/GeometryCompressionUtils.d.ts +21 -0
- package/examples/jsm/utils/GeometryCompressionUtils.js +547 -0
- package/examples/jsm/utils/GeometryUtils.d.ts +25 -0
- package/examples/jsm/utils/GeometryUtils.js +226 -0
- package/examples/jsm/utils/LDrawUtils.d.ts +5 -0
- package/examples/jsm/utils/LDrawUtils.js +211 -0
- package/examples/jsm/utils/MeshletGeometryUtils.js +417 -0
- package/examples/jsm/utils/SceneOptimizer.d.ts +18 -0
- package/examples/jsm/utils/SceneOptimizer.js +459 -0
- package/examples/jsm/utils/SceneUtils.d.ts +57 -0
- package/examples/jsm/utils/SceneUtils.js +363 -0
- package/examples/jsm/utils/ShadowMapViewer.d.ts +26 -0
- package/examples/jsm/utils/ShadowMapViewer.js +244 -0
- package/examples/jsm/utils/ShadowMapViewerGPU.d.ts +26 -0
- package/examples/jsm/utils/ShadowMapViewerGPU.js +233 -0
- package/examples/jsm/utils/SkeletonUtils.d.ts +32 -0
- package/examples/jsm/utils/SkeletonUtils.js +496 -0
- package/examples/jsm/utils/SortUtils.d.ts +7 -0
- package/examples/jsm/utils/SortUtils.js +175 -0
- package/examples/jsm/utils/UVsDebug.d.ts +3 -0
- package/examples/jsm/utils/UVsDebug.js +173 -0
- package/examples/jsm/utils/WebGLTextureUtils.d.ts +3 -0
- package/examples/jsm/utils/WebGLTextureUtils.js +115 -0
- package/examples/jsm/utils/WebGPUTextureUtils.d.ts +3 -0
- package/examples/jsm/utils/WebGPUTextureUtils.js +81 -0
- package/examples/jsm/utils/WorkerPool.d.ts +26 -0
- package/examples/jsm/utils/WorkerPool.js +167 -0
- package/examples/jsm/utils/unwrapUVs.js +865 -0
- package/examples/jsm/webxr/ARButton.d.ts +9 -0
- package/examples/jsm/webxr/ARButton.js +251 -0
- package/examples/jsm/webxr/OculusHandModel.d.ts +23 -0
- package/examples/jsm/webxr/OculusHandModel.js +194 -0
- package/examples/jsm/webxr/OculusHandPointerModel.d.ts +67 -0
- package/examples/jsm/webxr/OculusHandPointerModel.js +539 -0
- package/examples/jsm/webxr/Text2D.d.ts +3 -0
- package/examples/jsm/webxr/Text2D.js +52 -0
- package/examples/jsm/webxr/VRButton.d.ts +7 -0
- package/examples/jsm/webxr/VRButton.js +264 -0
- package/examples/jsm/webxr/WebGLXRFallback.d.ts +14 -0
- package/examples/jsm/webxr/WebGLXRFallback.js +75 -0
- package/examples/jsm/webxr/XRButton.d.ts +7 -0
- package/examples/jsm/webxr/XRButton.js +246 -0
- package/examples/jsm/webxr/XRControllerModelFactory.d.ts +23 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +415 -0
- package/examples/jsm/webxr/XREstimatedLight.d.ts +69 -0
- package/examples/jsm/webxr/XREstimatedLight.js +261 -0
- package/examples/jsm/webxr/XRHandMeshModel.d.ts +20 -0
- package/examples/jsm/webxr/XRHandMeshModel.js +177 -0
- package/examples/jsm/webxr/XRHandModelFactory.d.ts +32 -0
- package/examples/jsm/webxr/XRHandModelFactory.js +198 -0
- package/examples/jsm/webxr/XRHandPrimitiveModel.d.ts +24 -0
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +147 -0
- package/examples/jsm/webxr/XRPlanes.d.ts +5 -0
- package/examples/jsm/webxr/XRPlanes.js +118 -0
- package/index.d.ts +6 -0
- package/package.json +68 -4
- package/src/Three.Core.d.ts +176 -0
- package/src/Three.Core.js +189 -0
- package/src/Three.Legacy.js +0 -0
- package/src/Three.TSL.d.ts +686 -0
- package/src/Three.TSL.js +3 -0
- package/src/Three.WebGPU.Nodes.d.ts +36 -0
- package/src/Three.WebGPU.Nodes.js +34 -0
- package/src/Three.WebGPU.d.ts +44 -0
- package/src/Three.WebGPU.js +44 -0
- package/src/Three.d.ts +47 -0
- package/src/Three.js +10 -0
- package/src/animation/AnimationAction.d.ts +286 -0
- package/src/animation/AnimationAction.js +946 -0
- package/src/animation/AnimationClip.d.ts +168 -0
- package/src/animation/AnimationClip.js +502 -0
- package/src/animation/AnimationMixer.d.ts +175 -0
- package/src/animation/AnimationMixer.js +860 -0
- package/src/animation/AnimationObjectGroup.d.ts +58 -0
- package/src/animation/AnimationObjectGroup.js +423 -0
- package/src/animation/AnimationUtils.d.ts +182 -0
- package/src/animation/AnimationUtils.js +519 -0
- package/src/animation/KeyframeTrack.d.ts +197 -0
- package/src/animation/KeyframeTrack.js +692 -0
- package/src/animation/PropertyBinding.d.ts +101 -0
- package/src/animation/PropertyBinding.js +794 -0
- package/src/animation/PropertyMixer.d.ts +75 -0
- package/src/animation/PropertyMixer.js +385 -0
- package/src/animation/tracks/BooleanKeyframeTrack.d.ts +18 -0
- package/src/animation/tracks/BooleanKeyframeTrack.js +55 -0
- package/src/animation/tracks/ColorKeyframeTrack.d.ts +17 -0
- package/src/animation/tracks/ColorKeyframeTrack.js +36 -0
- package/src/animation/tracks/NumberKeyframeTrack.d.ts +17 -0
- package/src/animation/tracks/NumberKeyframeTrack.js +36 -0
- package/src/animation/tracks/QuaternionKeyframeTrack.d.ts +17 -0
- package/src/animation/tracks/QuaternionKeyframeTrack.js +51 -0
- package/src/animation/tracks/StringKeyframeTrack.d.ts +18 -0
- package/src/animation/tracks/StringKeyframeTrack.js +55 -0
- package/src/animation/tracks/VectorKeyframeTrack.d.ts +17 -0
- package/src/animation/tracks/VectorKeyframeTrack.js +36 -0
- package/src/audio/Audio.d.ts +340 -0
- package/src/audio/Audio.js +778 -0
- package/src/audio/AudioAnalyser.d.ts +63 -0
- package/src/audio/AudioAnalyser.js +97 -0
- package/src/audio/AudioContext.d.ts +19 -0
- package/src/audio/AudioContext.js +40 -0
- package/src/audio/AudioListener.d.ts +75 -0
- package/src/audio/AudioListener.js +218 -0
- package/src/audio/PositionalAudio.d.ts +108 -0
- package/src/audio/PositionalAudio.js +253 -0
- package/src/cameras/ArrayCamera.d.ts +35 -0
- package/src/cameras/ArrayCamera.js +66 -0
- package/src/cameras/Camera.d.ts +42 -0
- package/src/cameras/Camera.js +160 -0
- package/src/cameras/CubeCamera.d.ts +89 -0
- package/src/cameras/CubeCamera.js +259 -0
- package/src/cameras/OrthographicCamera.d.ts +144 -0
- package/src/cameras/OrthographicCamera.js +245 -0
- package/src/cameras/PerspectiveCamera.d.ts +241 -0
- package/src/cameras/PerspectiveCamera.js +407 -0
- package/src/cameras/StereoCamera.d.ts +44 -0
- package/src/cameras/StereoCamera.js +149 -0
- package/src/constants.d.ts +976 -0
- package/src/constants.js +1774 -0
- package/src/core/BufferAttribute.d.ts +650 -0
- package/src/core/BufferAttribute.js +1093 -0
- package/src/core/BufferGeometry.d.ts +442 -0
- package/src/core/BufferGeometry.js +1472 -0
- package/src/core/Clock.d.ts +73 -0
- package/src/core/Clock.js +135 -0
- package/src/core/EventDispatcher.d.ts +82 -0
- package/src/core/EventDispatcher.js +131 -0
- package/src/core/GLBufferAttribute.d.ts +138 -0
- package/src/core/GLBufferAttribute.js +171 -0
- package/src/core/InstancedBufferAttribute.d.ts +32 -0
- package/src/core/InstancedBufferAttribute.js +68 -0
- package/src/core/InstancedBufferGeometry.d.ts +37 -0
- package/src/core/InstancedBufferGeometry.js +60 -0
- package/src/core/InstancedInterleavedBuffer.d.ts +22 -0
- package/src/core/InstancedInterleavedBuffer.js +74 -0
- package/src/core/InterleavedBuffer.d.ts +162 -0
- package/src/core/InterleavedBuffer.js +305 -0
- package/src/core/InterleavedBufferAttribute.d.ts +201 -0
- package/src/core/InterleavedBufferAttribute.js +583 -0
- package/src/core/Layers.d.ts +72 -0
- package/src/core/Layers.js +121 -0
- package/src/core/Object3D.d.ts +725 -0
- package/src/core/Object3D.js +1719 -0
- package/src/core/Raycaster.d.ts +212 -0
- package/src/core/Raycaster.js +268 -0
- package/src/core/RenderTarget.d.ts +153 -0
- package/src/core/RenderTarget.js +501 -0
- package/src/core/RenderTarget3D.d.ts +9 -0
- package/src/core/RenderTarget3D.js +52 -0
- package/src/core/Timer.d.ts +77 -0
- package/src/core/Timer.js +184 -0
- package/src/core/Uniform.d.ts +38 -0
- package/src/core/Uniform.js +46 -0
- package/src/core/UniformsGroup.d.ts +39 -0
- package/src/core/UniformsGroup.js +184 -0
- package/src/extras/Controls.d.ts +59 -0
- package/src/extras/Controls.js +112 -0
- package/src/extras/DataUtils.d.ts +22 -0
- package/src/extras/DataUtils.js +217 -0
- package/src/extras/Earcut.d.ts +17 -0
- package/src/extras/Earcut.js +28 -0
- package/src/extras/ImageUtils.d.ts +33 -0
- package/src/extras/ImageUtils.js +137 -0
- package/src/extras/PMREMGenerator.d.ts +95 -0
- package/src/extras/PMREMGenerator.js +770 -0
- package/src/extras/ShapeUtils.d.ts +25 -0
- package/src/extras/ShapeUtils.js +114 -0
- package/src/extras/TextureUtils.d.ts +42 -0
- package/src/extras/TextureUtils.js +297 -0
- package/src/extras/core/Curve.d.ts +162 -0
- package/src/extras/core/Curve.js +521 -0
- package/src/extras/core/CurvePath.d.ts +77 -0
- package/src/extras/core/CurvePath.js +309 -0
- package/src/extras/core/Interpolations.d.ts +36 -0
- package/src/extras/core/Interpolations.js +111 -0
- package/src/extras/core/Path.d.ts +166 -0
- package/src/extras/core/Path.js +329 -0
- package/src/extras/core/Shape.d.ts +86 -0
- package/src/extras/core/Shape.js +165 -0
- package/src/extras/core/ShapePath.d.ts +94 -0
- package/src/extras/core/ShapePath.js +356 -0
- package/src/extras/curves/ArcCurve.d.ts +41 -0
- package/src/extras/curves/ArcCurve.js +39 -0
- package/src/extras/curves/CatmullRomCurve3.d.ts +77 -0
- package/src/extras/curves/CatmullRomCurve3.js +327 -0
- package/src/extras/curves/CubicBezierCurve.d.ts +72 -0
- package/src/extras/curves/CubicBezierCurve.js +145 -0
- package/src/extras/curves/CubicBezierCurve3.d.ts +72 -0
- package/src/extras/curves/CubicBezierCurve3.js +129 -0
- package/src/extras/curves/Curves.d.ts +10 -0
- package/src/extras/curves/Curves.js +10 -0
- package/src/extras/curves/EllipseCurve.d.ts +115 -0
- package/src/extras/curves/EllipseCurve.js +258 -0
- package/src/extras/curves/LineCurve.d.ts +42 -0
- package/src/extras/curves/LineCurve.js +128 -0
- package/src/extras/curves/LineCurve3.d.ts +42 -0
- package/src/extras/curves/LineCurve3.js +128 -0
- package/src/extras/curves/QuadraticBezierCurve.d.ts +64 -0
- package/src/extras/curves/QuadraticBezierCurve.js +133 -0
- package/src/extras/curves/QuadraticBezierCurve3.d.ts +64 -0
- package/src/extras/curves/QuadraticBezierCurve3.js +118 -0
- package/src/extras/curves/SplineCurve.d.ts +52 -0
- package/src/extras/curves/SplineCurve.js +145 -0
- package/src/extras/lib/earcut.js +685 -0
- package/src/geometries/BoxGeometry.d.ts +59 -0
- package/src/geometries/BoxGeometry.js +219 -0
- package/src/geometries/CapsuleGeometry.d.ts +56 -0
- package/src/geometries/CapsuleGeometry.js +218 -0
- package/src/geometries/CircleGeometry.d.ts +51 -0
- package/src/geometries/CircleGeometry.js +142 -0
- package/src/geometries/ConeGeometry.d.ts +64 -0
- package/src/geometries/ConeGeometry.js +70 -0
- package/src/geometries/CylinderGeometry.d.ts +64 -0
- package/src/geometries/CylinderGeometry.js +333 -0
- package/src/geometries/DodecahedronGeometry.d.ts +25 -0
- package/src/geometries/DodecahedronGeometry.js +99 -0
- package/src/geometries/EdgesGeometry.d.ts +41 -0
- package/src/geometries/EdgesGeometry.js +182 -0
- package/src/geometries/ExtrudeGeometry.d.ts +138 -0
- package/src/geometries/ExtrudeGeometry.js +910 -0
- package/src/geometries/Geometries.d.ts +21 -0
- package/src/geometries/Geometries.js +21 -0
- package/src/geometries/IcosahedronGeometry.d.ts +26 -0
- package/src/geometries/IcosahedronGeometry.js +75 -0
- package/src/geometries/LatheGeometry.d.ts +55 -0
- package/src/geometries/LatheGeometry.js +232 -0
- package/src/geometries/OctahedronGeometry.d.ts +25 -0
- package/src/geometries/OctahedronGeometry.js +70 -0
- package/src/geometries/PlaneGeometry.d.ts +48 -0
- package/src/geometries/PlaneGeometry.js +133 -0
- package/src/geometries/PolyhedronGeometry.d.ts +54 -0
- package/src/geometries/PolyhedronGeometry.js +348 -0
- package/src/geometries/RingGeometry.d.ts +59 -0
- package/src/geometries/RingGeometry.js +165 -0
- package/src/geometries/ShapeGeometry.d.ts +53 -0
- package/src/geometries/ShapeGeometry.js +233 -0
- package/src/geometries/SphereGeometry.d.ts +67 -0
- package/src/geometries/SphereGeometry.js +180 -0
- package/src/geometries/TetrahedronGeometry.d.ts +25 -0
- package/src/geometries/TetrahedronGeometry.js +67 -0
- package/src/geometries/TorusGeometry.d.ts +69 -0
- package/src/geometries/TorusGeometry.js +161 -0
- package/src/geometries/TorusKnotGeometry.d.ts +59 -0
- package/src/geometries/TorusKnotGeometry.js +206 -0
- package/src/geometries/TubeGeometry.d.ts +86 -0
- package/src/geometries/TubeGeometry.js +253 -0
- package/src/geometries/WireframeGeometry.d.ts +40 -0
- package/src/geometries/WireframeGeometry.js +179 -0
- package/src/helpers/ArrowHelper.d.ts +72 -0
- package/src/helpers/ArrowHelper.js +173 -0
- package/src/helpers/AxesHelper.d.ts +33 -0
- package/src/helpers/AxesHelper.js +98 -0
- package/src/helpers/Box3Helper.d.ts +28 -0
- package/src/helpers/Box3Helper.js +85 -0
- package/src/helpers/BoxHelper.d.ts +48 -0
- package/src/helpers/BoxHelper.js +151 -0
- package/src/helpers/CameraHelper.d.ts +54 -0
- package/src/helpers/CameraHelper.js +347 -0
- package/src/helpers/DirectionalLightHelper.d.ts +55 -0
- package/src/helpers/DirectionalLightHelper.js +152 -0
- package/src/helpers/GridHelper.d.ts +28 -0
- package/src/helpers/GridHelper.js +84 -0
- package/src/helpers/HemisphereLightHelper.d.ts +44 -0
- package/src/helpers/HemisphereLightHelper.js +134 -0
- package/src/helpers/PlaneHelper.d.ts +33 -0
- package/src/helpers/PlaneHelper.js +98 -0
- package/src/helpers/PointLightHelper.d.ts +43 -0
- package/src/helpers/PointLightHelper.js +115 -0
- package/src/helpers/PolarGridHelper.d.ts +37 -0
- package/src/helpers/PolarGridHelper.js +128 -0
- package/src/helpers/SkeletonHelper.d.ts +44 -0
- package/src/helpers/SkeletonHelper.js +196 -0
- package/src/helpers/SpotLightHelper.d.ts +45 -0
- package/src/helpers/SpotLightHelper.js +156 -0
- package/src/lights/AmbientLight.d.ts +28 -0
- package/src/lights/AmbientLight.js +42 -0
- package/src/lights/DirectionalLight.d.ts +68 -0
- package/src/lights/DirectionalLight.js +113 -0
- package/src/lights/DirectionalLightShadow.d.ts +18 -0
- package/src/lights/DirectionalLightShadow.js +31 -0
- package/src/lights/HemisphereLight.d.ts +41 -0
- package/src/lights/HemisphereLight.js +76 -0
- package/src/lights/Light.d.ts +39 -0
- package/src/lights/Light.js +86 -0
- package/src/lights/LightProbe.d.ts +46 -0
- package/src/lights/LightProbe.js +77 -0
- package/src/lights/LightShadow.d.ts +201 -0
- package/src/lights/LightShadow.js +380 -0
- package/src/lights/PointLight.d.ts +72 -0
- package/src/lights/PointLight.js +131 -0
- package/src/lights/PointLightShadow.d.ts +18 -0
- package/src/lights/PointLightShadow.js +31 -0
- package/src/lights/RectAreaLight.d.ts +62 -0
- package/src/lights/RectAreaLight.js +115 -0
- package/src/lights/SpotLight.d.ts +124 -0
- package/src/lights/SpotLight.js +194 -0
- package/src/lights/SpotLightShadow.d.ts +44 -0
- package/src/lights/SpotLightShadow.js +98 -0
- package/src/lights/webgpu/IESSpotLight.d.ts +18 -0
- package/src/lights/webgpu/IESSpotLight.js +47 -0
- package/src/lights/webgpu/ProjectorLight.d.ts +16 -0
- package/src/lights/webgpu/ProjectorLight.js +46 -0
- package/src/loaders/AnimationLoader.d.ts +9 -0
- package/src/loaders/AnimationLoader.js +100 -0
- package/src/loaders/AudioLoader.d.ts +6 -0
- package/src/loaders/AudioLoader.js +110 -0
- package/src/loaders/BufferGeometryLoader.d.ts +10 -0
- package/src/loaders/BufferGeometryLoader.js +249 -0
- package/src/loaders/Cache.d.ts +21 -0
- package/src/loaders/Cache.js +115 -0
- package/src/loaders/CompressedTextureLoader.d.ts +14 -0
- package/src/loaders/CompressedTextureLoader.js +169 -0
- package/src/loaders/CubeTextureLoader.d.ts +14 -0
- package/src/loaders/CubeTextureLoader.js +105 -0
- package/src/loaders/DataTextureLoader.d.ts +48 -0
- package/src/loaders/DataTextureLoader.js +207 -0
- package/src/loaders/FileLoader.d.ts +19 -0
- package/src/loaders/FileLoader.js +369 -0
- package/src/loaders/ImageBitmapLoader.d.ts +22 -0
- package/src/loaders/ImageBitmapLoader.js +227 -0
- package/src/loaders/ImageLoader.d.ts +17 -0
- package/src/loaders/ImageLoader.js +169 -0
- package/src/loaders/Loader.d.ts +51 -0
- package/src/loaders/Loader.js +269 -0
- package/src/loaders/LoaderUtils.d.ts +5 -0
- package/src/loaders/LoaderUtils.js +59 -0
- package/src/loaders/LoadingManager.d.ts +73 -0
- package/src/loaders/LoadingManager.js +334 -0
- package/src/loaders/MaterialLoader.d.ts +29 -0
- package/src/loaders/MaterialLoader.js +211 -0
- package/src/loaders/ObjectLoader.d.ts +35 -0
- package/src/loaders/ObjectLoader.js +1328 -0
- package/src/loaders/TextureLoader.d.ts +18 -0
- package/src/loaders/TextureLoader.js +76 -0
- package/src/loaders/nodes/NodeLoader.d.ts +21 -0
- package/src/loaders/nodes/NodeLoader.js +196 -0
- package/src/loaders/nodes/NodeMaterialLoader.d.ts +11 -0
- package/src/loaders/nodes/NodeMaterialLoader.js +108 -0
- package/src/loaders/nodes/NodeObjectLoader.d.ts +22 -0
- package/src/loaders/nodes/NodeObjectLoader.js +169 -0
- package/src/materials/LineBasicMaterial.d.ts +93 -0
- package/src/materials/LineBasicMaterial.js +126 -0
- package/src/materials/LineDashedMaterial.d.ts +56 -0
- package/src/materials/LineDashedMaterial.js +86 -0
- package/src/materials/Material.d.ts +663 -0
- package/src/materials/Material.js +1254 -0
- package/src/materials/Materials.d.ts +18 -0
- package/src/materials/Materials.js +39 -0
- package/src/materials/MeshBasicMaterial.d.ts +204 -0
- package/src/materials/MeshBasicMaterial.js +274 -0
- package/src/materials/MeshDepthMaterial.d.ts +119 -0
- package/src/materials/MeshDepthMaterial.js +158 -0
- package/src/materials/MeshDistanceMaterial.d.ts +102 -0
- package/src/materials/MeshDistanceMaterial.js +129 -0
- package/src/materials/MeshLambertMaterial.d.ts +331 -0
- package/src/materials/MeshLambertMaterial.js +441 -0
- package/src/materials/MeshMatcapMaterial.d.ts +199 -0
- package/src/materials/MeshMatcapMaterial.js +269 -0
- package/src/materials/MeshNormalMaterial.d.ts +134 -0
- package/src/materials/MeshNormalMaterial.js +183 -0
- package/src/materials/MeshPhongMaterial.d.ts +343 -0
- package/src/materials/MeshPhongMaterial.js +460 -0
- package/src/materials/MeshPhysicalMaterial.d.ts +353 -0
- package/src/materials/MeshPhysicalMaterial.js +685 -0
- package/src/materials/MeshStandardMaterial.d.ts +352 -0
- package/src/materials/MeshStandardMaterial.js +466 -0
- package/src/materials/MeshToonMaterial.d.ts +265 -0
- package/src/materials/MeshToonMaterial.js +354 -0
- package/src/materials/PointsMaterial.d.ts +113 -0
- package/src/materials/PointsMaterial.js +146 -0
- package/src/materials/RawShaderMaterial.d.ts +17 -0
- package/src/materials/RawShaderMaterial.js +42 -0
- package/src/materials/ShaderMaterial.d.ts +268 -0
- package/src/materials/ShaderMaterial.js +499 -0
- package/src/materials/ShadowMaterial.d.ts +61 -0
- package/src/materials/ShadowMaterial.js +91 -0
- package/src/materials/SpriteMaterial.d.ts +100 -0
- package/src/materials/SpriteMaterial.js +143 -0
- package/src/materials/nodes/Line2NodeMaterial.d.ts +102 -0
- package/src/materials/nodes/Line2NodeMaterial.js +656 -0
- package/src/materials/nodes/LineBasicNodeMaterial.d.ts +38 -0
- package/src/materials/nodes/LineBasicNodeMaterial.js +46 -0
- package/src/materials/nodes/LineDashedNodeMaterial.d.ts +88 -0
- package/src/materials/nodes/LineDashedNodeMaterial.js +132 -0
- package/src/materials/nodes/MeshBasicNodeMaterial.d.ts +55 -0
- package/src/materials/nodes/MeshBasicNodeMaterial.js +134 -0
- package/src/materials/nodes/MeshLambertNodeMaterial.d.ts +55 -0
- package/src/materials/nodes/MeshLambertNodeMaterial.js +95 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.d.ts +45 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +77 -0
- package/src/materials/nodes/MeshNormalNodeMaterial.d.ts +41 -0
- package/src/materials/nodes/MeshNormalNodeMaterial.js +67 -0
- package/src/materials/nodes/MeshPhongNodeMaterial.d.ts +77 -0
- package/src/materials/nodes/MeshPhongNodeMaterial.js +145 -0
- package/src/materials/nodes/MeshPhysicalNodeMaterial.d.ts +286 -0
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +563 -0
- package/src/materials/nodes/MeshSSSNodeMaterial.d.ts +110 -0
- package/src/materials/nodes/MeshSSSNodeMaterial.js +162 -0
- package/src/materials/nodes/MeshStandardNodeMaterial.d.ts +93 -0
- package/src/materials/nodes/MeshStandardNodeMaterial.js +176 -0
- package/src/materials/nodes/MeshToonNodeMaterial.d.ts +45 -0
- package/src/materials/nodes/MeshToonNodeMaterial.js +79 -0
- package/src/materials/nodes/NodeMaterial.d.ts +503 -0
- package/src/materials/nodes/NodeMaterial.js +1400 -0
- package/src/materials/nodes/NodeMaterialInstance.js +193 -0
- package/src/materials/nodes/NodeMaterials.d.ts +18 -0
- package/src/materials/nodes/NodeMaterials.js +22 -0
- package/src/materials/nodes/PointsNodeMaterial.d.ts +60 -0
- package/src/materials/nodes/PointsNodeMaterial.js +212 -0
- package/src/materials/nodes/ShadowNodeMaterial.d.ts +45 -0
- package/src/materials/nodes/ShadowNodeMaterial.js +76 -0
- package/src/materials/nodes/SpriteNodeMaterial.d.ts +74 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +176 -0
- package/src/materials/nodes/VolumeNodeMaterial.d.ts +56 -0
- package/src/materials/nodes/VolumeNodeMaterial.js +81 -0
- package/src/materials/nodes/manager/NodeMaterialObserver.d.ts +58 -0
- package/src/materials/nodes/manager/NodeMaterialObserver.js +1142 -0
- package/src/math/Box2.d.ts +48 -0
- package/src/math/Box2.js +381 -0
- package/src/math/Box3.d.ts +310 -0
- package/src/math/Box3.js +810 -0
- package/src/math/Color.d.ts +376 -0
- package/src/math/Color.js +967 -0
- package/src/math/ColorManagement.d.ts +59 -0
- package/src/math/ColorManagement.js +196 -0
- package/src/math/Cylindrical.d.ts +26 -0
- package/src/math/Cylindrical.js +120 -0
- package/src/math/Euler.d.ts +50 -0
- package/src/math/Euler.js +449 -0
- package/src/math/Frustum.d.ts +30 -0
- package/src/math/Frustum.js +294 -0
- package/src/math/FrustumArray.d.ts +86 -0
- package/src/math/FrustumArray.js +240 -0
- package/src/math/Interpolant.d.ts +113 -0
- package/src/math/Interpolant.js +320 -0
- package/src/math/Line3.d.ts +30 -0
- package/src/math/Line3.js +335 -0
- package/src/math/MathUtils.d.ts +153 -0
- package/src/math/MathUtils.js +740 -0
- package/src/math/Matrix2.d.ts +53 -0
- package/src/math/Matrix2.js +128 -0
- package/src/math/Matrix3.d.ts +193 -0
- package/src/math/Matrix3.js +628 -0
- package/src/math/Matrix4.d.ts +506 -0
- package/src/math/Matrix4.js +1332 -0
- package/src/math/Plane.d.ts +55 -0
- package/src/math/Plane.js +397 -0
- package/src/math/Quaternion.d.ts +189 -0
- package/src/math/Quaternion.js +908 -0
- package/src/math/Ray.d.ts +60 -0
- package/src/math/Ray.js +705 -0
- package/src/math/Sphere.d.ts +55 -0
- package/src/math/Sphere.js +420 -0
- package/src/math/Spherical.d.ts +27 -0
- package/src/math/Spherical.js +147 -0
- package/src/math/SphericalHarmonics3.d.ts +50 -0
- package/src/math/SphericalHarmonics3.js +341 -0
- package/src/math/Triangle.d.ts +110 -0
- package/src/math/Triangle.js +538 -0
- package/src/math/Vector2.d.ts +321 -0
- package/src/math/Vector2.js +870 -0
- package/src/math/Vector3.d.ts +301 -0
- package/src/math/Vector3.js +1263 -0
- package/src/math/Vector4.d.ts +241 -0
- package/src/math/Vector4.js +1063 -0
- package/src/math/interpolants/BezierInterpolant.d.ts +23 -0
- package/src/math/interpolants/BezierInterpolant.js +119 -0
- package/src/math/interpolants/CubicInterpolant.d.ts +22 -0
- package/src/math/interpolants/CubicInterpolant.js +159 -0
- package/src/math/interpolants/DiscreteInterpolant.d.ts +12 -0
- package/src/math/interpolants/DiscreteInterpolant.js +34 -0
- package/src/math/interpolants/LinearInterpolant.d.ts +11 -0
- package/src/math/interpolants/LinearInterpolant.js +51 -0
- package/src/math/interpolants/QuaternionLinearInterpolant.d.ts +11 -0
- package/src/math/interpolants/QuaternionLinearInterpolant.js +48 -0
- package/src/nodes/Nodes.d.ts +170 -0
- package/src/nodes/Nodes.js +166 -0
- package/src/nodes/TSL.d.ts +183 -0
- package/src/nodes/TSL.js +185 -0
- package/src/nodes/accessors/AccessorsUtils.d.ts +8 -0
- package/src/nodes/accessors/AccessorsUtils.js +53 -0
- package/src/nodes/accessors/Arrays.d.ts +22 -0
- package/src/nodes/accessors/Arrays.js +68 -0
- package/src/nodes/accessors/Batch.d.ts +25 -0
- package/src/nodes/accessors/Batch.js +186 -0
- package/src/nodes/accessors/Bitangent.d.ts +6 -0
- package/src/nodes/accessors/Bitangent.js +82 -0
- package/src/nodes/accessors/BufferAttributeNode.d.ts +247 -0
- package/src/nodes/accessors/BufferAttributeNode.js +472 -0
- package/src/nodes/accessors/BufferNode.d.ts +33 -0
- package/src/nodes/accessors/BufferNode.js +138 -0
- package/src/nodes/accessors/BuiltinNode.d.ts +13 -0
- package/src/nodes/accessors/BuiltinNode.js +69 -0
- package/src/nodes/accessors/Camera.d.ts +16 -0
- package/src/nodes/accessors/Camera.js +410 -0
- package/src/nodes/accessors/ClippingNode.d.ts +19 -0
- package/src/nodes/accessors/ClippingNode.js +266 -0
- package/src/nodes/accessors/CubeTextureNode.d.ts +38 -0
- package/src/nodes/accessors/CubeTextureNode.js +203 -0
- package/src/nodes/accessors/Instance.d.ts +32 -0
- package/src/nodes/accessors/Instance.js +387 -0
- package/src/nodes/accessors/Lights.d.ts +17 -0
- package/src/nodes/accessors/Lights.js +152 -0
- package/src/nodes/accessors/MaterialNode.d.ts +134 -0
- package/src/nodes/accessors/MaterialNode.js +837 -0
- package/src/nodes/accessors/MaterialProperties.d.ts +8 -0
- package/src/nodes/accessors/MaterialProperties.js +57 -0
- package/src/nodes/accessors/MaterialReferenceNode.d.ts +15 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +84 -0
- package/src/nodes/accessors/ModelNode.d.ts +49 -0
- package/src/nodes/accessors/ModelNode.js +260 -0
- package/src/nodes/accessors/ModelViewProjectionNode.d.ts +3 -0
- package/src/nodes/accessors/ModelViewProjectionNode.js +13 -0
- package/src/nodes/accessors/Morph.d.ts +11 -0
- package/src/nodes/accessors/Morph.js +356 -0
- package/src/nodes/accessors/Normal.d.ts +36 -0
- package/src/nodes/accessors/Normal.js +201 -0
- package/src/nodes/accessors/Object3DNode.d.ts +42 -0
- package/src/nodes/accessors/Object3DNode.js +274 -0
- package/src/nodes/accessors/PointUVNode.d.ts +9 -0
- package/src/nodes/accessors/PointUVNode.js +61 -0
- package/src/nodes/accessors/Position.d.ts +11 -0
- package/src/nodes/accessors/Position.js +126 -0
- package/src/nodes/accessors/ReferenceAttributeNode.js +279 -0
- package/src/nodes/accessors/ReferenceBaseNode.d.ts +26 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +294 -0
- package/src/nodes/accessors/ReferenceElementNode.d.ts +15 -0
- package/src/nodes/accessors/ReferenceElementNode.js +72 -0
- package/src/nodes/accessors/ReferenceNode.d.ts +37 -0
- package/src/nodes/accessors/ReferenceNode.js +362 -0
- package/src/nodes/accessors/ReflectVector.d.ts +7 -0
- package/src/nodes/accessors/ReflectVector.js +36 -0
- package/src/nodes/accessors/RendererReferenceNode.d.ts +14 -0
- package/src/nodes/accessors/RendererReferenceNode.js +78 -0
- package/src/nodes/accessors/SceneProperties.d.ts +5 -0
- package/src/nodes/accessors/SceneProperties.js +47 -0
- package/src/nodes/accessors/Skinning.d.ts +23 -0
- package/src/nodes/accessors/Skinning.js +380 -0
- package/src/nodes/accessors/StorageBufferNode.d.ts +82 -0
- package/src/nodes/accessors/StorageBufferNode.js +396 -0
- package/src/nodes/accessors/StorageTexture3DNode.d.ts +17 -0
- package/src/nodes/accessors/StorageTexture3DNode.js +100 -0
- package/src/nodes/accessors/StorageTextureNode.d.ts +47 -0
- package/src/nodes/accessors/StorageTextureNode.js +331 -0
- package/src/nodes/accessors/Tangent.d.ts +6 -0
- package/src/nodes/accessors/Tangent.js +60 -0
- package/src/nodes/accessors/TangentUtils.d.ts +21 -0
- package/src/nodes/accessors/TangentUtils.js +46 -0
- package/src/nodes/accessors/Texture3DNode.d.ts +29 -0
- package/src/nodes/accessors/Texture3DNode.js +196 -0
- package/src/nodes/accessors/TextureBicubic.d.ts +6 -0
- package/src/nodes/accessors/TextureBicubic.js +95 -0
- package/src/nodes/accessors/TextureNode.d.ts +104 -0
- package/src/nodes/accessors/TextureNode.js +1142 -0
- package/src/nodes/accessors/TextureSizeNode.d.ts +17 -0
- package/src/nodes/accessors/TextureSizeNode.js +85 -0
- package/src/nodes/accessors/UV.d.ts +3 -0
- package/src/nodes/accessors/UV.js +11 -0
- package/src/nodes/accessors/UniformArrayNode.d.ts +29 -0
- package/src/nodes/accessors/UniformArrayNode.js +368 -0
- package/src/nodes/accessors/UserDataNode.d.ts +14 -0
- package/src/nodes/accessors/UserDataNode.js +76 -0
- package/src/nodes/accessors/VelocityNode.d.ts +19 -0
- package/src/nodes/accessors/VelocityNode.js +229 -0
- package/src/nodes/accessors/VertexColorNode.d.ts +11 -0
- package/src/nodes/accessors/VertexColorNode.js +109 -0
- package/src/nodes/code/CodeNode.d.ts +22 -0
- package/src/nodes/code/CodeNode.js +187 -0
- package/src/nodes/code/ExpressionNode.d.ts +9 -0
- package/src/nodes/code/ExpressionNode.js +74 -0
- package/src/nodes/code/FunctionCallNode.d.ts +27 -0
- package/src/nodes/code/FunctionCallNode.js +187 -0
- package/src/nodes/code/FunctionNode.d.ts +40 -0
- package/src/nodes/code/FunctionNode.js +180 -0
- package/src/nodes/core/ArrayNode.d.ts +33 -0
- package/src/nodes/core/ArrayNode.js +174 -0
- package/src/nodes/core/AssignNode.d.ts +15 -0
- package/src/nodes/core/AssignNode.js +203 -0
- package/src/nodes/core/AttributeNode.d.ts +21 -0
- package/src/nodes/core/AttributeNode.js +207 -0
- package/src/nodes/core/BypassNode.d.ts +17 -0
- package/src/nodes/core/BypassNode.js +99 -0
- package/src/nodes/core/ConstNode.d.ts +16 -0
- package/src/nodes/core/ConstNode.js +97 -0
- package/src/nodes/core/ContextNode.d.ts +65 -0
- package/src/nodes/core/ContextNode.js +341 -0
- package/src/nodes/core/IndexNode.d.ts +33 -0
- package/src/nodes/core/IndexNode.js +236 -0
- package/src/nodes/core/InputNode.d.ts +23 -0
- package/src/nodes/core/InputNode.js +142 -0
- package/src/nodes/core/InspectorNode.d.ts +15 -0
- package/src/nodes/core/InspectorNode.js +114 -0
- package/src/nodes/core/IsolateNode.d.ts +31 -0
- package/src/nodes/core/IsolateNode.js +141 -0
- package/src/nodes/core/LightingModel.d.ts +33 -0
- package/src/nodes/core/LightingModel.js +77 -0
- package/src/nodes/core/MRTNode.d.ts +38 -0
- package/src/nodes/core/MRTNode.js +243 -0
- package/src/nodes/core/Node.d.ts +622 -0
- package/src/nodes/core/Node.js +1520 -0
- package/src/nodes/core/NodeAttribute.d.ts +47 -0
- package/src/nodes/core/NodeAttribute.js +53 -0
- package/src/nodes/core/NodeBuilder.d.ts +25 -0
- package/src/nodes/core/NodeBuilder.js +3918 -0
- package/src/nodes/core/NodeCache.d.ts +50 -0
- package/src/nodes/core/NodeCache.js +75 -0
- package/src/nodes/core/NodeCode.d.ts +4 -0
- package/src/nodes/core/NodeCode.js +46 -0
- package/src/nodes/core/NodeError.d.ts +9 -0
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeFrame.d.ts +36 -0
- package/src/nodes/core/NodeFrame.js +322 -0
- package/src/nodes/core/NodeFunction.d.ts +13 -0
- package/src/nodes/core/NodeFunction.js +69 -0
- package/src/nodes/core/NodeFunctionInput.d.ts +7 -0
- package/src/nodes/core/NodeFunctionInput.js +61 -0
- package/src/nodes/core/NodeParser.d.ts +18 -0
- package/src/nodes/core/NodeParser.js +23 -0
- package/src/nodes/core/NodeUniform.d.ts +66 -0
- package/src/nodes/core/NodeUniform.js +91 -0
- package/src/nodes/core/NodeUtils.d.ts +26 -0
- package/src/nodes/core/NodeUtils.js +521 -0
- package/src/nodes/core/NodeVar.d.ts +51 -0
- package/src/nodes/core/NodeVar.js +69 -0
- package/src/nodes/core/NodeVarying.d.ts +59 -0
- package/src/nodes/core/NodeVarying.js +63 -0
- package/src/nodes/core/OutputStructNode.d.ts +11 -0
- package/src/nodes/core/OutputStructNode.js +111 -0
- package/src/nodes/core/OverrideContextNode.d.ts +92 -0
- package/src/nodes/core/OverrideContextNode.js +154 -0
- package/src/nodes/core/ParameterNode.d.ts +18 -0
- package/src/nodes/core/ParameterNode.js +94 -0
- package/src/nodes/core/PropertyNode.d.ts +66 -0
- package/src/nodes/core/PropertyNode.js +435 -0
- package/src/nodes/core/StackNode.d.ts +25 -0
- package/src/nodes/core/StackNode.js +459 -0
- package/src/nodes/core/StackTrace.d.ts +9 -0
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.d.ts +37 -0
- package/src/nodes/core/StructNode.js +139 -0
- package/src/nodes/core/StructType.d.ts +10 -0
- package/src/nodes/core/StructType.js +13 -0
- package/src/nodes/core/StructTypeNode.d.ts +57 -0
- package/src/nodes/core/StructTypeNode.js +154 -0
- package/src/nodes/core/SubBuildNode.d.ts +14 -0
- package/src/nodes/core/SubBuildNode.js +97 -0
- package/src/nodes/core/TempNode.d.ts +16 -0
- package/src/nodes/core/TempNode.js +63 -0
- package/src/nodes/core/UniformGroupNode.d.ts +22 -0
- package/src/nodes/core/UniformGroupNode.js +174 -0
- package/src/nodes/core/UniformNode.d.ts +162 -0
- package/src/nodes/core/UniformNode.js +273 -0
- package/src/nodes/core/VarNode.d.ts +45 -0
- package/src/nodes/core/VarNode.js +282 -0
- package/src/nodes/core/VaryingNode.d.ts +36 -0
- package/src/nodes/core/VaryingNode.js +251 -0
- package/src/nodes/core/constants.d.ts +72 -0
- package/src/nodes/core/constants.js +68 -0
- package/src/nodes/display/BlendModes.d.ts +76 -0
- package/src/nodes/display/BlendModes.js +96 -0
- package/src/nodes/display/BumpMapNode.d.ts +16 -0
- package/src/nodes/display/BumpMapNode.js +132 -0
- package/src/nodes/display/ColorAdjustment.d.ts +54 -0
- package/src/nodes/display/ColorAdjustment.js +171 -0
- package/src/nodes/display/ColorSpaceFunctions.d.ts +5 -0
- package/src/nodes/display/ColorSpaceFunctions.js +42 -0
- package/src/nodes/display/ColorSpaceNode.d.ts +54 -0
- package/src/nodes/display/ColorSpaceNode.js +164 -0
- package/src/nodes/display/FrontFacingNode.d.ts +71 -0
- package/src/nodes/display/FrontFacingNode.js +137 -0
- package/src/nodes/display/NormalMapNode.d.ts +18 -0
- package/src/nodes/display/NormalMapNode.js +153 -0
- package/src/nodes/display/PassNode.d.ts +124 -0
- package/src/nodes/display/PassNode.js +1167 -0
- package/src/nodes/display/PremultiplyAlphaFunctions.d.ts +37 -0
- package/src/nodes/display/PremultiplyAlphaFunctions.js +39 -0
- package/src/nodes/display/RenderOutputNode.d.ts +29 -0
- package/src/nodes/display/RenderOutputNode.js +176 -0
- package/src/nodes/display/ScreenNode.d.ts +44 -0
- package/src/nodes/display/ScreenNode.js +255 -0
- package/src/nodes/display/ToneMappingFunctions.d.ts +13 -0
- package/src/nodes/display/ToneMappingFunctions.js +200 -0
- package/src/nodes/display/ToneMappingNode.d.ts +29 -0
- package/src/nodes/display/ToneMappingNode.js +147 -0
- package/src/nodes/display/ToonOutlinePassNode.d.ts +23 -0
- package/src/nodes/display/ToonOutlinePassNode.js +255 -0
- package/src/nodes/display/ViewportDepthNode.d.ts +41 -0
- package/src/nodes/display/ViewportDepthNode.js +372 -0
- package/src/nodes/display/ViewportDepthTextureNode.d.ts +14 -0
- package/src/nodes/display/ViewportDepthTextureNode.js +63 -0
- package/src/nodes/display/ViewportSharedTextureNode.d.ts +16 -0
- package/src/nodes/display/ViewportSharedTextureNode.js +73 -0
- package/src/nodes/display/ViewportTextureNode.d.ts +33 -0
- package/src/nodes/display/ViewportTextureNode.js +256 -0
- package/src/nodes/fog/Fog.d.ts +27 -0
- package/src/nodes/fog/Fog.js +97 -0
- package/src/nodes/functions/BSDF/BRDF_EON.js +65 -0
- package/src/nodes/functions/BSDF/BRDF_GGX.d.ts +15 -0
- package/src/nodes/functions/BSDF/BRDF_GGX.js +57 -0
- package/src/nodes/functions/BSDF/BRDF_Lambert.d.ts +6 -0
- package/src/nodes/functions/BSDF/BRDF_Lambert.js +9 -0
- package/src/nodes/functions/BSDF/BRDF_Sheen.d.ts +6 -0
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +43 -0
- package/src/nodes/functions/BSDF/DFGLUT.d.ts +13 -0
- package/src/nodes/functions/BSDF/DFGLUT.js +57 -0
- package/src/nodes/functions/BSDF/D_GGX.d.ts +9 -0
- package/src/nodes/functions/BSDF/D_GGX.js +16 -0
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.d.ts +9 -0
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +25 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.d.ts +8 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +13 -0
- package/src/nodes/functions/BSDF/F_Schlick.d.ts +6 -0
- package/src/nodes/functions/BSDF/F_Schlick.js +16 -0
- package/src/nodes/functions/BSDF/LTC.d.ts +13 -0
- package/src/nodes/functions/BSDF/LTC.js +148 -0
- package/src/nodes/functions/BSDF/Schlick_to_F0.d.ts +9 -0
- package/src/nodes/functions/BSDF/Schlick_to_F0.js +13 -0
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.d.ts +10 -0
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +18 -0
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.d.ts +15 -0
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +26 -0
- package/src/nodes/functions/BasicLightingModel.d.ts +7 -0
- package/src/nodes/functions/BasicLightingModel.js +100 -0
- package/src/nodes/functions/PhongLightingModel.d.ts +7 -0
- package/src/nodes/functions/PhongLightingModel.js +99 -0
- package/src/nodes/functions/PhysicalLightingModel.d.ts +40 -0
- package/src/nodes/functions/PhysicalLightingModel.js +969 -0
- package/src/nodes/functions/ShadowMaskModel.d.ts +8 -0
- package/src/nodes/functions/ShadowMaskModel.js +58 -0
- package/src/nodes/functions/ToonLightingModel.d.ts +4 -0
- package/src/nodes/functions/ToonLightingModel.js +70 -0
- package/src/nodes/functions/VolumetricLightingModel.d.ts +6 -0
- package/src/nodes/functions/VolumetricLightingModel.js +216 -0
- package/src/nodes/functions/material/getAlphaHashThreshold.d.ts +5 -0
- package/src/nodes/functions/material/getAlphaHashThreshold.js +62 -0
- package/src/nodes/functions/material/getGeometryRoughness.d.ts +5 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +19 -0
- package/src/nodes/functions/material/getParallaxCorrectNormal.d.ts +9 -0
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +36 -0
- package/src/nodes/functions/material/getRoughness.d.ts +6 -0
- package/src/nodes/functions/material/getRoughness.js +20 -0
- package/src/nodes/functions/material/getShIrradianceAt.d.ts +5 -0
- package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/src/nodes/geometry/RangeNode.d.ts +62 -0
- package/src/nodes/geometry/RangeNode.js +193 -0
- package/src/nodes/gpgpu/AtomicFunctionNode.d.ts +91 -0
- package/src/nodes/gpgpu/AtomicFunctionNode.js +330 -0
- package/src/nodes/gpgpu/BarrierNode.d.ts +15 -0
- package/src/nodes/gpgpu/BarrierNode.js +113 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.d.ts +22 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +233 -0
- package/src/nodes/gpgpu/ComputeNode.d.ts +50 -0
- package/src/nodes/gpgpu/ComputeNode.js +319 -0
- package/src/nodes/gpgpu/SubgroupFunctionNode.d.ts +99 -0
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +592 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.d.ts +24 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +278 -0
- package/src/nodes/lighting/AONode.d.ts +8 -0
- package/src/nodes/lighting/AONode.js +45 -0
- package/src/nodes/lighting/AmbientLightNode.d.ts +8 -0
- package/src/nodes/lighting/AmbientLightNode.js +35 -0
- package/src/nodes/lighting/AnalyticLightNode.d.ts +32 -0
- package/src/nodes/lighting/AnalyticLightNode.js +302 -0
- package/src/nodes/lighting/BasicEnvironmentNode.d.ts +10 -0
- package/src/nodes/lighting/BasicEnvironmentNode.js +53 -0
- package/src/nodes/lighting/BasicLightMapNode.d.ts +8 -0
- package/src/nodes/lighting/BasicLightMapNode.js +49 -0
- package/src/nodes/lighting/DirectionalLightNode.d.ts +8 -0
- package/src/nodes/lighting/DirectionalLightNode.js +39 -0
- package/src/nodes/lighting/EnvironmentNode.d.ts +8 -0
- package/src/nodes/lighting/EnvironmentNode.js +264 -0
- package/src/nodes/lighting/HemisphereLightNode.d.ts +14 -0
- package/src/nodes/lighting/HemisphereLightNode.js +87 -0
- package/src/nodes/lighting/IESSpotLightNode.d.ts +5 -0
- package/src/nodes/lighting/IESSpotLightNode.js +102 -0
- package/src/nodes/lighting/IrradianceNode.d.ts +8 -0
- package/src/nodes/lighting/IrradianceNode.js +44 -0
- package/src/nodes/lighting/LightProbeNode.d.ts +11 -0
- package/src/nodes/lighting/LightProbeNode.js +74 -0
- package/src/nodes/lighting/LightUtils.d.ts +8 -0
- package/src/nodes/lighting/LightUtils.js +25 -0
- package/src/nodes/lighting/LightingContextNode.d.ts +41 -0
- package/src/nodes/lighting/LightingContextNode.js +123 -0
- package/src/nodes/lighting/LightingNode.d.ts +7 -0
- package/src/nodes/lighting/LightingNode.js +42 -0
- package/src/nodes/lighting/LightsNode.d.ts +48 -0
- package/src/nodes/lighting/LightsNode.js +495 -0
- package/src/nodes/lighting/PointLightNode.d.ts +23 -0
- package/src/nodes/lighting/PointLightNode.js +102 -0
- package/src/nodes/lighting/PointShadowNode.d.ts +25 -0
- package/src/nodes/lighting/PointShadowNode.js +374 -0
- package/src/nodes/lighting/ProjectorLightNode.d.ts +5 -0
- package/src/nodes/lighting/ProjectorLightNode.js +91 -0
- package/src/nodes/lighting/RectAreaLightNode.d.ts +21 -0
- package/src/nodes/lighting/RectAreaLightNode.js +132 -0
- package/src/nodes/lighting/ShadowBaseNode.d.ts +47 -0
- package/src/nodes/lighting/ShadowBaseNode.js +230 -0
- package/src/nodes/lighting/ShadowFilterNode.d.ts +17 -0
- package/src/nodes/lighting/ShadowFilterNode.js +152 -0
- package/src/nodes/lighting/ShadowNode.d.ts +11 -0
- package/src/nodes/lighting/ShadowNode.js +843 -0
- package/src/nodes/lighting/SpotLightNode.d.ts +22 -0
- package/src/nodes/lighting/SpotLightNode.js +168 -0
- package/src/nodes/materialx/DISCLAIMER.md +199 -0
- package/src/nodes/materialx/MaterialXColor.d.ts +5 -0
- package/src/nodes/materialx/MaterialXColor.js +112 -0
- package/src/nodes/materialx/MaterialXColorTransform.d.ts +3 -0
- package/src/nodes/materialx/MaterialXColorTransform.js +14 -0
- package/src/nodes/materialx/MaterialXCore.d.ts +5 -0
- package/src/nodes/materialx/MaterialXCore.js +37 -0
- package/src/nodes/materialx/MaterialXNodes.d.ts +206 -0
- package/src/nodes/materialx/MaterialXNodes.js +186 -0
- package/src/nodes/materialx/MaterialXNoise.d.ts +415 -0
- package/src/nodes/materialx/MaterialXNoise.js +1461 -0
- package/src/nodes/math/BitcastNode.d.ts +24 -0
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/BitcountNode.d.ts +23 -0
- package/src/nodes/math/BitcountNode.js +425 -0
- package/src/nodes/math/ConditionalNode.d.ts +51 -0
- package/src/nodes/math/ConditionalNode.js +315 -0
- package/src/nodes/math/Hash.d.ts +3 -0
- package/src/nodes/math/Hash.js +21 -0
- package/src/nodes/math/MathNode.d.ts +895 -0
- package/src/nodes/math/MathNode.js +1252 -0
- package/src/nodes/math/MathUtils.d.ts +10 -0
- package/src/nodes/math/MathUtils.js +65 -0
- package/src/nodes/math/OperatorNode.d.ts +709 -0
- package/src/nodes/math/OperatorNode.js +735 -0
- package/src/nodes/math/PackFloatNode.d.ts +24 -0
- package/src/nodes/math/PackFloatNode.js +126 -0
- package/src/nodes/math/Packed4x8IntegerNode.d.ts +49 -0
- package/src/nodes/math/Packed4x8IntegerNode.js +401 -0
- package/src/nodes/math/TriNoise3D.d.ts +11 -0
- package/src/nodes/math/TriNoise3D.js +51 -0
- package/src/nodes/math/UnpackFloatNode.d.ts +21 -0
- package/src/nodes/math/UnpackFloatNode.js +124 -0
- package/src/nodes/parsers/GLSLNodeFunction.d.ts +9 -0
- package/src/nodes/parsers/GLSLNodeFunction.js +168 -0
- package/src/nodes/parsers/GLSLNodeParser.d.ts +8 -0
- package/src/nodes/parsers/GLSLNodeParser.js +25 -0
- package/src/nodes/pmrem/PMREMNode.d.ts +21 -0
- package/src/nodes/pmrem/PMREMNode.js +391 -0
- package/src/nodes/pmrem/PMREMUtils.d.ts +21 -0
- package/src/nodes/pmrem/PMREMUtils.js +190 -0
- package/src/nodes/procedural/Checker.d.ts +3 -0
- package/src/nodes/procedural/Checker.js +22 -0
- package/src/nodes/shapes/Shapes.d.ts +3 -0
- package/src/nodes/shapes/Shapes.js +33 -0
- package/src/nodes/tsl/TSLBase.d.ts +30 -0
- package/src/nodes/tsl/TSLBase.js +36 -0
- package/src/nodes/tsl/TSLCore.d.ts +2420 -0
- package/src/nodes/tsl/TSLCore.js +1390 -0
- package/src/nodes/utils/ArrayElementNode.d.ts +15 -0
- package/src/nodes/utils/ArrayElementNode.js +108 -0
- package/src/nodes/utils/ConvertNode.d.ts +14 -0
- package/src/nodes/utils/ConvertNode.js +100 -0
- package/src/nodes/utils/CubeMapNode.d.ts +12 -0
- package/src/nodes/utils/CubeMapNode.js +237 -0
- package/src/nodes/utils/DebugNode.d.ts +22 -0
- package/src/nodes/utils/DebugNode.js +83 -0
- package/src/nodes/utils/Discard.d.ts +10 -0
- package/src/nodes/utils/Discard.js +24 -0
- package/src/nodes/utils/EquirectUV.d.ts +33 -0
- package/src/nodes/utils/EquirectUV.js +52 -0
- package/src/nodes/utils/EventNode.d.ts +41 -0
- package/src/nodes/utils/EventNode.js +229 -0
- package/src/nodes/utils/FlipNode.d.ts +11 -0
- package/src/nodes/utils/FlipNode.js +106 -0
- package/src/nodes/utils/FunctionOverloadingNode.d.ts +12 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +176 -0
- package/src/nodes/utils/JoinNode.d.ts +14 -0
- package/src/nodes/utils/JoinNode.js +117 -0
- package/src/nodes/utils/LoopNode.d.ts +43 -0
- package/src/nodes/utils/LoopNode.js +395 -0
- package/src/nodes/utils/MatcapUV.d.ts +3 -0
- package/src/nodes/utils/MatcapUV.js +22 -0
- package/src/nodes/utils/MaxMipLevelNode.d.ts +13 -0
- package/src/nodes/utils/MaxMipLevelNode.js +103 -0
- package/src/nodes/utils/MemberNode.d.ts +11 -0
- package/src/nodes/utils/MemberNode.js +138 -0
- package/src/nodes/utils/Oscillators.d.ts +6 -0
- package/src/nodes/utils/Oscillators.js +41 -0
- package/src/nodes/utils/Packing.d.ts +52 -0
- package/src/nodes/utils/Packing.js +64 -0
- package/src/nodes/utils/PostProcessingUtils.d.ts +56 -0
- package/src/nodes/utils/PostProcessingUtils.js +170 -0
- package/src/nodes/utils/RTTNode.d.ts +46 -0
- package/src/nodes/utils/RTTNode.js +372 -0
- package/src/nodes/utils/ReflectorNode.d.ts +61 -0
- package/src/nodes/utils/ReflectorNode.js +658 -0
- package/src/nodes/utils/Remap.d.ts +223 -0
- package/src/nodes/utils/Remap.js +48 -0
- package/src/nodes/utils/RotateNode.d.ts +26 -0
- package/src/nodes/utils/RotateNode.js +180 -0
- package/src/nodes/utils/SampleNode.d.ts +26 -0
- package/src/nodes/utils/SampleNode.js +97 -0
- package/src/nodes/utils/SetNode.d.ts +11 -0
- package/src/nodes/utils/SetNode.js +108 -0
- package/src/nodes/utils/SplitNode.d.ts +14 -0
- package/src/nodes/utils/SplitNode.js +185 -0
- package/src/nodes/utils/SpriteSheetUV.d.ts +7 -0
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/SpriteUtils.d.ts +5 -0
- package/src/nodes/utils/SpriteUtils.js +98 -0
- package/src/nodes/utils/StorageArrayElementNode.d.ts +28 -0
- package/src/nodes/utils/StorageArrayElementNode.js +143 -0
- package/src/nodes/utils/Timer.d.ts +5 -0
- package/src/nodes/utils/Timer.js +26 -0
- package/src/nodes/utils/TriplanarTextures.d.ts +19 -0
- package/src/nodes/utils/TriplanarTextures.js +65 -0
- package/src/nodes/utils/UVUtils.d.ts +19 -0
- package/src/nodes/utils/UVUtils.js +67 -0
- package/src/nodes/utils/ViewportUtils.d.ts +3 -0
- package/src/nodes/utils/ViewportUtils.js +26 -0
- package/src/objects/BatchedMesh.d.ts +280 -0
- package/src/objects/BatchedMesh.js +1827 -0
- package/src/objects/Bone.d.ts +36 -0
- package/src/objects/Bone.js +41 -0
- package/src/objects/ClippingGroup.d.ts +41 -0
- package/src/objects/ClippingGroup.js +68 -0
- package/src/objects/Group.d.ts +37 -0
- package/src/objects/Group.js +41 -0
- package/src/objects/InstancedMesh.d.ts +175 -0
- package/src/objects/InstancedMesh.js +419 -0
- package/src/objects/LOD.d.ts +112 -0
- package/src/objects/LOD.js +329 -0
- package/src/objects/Line.d.ts +96 -0
- package/src/objects/Line.js +361 -0
- package/src/objects/LineLoop.d.ts +40 -0
- package/src/objects/LineLoop.js +37 -0
- package/src/objects/LineSegments.d.ts +41 -0
- package/src/objects/LineSegments.js +74 -0
- package/src/objects/Mesh.d.ts +111 -0
- package/src/objects/Mesh.js +516 -0
- package/src/objects/Points.d.ts +75 -0
- package/src/objects/Points.js +260 -0
- package/src/objects/Skeleton.d.ts +120 -0
- package/src/objects/Skeleton.js +409 -0
- package/src/objects/SkinnedMesh.d.ts +163 -0
- package/src/objects/SkinnedMesh.js +370 -0
- package/src/objects/Sprite.d.ts +82 -0
- package/src/objects/Sprite.js +267 -0
- package/src/renderers/WebGL3DRenderTarget.d.ts +29 -0
- package/src/renderers/WebGL3DRenderTarget.js +48 -0
- package/src/renderers/WebGLArrayRenderTarget.d.ts +29 -0
- package/src/renderers/WebGLArrayRenderTarget.js +48 -0
- package/src/renderers/WebGLCubeRenderTarget.d.ts +18 -0
- package/src/renderers/WebGLCubeRenderTarget.js +182 -0
- package/src/renderers/WebGLRenderTarget.d.ts +8 -0
- package/src/renderers/WebGLRenderTarget.js +34 -0
- package/src/renderers/WebGLRenderer.d.ts +489 -0
- package/src/renderers/WebGLRenderer.js +3803 -0
- package/src/renderers/common/Animation.js +173 -0
- package/src/renderers/common/Attributes.js +197 -0
- package/src/renderers/common/Backend.d.ts +29 -0
- package/src/renderers/common/Backend.js +916 -0
- package/src/renderers/common/Background.js +225 -0
- package/src/renderers/common/BindGroup.js +56 -0
- package/src/renderers/common/Binding.js +60 -0
- package/src/renderers/common/Bindings.js +641 -0
- package/src/renderers/common/BlendMode.d.ts +22 -0
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/Buffer.js +136 -0
- package/src/renderers/common/BufferUtils.d.ts +28 -0
- package/src/renderers/common/BufferUtils.js +58 -0
- package/src/renderers/common/BundleGroup.d.ts +46 -0
- package/src/renderers/common/BundleGroup.js +87 -0
- package/src/renderers/common/CanvasTarget.d.ts +158 -0
- package/src/renderers/common/CanvasTarget.js +341 -0
- package/src/renderers/common/CapabilityTier.js +18 -0
- package/src/renderers/common/ChainMap.js +122 -0
- package/src/renderers/common/ClippingContext.d.ts +134 -0
- package/src/renderers/common/ClippingContext.js +291 -0
- package/src/renderers/common/Color4.d.ts +53 -0
- package/src/renderers/common/Color4.js +86 -0
- package/src/renderers/common/ComputePipeline.js +57 -0
- package/src/renderers/common/Constants.d.ts +9 -0
- package/src/renderers/common/Constants.js +10 -0
- package/src/renderers/common/CubeRenderTarget.d.ts +47 -0
- package/src/renderers/common/CubeRenderTarget.js +147 -0
- package/src/renderers/common/DataMap.js +90 -0
- package/src/renderers/common/DirectRenderPipeline.d.ts +20 -0
- package/src/renderers/common/DirectRenderPipeline.js +237 -0
- package/src/renderers/common/GPUInstanceCuller.d.ts +43 -0
- package/src/renderers/common/GPUInstanceCuller.js +372 -0
- package/src/renderers/common/GPUTimings.js +66 -0
- package/src/renderers/common/Geometries.js +523 -0
- package/src/renderers/common/IndirectStorageBufferAttribute.d.ts +10 -0
- package/src/renderers/common/IndirectStorageBufferAttribute.js +38 -0
- package/src/renderers/common/Info.d.ts +194 -0
- package/src/renderers/common/Info.js +542 -0
- package/src/renderers/common/InspectorBase.d.ts +129 -0
- package/src/renderers/common/InspectorBase.js +180 -0
- package/src/renderers/common/Lighting.d.ts +55 -0
- package/src/renderers/common/Lighting.js +171 -0
- package/src/renderers/common/Pipeline.js +35 -0
- package/src/renderers/common/Pipelines.js +514 -0
- package/src/renderers/common/PostProcessing.d.ts +21 -0
- package/src/renderers/common/PostProcessing.js +28 -0
- package/src/renderers/common/ProgrammableStage.js +62 -0
- package/src/renderers/common/QuadMesh.d.ts +19 -0
- package/src/renderers/common/QuadMesh.js +126 -0
- package/src/renderers/common/ReadbackBuffer.d.ts +63 -0
- package/src/renderers/common/ReadbackBuffer.js +78 -0
- package/src/renderers/common/RenderBundle.js +26 -0
- package/src/renderers/common/RenderBundles.js +71 -0
- package/src/renderers/common/RenderContext.js +310 -0
- package/src/renderers/common/RenderContexts.js +109 -0
- package/src/renderers/common/RenderList.js +475 -0
- package/src/renderers/common/RenderLists.js +125 -0
- package/src/renderers/common/RenderObject.js +1065 -0
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +263 -0
- package/src/renderers/common/RenderPipeline.d.ts +26 -0
- package/src/renderers/common/RenderPipeline.js +263 -0
- package/src/renderers/common/Renderer.d.ts +1209 -0
- package/src/renderers/common/Renderer.js +4357 -0
- package/src/renderers/common/RendererUtils.d.ts +77 -0
- package/src/renderers/common/RendererUtils.js +215 -0
- package/src/renderers/common/SampledTexture.js +152 -0
- package/src/renderers/common/Sampler.js +133 -0
- package/src/renderers/common/StandardDrawingPipeline.js +343 -0
- package/src/renderers/common/Storage3DTexture.d.ts +42 -0
- package/src/renderers/common/Storage3DTexture.js +127 -0
- package/src/renderers/common/StorageArrayTexture.d.ts +31 -0
- package/src/renderers/common/StorageArrayTexture.js +94 -0
- package/src/renderers/common/StorageBuffer.js +53 -0
- package/src/renderers/common/StorageBufferAttribute.d.ts +7 -0
- package/src/renderers/common/StorageBufferAttribute.js +46 -0
- package/src/renderers/common/StorageInstancedBufferAttribute.d.ts +8 -0
- package/src/renderers/common/StorageInstancedBufferAttribute.js +46 -0
- package/src/renderers/common/StorageTexture.d.ts +7 -0
- package/src/renderers/common/StorageTexture.js +77 -0
- package/src/renderers/common/Textures.js +763 -0
- package/src/renderers/common/TimestampQueryPool.d.ts +120 -0
- package/src/renderers/common/TimestampQueryPool.js +173 -0
- package/src/renderers/common/Uniform.js +375 -0
- package/src/renderers/common/UniformBuffer.js +34 -0
- package/src/renderers/common/UniformsGroup.js +589 -0
- package/src/renderers/common/XRManager.d.ts +293 -0
- package/src/renderers/common/XRManager.js +1928 -0
- package/src/renderers/common/XRRenderTarget.js +91 -0
- package/src/renderers/common/extras/PMREMGenerator.d.ts +52 -0
- package/src/renderers/common/extras/PMREMGenerator.js +673 -0
- package/src/renderers/common/nodes/NodeBuilderState.js +162 -0
- package/src/renderers/common/nodes/NodeLibrary.d.ts +129 -0
- package/src/renderers/common/nodes/NodeLibrary.js +172 -0
- package/src/renderers/common/nodes/NodeManager.js +1219 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +154 -0
- package/src/renderers/common/nodes/NodeSampler.js +76 -0
- package/src/renderers/common/nodes/NodeStorageBuffer.js +74 -0
- package/src/renderers/common/nodes/NodeUniform.js +418 -0
- package/src/renderers/common/nodes/NodeUniformBuffer.js +107 -0
- package/src/renderers/common/nodes/NodeUniformsGroup.js +51 -0
- package/src/renderers/shaders/DFGLUTData.js +50 -0
- package/src/renderers/shaders/ShaderChunk/alphahash_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/alphahash_pars_fragment.glsl.js +68 -0
- package/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js +16 -0
- package/src/renderers/shaders/ShaderChunk/alphatest_pars_fragment.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +26 -0
- package/src/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +49 -0
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +33 -0
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +43 -0
- package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js +10 -0
- package/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js +21 -0
- package/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js +78 -0
- package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +29 -0
- package/src/renderers/shaders/ShaderChunk/colorspace_fragment.glsl.js +3 -0
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +15 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +134 -0
- package/src/renderers/shaders/ShaderChunk/default_fragment.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/default_vertex.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +59 -0
- package/src/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js +20 -0
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +17 -0
- package/src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +23 -0
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +58 -0
- package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +21 -0
- package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +22 -0
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +117 -0
- package/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js +37 -0
- package/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js +17 -0
- package/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js +19 -0
- package/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/fog_vertex.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +27 -0
- package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +120 -0
- package/src/renderers/shaders/ShaderChunk/iridescence_pars_fragment.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/lightprobes_pars_fragment.glsl.js +92 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +281 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +19 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +62 -0
- package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +28 -0
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +236 -0
- package/src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +32 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +183 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +757 -0
- package/src/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js +4 -0
- package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +26 -0
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +17 -0
- package/src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +27 -0
- package/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js +27 -0
- package/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js +12 -0
- package/src/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +33 -0
- package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +16 -0
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +26 -0
- package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +16 -0
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +76 -0
- package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +40 -0
- package/src/renderers/shaders/ShaderChunk/normal_pars_fragment.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/normal_pars_vertex.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +20 -0
- package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +43 -0
- package/src/renderers/shaders/ShaderChunk/opaque_fragment.glsl.js +11 -0
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +116 -0
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js +19 -0
- package/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js +12 -0
- package/src/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +474 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +80 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +85 -0
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +81 -0
- package/src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js +10 -0
- package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +25 -0
- package/src/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js +15 -0
- package/src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js +20 -0
- package/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +200 -0
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +36 -0
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +235 -0
- package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +124 -0
- package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +151 -0
- package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +127 -0
- package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +21 -0
- package/src/renderers/shaders/ShaderChunk.d.ts +144 -0
- package/src/renderers/shaders/ShaderChunk.js +270 -0
- package/src/renderers/shaders/ShaderLib/background.glsl.js +40 -0
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +48 -0
- package/src/renderers/shaders/ShaderLib/cube.glsl.js +36 -0
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +117 -0
- package/src/renderers/shaders/ShaderLib/distance.glsl.js +77 -0
- package/src/renderers/shaders/ShaderLib/equirect.glsl.js +35 -0
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +76 -0
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +116 -0
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +125 -0
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +112 -0
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +86 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +127 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +235 -0
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +118 -0
- package/src/renderers/shaders/ShaderLib/points.glsl.js +87 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +58 -0
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +79 -0
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +51 -0
- package/src/renderers/shaders/ShaderLib.d.ts +29 -0
- package/src/renderers/shaders/ShaderLib.js +366 -0
- package/src/renderers/shaders/UniformsLib.d.ts +209 -0
- package/src/renderers/shaders/UniformsLib.js +249 -0
- package/src/renderers/shaders/UniformsUtils.d.ts +14 -0
- package/src/renderers/shaders/UniformsUtils.js +154 -0
- package/src/renderers/webgl/WebGLAnimation.js +54 -0
- package/src/renderers/webgl/WebGLAttributes.d.ts +23 -0
- package/src/renderers/webgl/WebGLAttributes.js +237 -0
- package/src/renderers/webgl/WebGLBackground.js +303 -0
- package/src/renderers/webgl/WebGLBindingStates.d.ts +26 -0
- package/src/renderers/webgl/WebGLBindingStates.js +668 -0
- package/src/renderers/webgl/WebGLBufferRenderer.d.ts +15 -0
- package/src/renderers/webgl/WebGLBufferRenderer.js +57 -0
- package/src/renderers/webgl/WebGLCapabilities.d.ts +48 -0
- package/src/renderers/webgl/WebGLCapabilities.js +156 -0
- package/src/renderers/webgl/WebGLClipping.d.ts +26 -0
- package/src/renderers/webgl/WebGLClipping.js +171 -0
- package/src/renderers/webgl/WebGLEnvironments.d.ts +8 -0
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLExtensions.d.ts +7 -0
- package/src/renderers/webgl/WebGLExtensions.js +61 -0
- package/src/renderers/webgl/WebGLGeometries.d.ts +13 -0
- package/src/renderers/webgl/WebGLGeometries.js +214 -0
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.d.ts +13 -0
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +68 -0
- package/src/renderers/webgl/WebGLInfo.d.ts +39 -0
- package/src/renderers/webgl/WebGLInfo.js +73 -0
- package/src/renderers/webgl/WebGLLights.d.ts +57 -0
- package/src/renderers/webgl/WebGLLights.js +654 -0
- package/src/renderers/webgl/WebGLMaterials.js +621 -0
- package/src/renderers/webgl/WebGLMorphtargets.js +168 -0
- package/src/renderers/webgl/WebGLObjects.d.ts +19 -0
- package/src/renderers/webgl/WebGLObjects.js +94 -0
- package/src/renderers/webgl/WebGLOutput.js +319 -0
- package/src/renderers/webgl/WebGLProgram.d.ts +22 -0
- package/src/renderers/webgl/WebGLProgram.js +994 -0
- package/src/renderers/webgl/WebGLPrograms.d.ts +242 -0
- package/src/renderers/webgl/WebGLPrograms.js +708 -0
- package/src/renderers/webgl/WebGLProperties.d.ts +9 -0
- package/src/renderers/webgl/WebGLProperties.js +55 -0
- package/src/renderers/webgl/WebGLRenderLists.d.ts +68 -0
- package/src/renderers/webgl/WebGLRenderLists.js +257 -0
- package/src/renderers/webgl/WebGLRenderStates.js +127 -0
- package/src/renderers/webgl/WebGLShader.d.ts +1 -0
- package/src/renderers/webgl/WebGLShader.js +12 -0
- package/src/renderers/webgl/WebGLShaderCache.js +118 -0
- package/src/renderers/webgl/WebGLShadowMap.d.ts +33 -0
- package/src/renderers/webgl/WebGLShadowMap.js +613 -0
- package/src/renderers/webgl/WebGLState.d.ts +399 -0
- package/src/renderers/webgl/WebGLState.js +1374 -0
- package/src/renderers/webgl/WebGLTextures.d.ts +31 -0
- package/src/renderers/webgl/WebGLTextures.js +2571 -0
- package/src/renderers/webgl/WebGLUniforms.d.ts +5 -0
- package/src/renderers/webgl/WebGLUniforms.js +1241 -0
- package/src/renderers/webgl/WebGLUniformsGroups.d.ts +17 -0
- package/src/renderers/webgl/WebGLUniformsGroups.js +447 -0
- package/src/renderers/webgl/WebGLUtils.d.ts +11 -0
- package/src/renderers/webgl/WebGLUtils.js +217 -0
- package/src/renderers/webgl-fallback/WebGLBackend.d.ts +16 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +2878 -0
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +99 -0
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.d.ts +9 -0
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +1994 -0
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +362 -0
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.d.ts +51 -0
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +105 -0
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +13 -0
- package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +83 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +1532 -0
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +1461 -0
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +406 -0
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +319 -0
- package/src/renderers/webgl-fallback/utils/WebGLVertexArrayUtils.js +346 -0
- package/src/renderers/webgpu/WebGPUBackend.d.ts +32 -0
- package/src/renderers/webgpu/WebGPUBackend.js +3379 -0
- package/src/renderers/webgpu/WebGPURenderer.Nodes.d.ts +12 -0
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +69 -0
- package/src/renderers/webgpu/WebGPURenderer.d.ts +17 -0
- package/src/renderers/webgpu/WebGPURenderer.js +107 -0
- package/src/renderers/webgpu/descriptors/GPUBindGroupDescriptor.js +48 -0
- package/src/renderers/webgpu/descriptors/GPUBufferDescriptor.js +57 -0
- package/src/renderers/webgpu/descriptors/GPUCommandEncoderDescriptor.js +30 -0
- package/src/renderers/webgpu/descriptors/GPUComputePassDescriptor.js +38 -0
- package/src/renderers/webgpu/descriptors/GPUComputePipelineDescriptor.js +48 -0
- package/src/renderers/webgpu/descriptors/GPUCopyExternalImageDestInfo.js +47 -0
- package/src/renderers/webgpu/descriptors/GPUCopyExternalImageSourceInfo.js +50 -0
- package/src/renderers/webgpu/descriptors/GPUExtent3D.js +51 -0
- package/src/renderers/webgpu/descriptors/GPUPipelineLayoutDescriptor.js +39 -0
- package/src/renderers/webgpu/descriptors/GPUQuerySetDescriptor.js +47 -0
- package/src/renderers/webgpu/descriptors/GPURenderBundleEncoderDescriptor.js +74 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassColorAttachment.js +72 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassDepthStencilAttachment.js +99 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassDescriptor.js +72 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassTimestampWrites.js +49 -0
- package/src/renderers/webgpu/descriptors/GPURenderPipelineDescriptor.js +130 -0
- package/src/renderers/webgpu/descriptors/GPUSamplerDescriptor.js +119 -0
- package/src/renderers/webgpu/descriptors/GPUShaderModuleDescriptor.js +46 -0
- package/src/renderers/webgpu/descriptors/GPUTexelCopyBufferInfo.js +57 -0
- package/src/renderers/webgpu/descriptors/GPUTexelCopyBufferLayout.js +48 -0
- package/src/renderers/webgpu/descriptors/GPUTexelCopyTextureInfo.js +61 -0
- package/src/renderers/webgpu/descriptors/GPUTextureDescriptor.js +99 -0
- package/src/renderers/webgpu/descriptors/GPUTextureViewDescriptor.js +108 -0
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.d.ts +13 -0
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +66 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.d.ts +91 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +99 -0
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.d.ts +9 -0
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +2834 -0
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +188 -0
- package/src/renderers/webgpu/nodes/WGSLNodeParser.js +25 -0
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +646 -0
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +683 -0
- package/src/renderers/webgpu/utils/WebGPUCapabilities.js +149 -0
- package/src/renderers/webgpu/utils/WebGPUConstants.d.ts +348 -0
- package/src/renderers/webgpu/utils/WebGPUConstants.js +354 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +1010 -0
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +452 -0
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +1920 -0
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +337 -0
- package/src/renderers/webgpu/utils/WebGPUUniformArena.js +240 -0
- package/src/renderers/webgpu/utils/WebGPUUtils.js +359 -0
- package/src/renderers/webxr/WebXRController.d.ts +67 -0
- package/src/renderers/webxr/WebXRController.js +440 -0
- package/src/renderers/webxr/WebXRDepthSensing.d.ts +21 -0
- package/src/renderers/webxr/WebXRDepthSensing.js +155 -0
- package/src/renderers/webxr/WebXRManager.d.ts +89 -0
- package/src/renderers/webxr/WebXRManager.js +1041 -0
- package/src/scenes/Fog.d.ts +71 -0
- package/src/scenes/Fog.js +98 -0
- package/src/scenes/FogExp2.d.ts +61 -0
- package/src/scenes/FogExp2.js +86 -0
- package/src/scenes/Scene.d.ts +104 -0
- package/src/scenes/Scene.js +165 -0
- package/src/textures/CanvasTexture.d.ts +51 -0
- package/src/textures/CanvasTexture.js +45 -0
- package/src/textures/CompressedArrayTexture.d.ts +65 -0
- package/src/textures/CompressedArrayTexture.js +105 -0
- package/src/textures/CompressedCubeTexture.d.ts +13 -0
- package/src/textures/CompressedCubeTexture.js +48 -0
- package/src/textures/CompressedTexture.d.ts +92 -0
- package/src/textures/CompressedTexture.js +86 -0
- package/src/textures/CubeDepthTexture.d.ts +40 -0
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/CubeTexture.d.ts +82 -0
- package/src/textures/CubeTexture.js +81 -0
- package/src/textures/Data3DTexture.d.ts +94 -0
- package/src/textures/Data3DTexture.js +128 -0
- package/src/textures/DataArrayTexture.d.ts +123 -0
- package/src/textures/DataArrayTexture.js +150 -0
- package/src/textures/DataTexture.d.ts +112 -0
- package/src/textures/DataTexture.js +87 -0
- package/src/textures/DepthTexture.d.ts +105 -0
- package/src/textures/DepthTexture.js +104 -0
- package/src/textures/ExternalTexture.d.ts +14 -0
- package/src/textures/ExternalTexture.js +53 -0
- package/src/textures/FramebufferTexture.d.ts +67 -0
- package/src/textures/FramebufferTexture.js +96 -0
- package/src/textures/HTMLTexture.d.ts +27 -0
- package/src/textures/HTMLTexture.js +74 -0
- package/src/textures/Texture.d.ts +565 -0
- package/src/textures/Texture.js +840 -0
- package/src/textures/TextureSource.d.ts +99 -0
- package/src/textures/TextureSource.js +261 -0
- package/src/textures/VideoFrameTexture.d.ts +27 -0
- package/src/textures/VideoFrameTexture.js +72 -0
- package/src/textures/VideoTexture.d.ts +90 -0
- package/src/textures/VideoTexture.js +127 -0
- package/src/upe.d.ts +5 -0
- package/src/upe.js +17 -0
- package/src/utils.d.ts +36 -0
- package/src/utils.js +493 -0
|
@@ -0,0 +1,3856 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BufferAttribute,
|
|
3
|
+
ClampToEdgeWrapping,
|
|
4
|
+
Color,
|
|
5
|
+
DoubleSide,
|
|
6
|
+
InterpolateDiscrete,
|
|
7
|
+
InterpolateLinear,
|
|
8
|
+
NoColorSpace,
|
|
9
|
+
LinearFilter,
|
|
10
|
+
LinearMipmapLinearFilter,
|
|
11
|
+
LinearMipmapNearestFilter,
|
|
12
|
+
MathUtils,
|
|
13
|
+
Matrix4,
|
|
14
|
+
MirroredRepeatWrapping,
|
|
15
|
+
NearestFilter,
|
|
16
|
+
NearestMipmapLinearFilter,
|
|
17
|
+
NearestMipmapNearestFilter,
|
|
18
|
+
PropertyBinding,
|
|
19
|
+
RGBAFormat,
|
|
20
|
+
RepeatWrapping,
|
|
21
|
+
Scene,
|
|
22
|
+
SRGBColorSpace,
|
|
23
|
+
TextureSource,
|
|
24
|
+
CompressedTexture,
|
|
25
|
+
Vector3,
|
|
26
|
+
Quaternion,
|
|
27
|
+
REVISION,
|
|
28
|
+
ImageUtils
|
|
29
|
+
} from 'three';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The KHR_mesh_quantization extension allows these extra attribute component types
|
|
33
|
+
*
|
|
34
|
+
* @see https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_mesh_quantization/README.md#extending-mesh-attributes
|
|
35
|
+
*/
|
|
36
|
+
const KHR_mesh_quantization_ExtraAttrTypes = {
|
|
37
|
+
POSITION: [
|
|
38
|
+
'byte',
|
|
39
|
+
'byte normalized',
|
|
40
|
+
'unsigned byte',
|
|
41
|
+
'unsigned byte normalized',
|
|
42
|
+
'short',
|
|
43
|
+
'short normalized',
|
|
44
|
+
'unsigned short',
|
|
45
|
+
'unsigned short normalized',
|
|
46
|
+
],
|
|
47
|
+
NORMAL: [
|
|
48
|
+
'byte normalized',
|
|
49
|
+
'short normalized',
|
|
50
|
+
],
|
|
51
|
+
TANGENT: [
|
|
52
|
+
'byte normalized',
|
|
53
|
+
'short normalized',
|
|
54
|
+
],
|
|
55
|
+
TEXCOORD: [
|
|
56
|
+
'byte',
|
|
57
|
+
'byte normalized',
|
|
58
|
+
'unsigned byte',
|
|
59
|
+
'short',
|
|
60
|
+
'short normalized',
|
|
61
|
+
'unsigned short',
|
|
62
|
+
],
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* An exporter for `glTF` 2.0.
|
|
67
|
+
*
|
|
68
|
+
* glTF (GL Transmission Format) is an [open format specification](https://github.com/KhronosGroup/glTF/tree/master/specification/2.0)
|
|
69
|
+
* for efficient delivery and loading of 3D content. Assets may be provided either in JSON (.gltf)
|
|
70
|
+
* or binary (.glb) format. External files store textures (.jpg, .png) and additional binary
|
|
71
|
+
* data (.bin). A glTF asset may deliver one or more scenes, including meshes, materials,
|
|
72
|
+
* textures, skins, skeletons, morph targets, animations, lights, and/or cameras.
|
|
73
|
+
*
|
|
74
|
+
* GLTFExporter supports the [glTF 2.0 extensions](https://github.com/KhronosGroup/glTF/tree/master/extensions/):
|
|
75
|
+
*
|
|
76
|
+
* - KHR_lights_punctual
|
|
77
|
+
* - KHR_materials_clearcoat
|
|
78
|
+
* - KHR_materials_dispersion
|
|
79
|
+
* - KHR_materials_emissive_strength
|
|
80
|
+
* - KHR_materials_ior
|
|
81
|
+
* - KHR_materials_iridescence
|
|
82
|
+
* - KHR_materials_specular
|
|
83
|
+
* - KHR_materials_sheen
|
|
84
|
+
* - KHR_materials_transmission
|
|
85
|
+
* - KHR_materials_unlit
|
|
86
|
+
* - KHR_materials_volume
|
|
87
|
+
* - KHR_mesh_quantization
|
|
88
|
+
* - KHR_texture_transform
|
|
89
|
+
* - EXT_materials_bump
|
|
90
|
+
* - EXT_mesh_gpu_instancing
|
|
91
|
+
* - EXT_texture_webp
|
|
92
|
+
*
|
|
93
|
+
* The following glTF 2.0 extension is supported by an external user plugin:
|
|
94
|
+
*
|
|
95
|
+
* - [KHR_materials_variants](https://github.com/takahirox/three-gltf-extensions)
|
|
96
|
+
*
|
|
97
|
+
* ```js
|
|
98
|
+
* const exporter = new GLTFExporter();
|
|
99
|
+
* const data = await exporter.parseAsync( scene, options );
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @three_import import { GLTFExporter } from 'three/addons/exporters/GLTFExporter.js';
|
|
103
|
+
*/
|
|
104
|
+
class GLTFExporter {
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Constructs a new glTF exporter.
|
|
108
|
+
*/
|
|
109
|
+
constructor() {
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* A reference to a texture utils module.
|
|
113
|
+
*
|
|
114
|
+
* @type {?(WebGLTextureUtils|WebGPUTextureUtils)}
|
|
115
|
+
* @default null
|
|
116
|
+
*/
|
|
117
|
+
this.textureUtils = null;
|
|
118
|
+
|
|
119
|
+
this.pluginCallbacks = [];
|
|
120
|
+
|
|
121
|
+
this.register( function ( writer ) {
|
|
122
|
+
|
|
123
|
+
return new GLTFLightExtension( writer );
|
|
124
|
+
|
|
125
|
+
} );
|
|
126
|
+
|
|
127
|
+
this.register( function ( writer ) {
|
|
128
|
+
|
|
129
|
+
return new GLTFMaterialsUnlitExtension( writer );
|
|
130
|
+
|
|
131
|
+
} );
|
|
132
|
+
|
|
133
|
+
this.register( function ( writer ) {
|
|
134
|
+
|
|
135
|
+
return new GLTFMaterialsTransmissionExtension( writer );
|
|
136
|
+
|
|
137
|
+
} );
|
|
138
|
+
|
|
139
|
+
this.register( function ( writer ) {
|
|
140
|
+
|
|
141
|
+
return new GLTFMaterialsVolumeExtension( writer );
|
|
142
|
+
|
|
143
|
+
} );
|
|
144
|
+
|
|
145
|
+
this.register( function ( writer ) {
|
|
146
|
+
|
|
147
|
+
return new GLTFMaterialsIorExtension( writer );
|
|
148
|
+
|
|
149
|
+
} );
|
|
150
|
+
|
|
151
|
+
this.register( function ( writer ) {
|
|
152
|
+
|
|
153
|
+
return new GLTFMaterialsSpecularExtension( writer );
|
|
154
|
+
|
|
155
|
+
} );
|
|
156
|
+
|
|
157
|
+
this.register( function ( writer ) {
|
|
158
|
+
|
|
159
|
+
return new GLTFMaterialsClearcoatExtension( writer );
|
|
160
|
+
|
|
161
|
+
} );
|
|
162
|
+
|
|
163
|
+
this.register( function ( writer ) {
|
|
164
|
+
|
|
165
|
+
return new GLTFMaterialsDispersionExtension( writer );
|
|
166
|
+
|
|
167
|
+
} );
|
|
168
|
+
|
|
169
|
+
this.register( function ( writer ) {
|
|
170
|
+
|
|
171
|
+
return new GLTFMaterialsIridescenceExtension( writer );
|
|
172
|
+
|
|
173
|
+
} );
|
|
174
|
+
|
|
175
|
+
this.register( function ( writer ) {
|
|
176
|
+
|
|
177
|
+
return new GLTFMaterialsSheenExtension( writer );
|
|
178
|
+
|
|
179
|
+
} );
|
|
180
|
+
|
|
181
|
+
this.register( function ( writer ) {
|
|
182
|
+
|
|
183
|
+
return new GLTFMaterialsAnisotropyExtension( writer );
|
|
184
|
+
|
|
185
|
+
} );
|
|
186
|
+
|
|
187
|
+
this.register( function ( writer ) {
|
|
188
|
+
|
|
189
|
+
return new GLTFMaterialsEmissiveStrengthExtension( writer );
|
|
190
|
+
|
|
191
|
+
} );
|
|
192
|
+
|
|
193
|
+
this.register( function ( writer ) {
|
|
194
|
+
|
|
195
|
+
return new GLTFMaterialsBumpExtension( writer );
|
|
196
|
+
|
|
197
|
+
} );
|
|
198
|
+
|
|
199
|
+
this.register( function ( writer ) {
|
|
200
|
+
|
|
201
|
+
return new GLTFMeshGpuInstancing( writer );
|
|
202
|
+
|
|
203
|
+
} );
|
|
204
|
+
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Registers a plugin callback. This API is internally used to implement the various
|
|
209
|
+
* glTF extensions but can also used by third-party code to add additional logic
|
|
210
|
+
* to the exporter.
|
|
211
|
+
*
|
|
212
|
+
* @param {function(writer:GLTFWriter)} callback - The callback function to register.
|
|
213
|
+
* @return {GLTFExporter} A reference to this exporter.
|
|
214
|
+
*/
|
|
215
|
+
register( callback ) {
|
|
216
|
+
|
|
217
|
+
if ( this.pluginCallbacks.indexOf( callback ) === - 1 ) {
|
|
218
|
+
|
|
219
|
+
this.pluginCallbacks.push( callback );
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return this;
|
|
224
|
+
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Unregisters a plugin callback.
|
|
229
|
+
*
|
|
230
|
+
* @param {Function} callback - The callback function to unregister.
|
|
231
|
+
* @return {GLTFExporter} A reference to this exporter.
|
|
232
|
+
*/
|
|
233
|
+
unregister( callback ) {
|
|
234
|
+
|
|
235
|
+
if ( this.pluginCallbacks.indexOf( callback ) !== - 1 ) {
|
|
236
|
+
|
|
237
|
+
this.pluginCallbacks.splice( this.pluginCallbacks.indexOf( callback ), 1 );
|
|
238
|
+
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return this;
|
|
242
|
+
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Sets the texture utils for this exporter. Only relevant when compressed textures have to be exported.
|
|
247
|
+
*
|
|
248
|
+
* Depending on whether you use {@link WebGLRenderer} or {@link WebGPURenderer}, you must inject the
|
|
249
|
+
* corresponding texture utils {@link module:WebGLTextureUtils} or {@link module:WebGPUTextureUtils}.
|
|
250
|
+
*
|
|
251
|
+
* @param {WebGLTextureUtils|WebGPUTextureUtils} utils - The texture utils.
|
|
252
|
+
* @return {GLTFExporter} A reference to this exporter.
|
|
253
|
+
*/
|
|
254
|
+
setTextureUtils( utils ) {
|
|
255
|
+
|
|
256
|
+
this.textureUtils = utils;
|
|
257
|
+
|
|
258
|
+
return this;
|
|
259
|
+
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Parses the given scenes and generates the glTF output.
|
|
264
|
+
*
|
|
265
|
+
* @param {Scene|Array<Scene>} input - A scene or an array of scenes.
|
|
266
|
+
* @param {GLTFExporter~OnDone} onDone - A callback function that is executed when the export has finished.
|
|
267
|
+
* @param {GLTFExporter~OnError} onError - A callback function that is executed when an error happens.
|
|
268
|
+
* @param {GLTFExporter~Options} options - options
|
|
269
|
+
*/
|
|
270
|
+
parse( input, onDone, onError, options ) {
|
|
271
|
+
|
|
272
|
+
const writer = new GLTFWriter();
|
|
273
|
+
const plugins = [];
|
|
274
|
+
|
|
275
|
+
for ( let i = 0, il = this.pluginCallbacks.length; i < il; i ++ ) {
|
|
276
|
+
|
|
277
|
+
plugins.push( this.pluginCallbacks[ i ]( writer ) );
|
|
278
|
+
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
writer.setPlugins( plugins );
|
|
282
|
+
writer.setTextureUtils( this.textureUtils );
|
|
283
|
+
writer.writeAsync( input, onDone, options ).catch( onError );
|
|
284
|
+
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Async version of {@link GLTFExporter#parse}.
|
|
289
|
+
*
|
|
290
|
+
* @param {Scene|Array<Scene>} input - A scene or an array of scenes.
|
|
291
|
+
* @param {GLTFExporter~Options} options - options.
|
|
292
|
+
* @return {Promise<ArrayBuffer|string>} A Promise that resolved with the exported glTF data.
|
|
293
|
+
*/
|
|
294
|
+
parseAsync( input, options ) {
|
|
295
|
+
|
|
296
|
+
const scope = this;
|
|
297
|
+
|
|
298
|
+
return new Promise( function ( resolve, reject ) {
|
|
299
|
+
|
|
300
|
+
scope.parse( input, resolve, reject, options );
|
|
301
|
+
|
|
302
|
+
} );
|
|
303
|
+
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
//------------------------------------------------------------------------------
|
|
309
|
+
// Constants
|
|
310
|
+
//------------------------------------------------------------------------------
|
|
311
|
+
|
|
312
|
+
const WEBGL_CONSTANTS = {
|
|
313
|
+
POINTS: 0x0000,
|
|
314
|
+
LINES: 0x0001,
|
|
315
|
+
LINE_LOOP: 0x0002,
|
|
316
|
+
LINE_STRIP: 0x0003,
|
|
317
|
+
TRIANGLES: 0x0004,
|
|
318
|
+
TRIANGLE_STRIP: 0x0005,
|
|
319
|
+
TRIANGLE_FAN: 0x0006,
|
|
320
|
+
|
|
321
|
+
BYTE: 0x1400,
|
|
322
|
+
UNSIGNED_BYTE: 0x1401,
|
|
323
|
+
SHORT: 0x1402,
|
|
324
|
+
UNSIGNED_SHORT: 0x1403,
|
|
325
|
+
INT: 0x1404,
|
|
326
|
+
UNSIGNED_INT: 0x1405,
|
|
327
|
+
FLOAT: 0x1406,
|
|
328
|
+
|
|
329
|
+
ARRAY_BUFFER: 0x8892,
|
|
330
|
+
ELEMENT_ARRAY_BUFFER: 0x8893,
|
|
331
|
+
|
|
332
|
+
NEAREST: 0x2600,
|
|
333
|
+
LINEAR: 0x2601,
|
|
334
|
+
NEAREST_MIPMAP_NEAREST: 0x2700,
|
|
335
|
+
LINEAR_MIPMAP_NEAREST: 0x2701,
|
|
336
|
+
NEAREST_MIPMAP_LINEAR: 0x2702,
|
|
337
|
+
LINEAR_MIPMAP_LINEAR: 0x2703,
|
|
338
|
+
|
|
339
|
+
CLAMP_TO_EDGE: 33071,
|
|
340
|
+
MIRRORED_REPEAT: 33648,
|
|
341
|
+
REPEAT: 10497
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
const KHR_MESH_QUANTIZATION = 'KHR_mesh_quantization';
|
|
345
|
+
|
|
346
|
+
const THREE_TO_WEBGL = {};
|
|
347
|
+
|
|
348
|
+
THREE_TO_WEBGL[ NearestFilter ] = WEBGL_CONSTANTS.NEAREST;
|
|
349
|
+
THREE_TO_WEBGL[ NearestMipmapNearestFilter ] = WEBGL_CONSTANTS.NEAREST_MIPMAP_NEAREST;
|
|
350
|
+
THREE_TO_WEBGL[ NearestMipmapLinearFilter ] = WEBGL_CONSTANTS.NEAREST_MIPMAP_LINEAR;
|
|
351
|
+
THREE_TO_WEBGL[ LinearFilter ] = WEBGL_CONSTANTS.LINEAR;
|
|
352
|
+
THREE_TO_WEBGL[ LinearMipmapNearestFilter ] = WEBGL_CONSTANTS.LINEAR_MIPMAP_NEAREST;
|
|
353
|
+
THREE_TO_WEBGL[ LinearMipmapLinearFilter ] = WEBGL_CONSTANTS.LINEAR_MIPMAP_LINEAR;
|
|
354
|
+
|
|
355
|
+
THREE_TO_WEBGL[ ClampToEdgeWrapping ] = WEBGL_CONSTANTS.CLAMP_TO_EDGE;
|
|
356
|
+
THREE_TO_WEBGL[ RepeatWrapping ] = WEBGL_CONSTANTS.REPEAT;
|
|
357
|
+
THREE_TO_WEBGL[ MirroredRepeatWrapping ] = WEBGL_CONSTANTS.MIRRORED_REPEAT;
|
|
358
|
+
|
|
359
|
+
const PATH_PROPERTIES = {
|
|
360
|
+
scale: 'scale',
|
|
361
|
+
position: 'translation',
|
|
362
|
+
quaternion: 'rotation',
|
|
363
|
+
morphTargetInfluences: 'weights'
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
const DEFAULT_SPECULAR_COLOR = new Color();
|
|
367
|
+
|
|
368
|
+
// GLB constants
|
|
369
|
+
// https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#glb-file-format-specification
|
|
370
|
+
|
|
371
|
+
const GLB_HEADER_BYTES = 12;
|
|
372
|
+
const GLB_HEADER_MAGIC = 0x46546C67;
|
|
373
|
+
const GLB_VERSION = 2;
|
|
374
|
+
|
|
375
|
+
const GLB_CHUNK_PREFIX_BYTES = 8;
|
|
376
|
+
const GLB_CHUNK_TYPE_JSON = 0x4E4F534A;
|
|
377
|
+
const GLB_CHUNK_TYPE_BIN = 0x004E4942;
|
|
378
|
+
|
|
379
|
+
//------------------------------------------------------------------------------
|
|
380
|
+
// Utility functions
|
|
381
|
+
//------------------------------------------------------------------------------
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Compare two arrays
|
|
385
|
+
*
|
|
386
|
+
* @private
|
|
387
|
+
* @param {Array} array1 Array 1 to compare
|
|
388
|
+
* @param {Array} array2 Array 2 to compare
|
|
389
|
+
* @return {boolean} Returns true if both arrays are equal
|
|
390
|
+
*/
|
|
391
|
+
function equalArray( array1, array2 ) {
|
|
392
|
+
|
|
393
|
+
return ( array1.length === array2.length ) && array1.every( function ( element, index ) {
|
|
394
|
+
|
|
395
|
+
return element === array2[ index ];
|
|
396
|
+
|
|
397
|
+
} );
|
|
398
|
+
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Converts a string to an ArrayBuffer.
|
|
403
|
+
*
|
|
404
|
+
* @private
|
|
405
|
+
* @param {string} text
|
|
406
|
+
* @return {ArrayBuffer}
|
|
407
|
+
*/
|
|
408
|
+
function stringToArrayBuffer( text ) {
|
|
409
|
+
|
|
410
|
+
return new TextEncoder().encode( text ).buffer;
|
|
411
|
+
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Is identity matrix
|
|
416
|
+
*
|
|
417
|
+
* @private
|
|
418
|
+
* @param {Matrix4} matrix
|
|
419
|
+
* @returns {boolean} Returns true, if parameter is identity matrix
|
|
420
|
+
*/
|
|
421
|
+
function isIdentityMatrix( matrix ) {
|
|
422
|
+
|
|
423
|
+
return equalArray( matrix.elements, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ] );
|
|
424
|
+
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Get the min and max vectors from the given attribute
|
|
429
|
+
*
|
|
430
|
+
* @private
|
|
431
|
+
* @param {BufferAttribute} attribute Attribute to find the min/max in range from start to start + count
|
|
432
|
+
* @param {number} start Start index
|
|
433
|
+
* @param {number} count Range to cover
|
|
434
|
+
* @return {Object} Object containing the `min` and `max` values (As an array of attribute.itemSize components)
|
|
435
|
+
*/
|
|
436
|
+
function getMinMax( attribute, start, count ) {
|
|
437
|
+
|
|
438
|
+
const output = {
|
|
439
|
+
|
|
440
|
+
min: new Array( attribute.itemSize ).fill( Number.POSITIVE_INFINITY ),
|
|
441
|
+
max: new Array( attribute.itemSize ).fill( Number.NEGATIVE_INFINITY )
|
|
442
|
+
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
for ( let i = start; i < start + count; i ++ ) {
|
|
446
|
+
|
|
447
|
+
for ( let a = 0; a < attribute.itemSize; a ++ ) {
|
|
448
|
+
|
|
449
|
+
let value;
|
|
450
|
+
|
|
451
|
+
if ( attribute.itemSize > 4 ) {
|
|
452
|
+
|
|
453
|
+
// no support for interleaved data for itemSize > 4
|
|
454
|
+
|
|
455
|
+
value = attribute.array[ i * attribute.itemSize + a ];
|
|
456
|
+
|
|
457
|
+
} else {
|
|
458
|
+
|
|
459
|
+
if ( a === 0 ) value = attribute.getX( i );
|
|
460
|
+
else if ( a === 1 ) value = attribute.getY( i );
|
|
461
|
+
else if ( a === 2 ) value = attribute.getZ( i );
|
|
462
|
+
else if ( a === 3 ) value = attribute.getW( i );
|
|
463
|
+
|
|
464
|
+
if ( attribute.normalized === true ) {
|
|
465
|
+
|
|
466
|
+
value = MathUtils.normalize( value, attribute.array );
|
|
467
|
+
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
output.min[ a ] = Math.min( output.min[ a ], value );
|
|
473
|
+
output.max[ a ] = Math.max( output.max[ a ], value );
|
|
474
|
+
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
return output;
|
|
480
|
+
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Get the required size + padding for a buffer, rounded to the next 4-byte boundary.
|
|
485
|
+
* https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#data-alignment
|
|
486
|
+
*
|
|
487
|
+
* @private
|
|
488
|
+
* @param {number} bufferSize The size the original buffer. Should be an integer.
|
|
489
|
+
* @returns {number} new buffer size with required padding as an integer.
|
|
490
|
+
*
|
|
491
|
+
*/
|
|
492
|
+
function getPaddedBufferSize( bufferSize ) {
|
|
493
|
+
|
|
494
|
+
return Math.ceil( bufferSize / 4 ) * 4;
|
|
495
|
+
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Returns a buffer aligned to 4-byte boundary.
|
|
500
|
+
*
|
|
501
|
+
* @private
|
|
502
|
+
* @param {ArrayBuffer} arrayBuffer Buffer to pad
|
|
503
|
+
* @param {number} [paddingByte=0] Should be an integer
|
|
504
|
+
* @returns {ArrayBuffer} The same buffer if it's already aligned to 4-byte boundary or a new buffer
|
|
505
|
+
*/
|
|
506
|
+
function getPaddedArrayBuffer( arrayBuffer, paddingByte = 0 ) {
|
|
507
|
+
|
|
508
|
+
const paddedLength = getPaddedBufferSize( arrayBuffer.byteLength );
|
|
509
|
+
|
|
510
|
+
if ( paddedLength !== arrayBuffer.byteLength ) {
|
|
511
|
+
|
|
512
|
+
const array = new Uint8Array( paddedLength );
|
|
513
|
+
array.set( new Uint8Array( arrayBuffer ) );
|
|
514
|
+
|
|
515
|
+
if ( paddingByte !== 0 ) {
|
|
516
|
+
|
|
517
|
+
for ( let i = arrayBuffer.byteLength; i < paddedLength; i ++ ) {
|
|
518
|
+
|
|
519
|
+
array[ i ] = paddingByte;
|
|
520
|
+
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
return array.buffer;
|
|
526
|
+
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
return arrayBuffer;
|
|
530
|
+
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
function getCanvas() {
|
|
534
|
+
|
|
535
|
+
if ( typeof document === 'undefined' && typeof OffscreenCanvas !== 'undefined' ) {
|
|
536
|
+
|
|
537
|
+
return new OffscreenCanvas( 1, 1 );
|
|
538
|
+
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
return document.createElement( 'canvas' );
|
|
542
|
+
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
function getToBlobPromise( canvas, mimeType ) {
|
|
546
|
+
|
|
547
|
+
if ( typeof OffscreenCanvas !== 'undefined' && canvas instanceof OffscreenCanvas ) {
|
|
548
|
+
|
|
549
|
+
let quality;
|
|
550
|
+
|
|
551
|
+
// Blink's implementation of convertToBlob seems to default to a quality level of 100%
|
|
552
|
+
// Use the Blink default quality levels of toBlob instead so that file sizes are comparable.
|
|
553
|
+
if ( mimeType === 'image/jpeg' ) {
|
|
554
|
+
|
|
555
|
+
quality = 0.92;
|
|
556
|
+
|
|
557
|
+
} else if ( mimeType === 'image/webp' ) {
|
|
558
|
+
|
|
559
|
+
quality = 0.8;
|
|
560
|
+
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
return canvas.convertToBlob( {
|
|
564
|
+
|
|
565
|
+
type: mimeType,
|
|
566
|
+
quality: quality
|
|
567
|
+
|
|
568
|
+
} );
|
|
569
|
+
|
|
570
|
+
} else {
|
|
571
|
+
|
|
572
|
+
// HTMLCanvasElement code path
|
|
573
|
+
|
|
574
|
+
return new Promise( ( resolve ) => canvas.toBlob( resolve, mimeType ) );
|
|
575
|
+
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Writer
|
|
582
|
+
*
|
|
583
|
+
* @private
|
|
584
|
+
*/
|
|
585
|
+
class GLTFWriter {
|
|
586
|
+
|
|
587
|
+
constructor() {
|
|
588
|
+
|
|
589
|
+
this.plugins = [];
|
|
590
|
+
|
|
591
|
+
this.options = {};
|
|
592
|
+
this.pending = [];
|
|
593
|
+
this.buffers = [];
|
|
594
|
+
|
|
595
|
+
this.byteOffset = 0;
|
|
596
|
+
this.buffers = [];
|
|
597
|
+
this.nodeMap = new Map();
|
|
598
|
+
this.skins = [];
|
|
599
|
+
|
|
600
|
+
this.extensionsUsed = {};
|
|
601
|
+
this.extensionsRequired = {};
|
|
602
|
+
|
|
603
|
+
this.uids = new Map();
|
|
604
|
+
this.uid = 0;
|
|
605
|
+
|
|
606
|
+
this.json = {
|
|
607
|
+
asset: {
|
|
608
|
+
version: '2.0',
|
|
609
|
+
generator: 'THREE.GLTFExporter r' + REVISION
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
|
|
613
|
+
this.cache = {
|
|
614
|
+
meshes: new Map(),
|
|
615
|
+
attributes: new Map(),
|
|
616
|
+
attributesNormalized: new Map(),
|
|
617
|
+
materials: new Map(),
|
|
618
|
+
textures: new Map(),
|
|
619
|
+
images: new Map(),
|
|
620
|
+
normalMaps: new Map()
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
this.textureUtils = null;
|
|
624
|
+
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
setPlugins( plugins ) {
|
|
628
|
+
|
|
629
|
+
this.plugins = plugins;
|
|
630
|
+
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
setTextureUtils( utils ) {
|
|
634
|
+
|
|
635
|
+
this.textureUtils = utils;
|
|
636
|
+
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Parse scenes and generate GLTF output
|
|
641
|
+
*
|
|
642
|
+
* @param {Scene|Array<Scene>} input Scene or Array of THREE.Scenes
|
|
643
|
+
* @param {Function} onDone Callback on completed
|
|
644
|
+
* @param {Object} options options
|
|
645
|
+
*/
|
|
646
|
+
async writeAsync( input, onDone, options = {} ) {
|
|
647
|
+
|
|
648
|
+
this.options = Object.assign( {
|
|
649
|
+
// default options
|
|
650
|
+
binary: false,
|
|
651
|
+
trs: false,
|
|
652
|
+
onlyVisible: true,
|
|
653
|
+
maxTextureSize: Infinity,
|
|
654
|
+
animations: [],
|
|
655
|
+
includeCustomExtensions: false,
|
|
656
|
+
copyright: null
|
|
657
|
+
}, options );
|
|
658
|
+
|
|
659
|
+
if ( this.options.animations.length > 0 ) {
|
|
660
|
+
|
|
661
|
+
// Only TRS properties, and not matrices, may be targeted by animation.
|
|
662
|
+
this.options.trs = true;
|
|
663
|
+
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
await this.processInputAsync( input );
|
|
667
|
+
|
|
668
|
+
await Promise.all( this.pending );
|
|
669
|
+
|
|
670
|
+
const writer = this;
|
|
671
|
+
const buffers = writer.buffers;
|
|
672
|
+
const json = writer.json;
|
|
673
|
+
options = writer.options;
|
|
674
|
+
|
|
675
|
+
const extensionsUsed = writer.extensionsUsed;
|
|
676
|
+
const extensionsRequired = writer.extensionsRequired;
|
|
677
|
+
|
|
678
|
+
// Merge buffers.
|
|
679
|
+
const blob = new Blob( buffers, { type: 'application/octet-stream' } );
|
|
680
|
+
|
|
681
|
+
// Declare extensions.
|
|
682
|
+
const extensionsUsedList = Object.keys( extensionsUsed );
|
|
683
|
+
const extensionsRequiredList = Object.keys( extensionsRequired );
|
|
684
|
+
|
|
685
|
+
if ( extensionsUsedList.length > 0 ) json.extensionsUsed = extensionsUsedList;
|
|
686
|
+
if ( extensionsRequiredList.length > 0 ) json.extensionsRequired = extensionsRequiredList;
|
|
687
|
+
|
|
688
|
+
// Update bytelength of the single buffer.
|
|
689
|
+
if ( json.buffers && json.buffers.length > 0 ) json.buffers[ 0 ].byteLength = blob.size;
|
|
690
|
+
|
|
691
|
+
if ( options.copyright ) json.asset.copyright = options.copyright;
|
|
692
|
+
|
|
693
|
+
if ( options.binary === true ) {
|
|
694
|
+
|
|
695
|
+
// https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#glb-file-format-specification
|
|
696
|
+
|
|
697
|
+
const reader = new FileReader();
|
|
698
|
+
reader.readAsArrayBuffer( blob );
|
|
699
|
+
reader.onloadend = function () {
|
|
700
|
+
|
|
701
|
+
// Binary chunk.
|
|
702
|
+
const binaryChunk = getPaddedArrayBuffer( reader.result );
|
|
703
|
+
const binaryChunkPrefix = new DataView( new ArrayBuffer( GLB_CHUNK_PREFIX_BYTES ) );
|
|
704
|
+
binaryChunkPrefix.setUint32( 0, binaryChunk.byteLength, true );
|
|
705
|
+
binaryChunkPrefix.setUint32( 4, GLB_CHUNK_TYPE_BIN, true );
|
|
706
|
+
|
|
707
|
+
// JSON chunk.
|
|
708
|
+
const jsonChunk = getPaddedArrayBuffer( stringToArrayBuffer( JSON.stringify( json ) ), 0x20 );
|
|
709
|
+
const jsonChunkPrefix = new DataView( new ArrayBuffer( GLB_CHUNK_PREFIX_BYTES ) );
|
|
710
|
+
jsonChunkPrefix.setUint32( 0, jsonChunk.byteLength, true );
|
|
711
|
+
jsonChunkPrefix.setUint32( 4, GLB_CHUNK_TYPE_JSON, true );
|
|
712
|
+
|
|
713
|
+
// GLB header.
|
|
714
|
+
const header = new ArrayBuffer( GLB_HEADER_BYTES );
|
|
715
|
+
const headerView = new DataView( header );
|
|
716
|
+
headerView.setUint32( 0, GLB_HEADER_MAGIC, true );
|
|
717
|
+
headerView.setUint32( 4, GLB_VERSION, true );
|
|
718
|
+
const totalByteLength = GLB_HEADER_BYTES
|
|
719
|
+
+ jsonChunkPrefix.byteLength + jsonChunk.byteLength
|
|
720
|
+
+ binaryChunkPrefix.byteLength + binaryChunk.byteLength;
|
|
721
|
+
headerView.setUint32( 8, totalByteLength, true );
|
|
722
|
+
|
|
723
|
+
const glbBlob = new Blob( [
|
|
724
|
+
header,
|
|
725
|
+
jsonChunkPrefix,
|
|
726
|
+
jsonChunk,
|
|
727
|
+
binaryChunkPrefix,
|
|
728
|
+
binaryChunk
|
|
729
|
+
], { type: 'application/octet-stream' } );
|
|
730
|
+
|
|
731
|
+
const glbReader = new FileReader();
|
|
732
|
+
glbReader.readAsArrayBuffer( glbBlob );
|
|
733
|
+
glbReader.onloadend = function () {
|
|
734
|
+
|
|
735
|
+
onDone( glbReader.result );
|
|
736
|
+
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
};
|
|
740
|
+
|
|
741
|
+
} else {
|
|
742
|
+
|
|
743
|
+
if ( json.buffers && json.buffers.length > 0 ) {
|
|
744
|
+
|
|
745
|
+
const reader = new FileReader();
|
|
746
|
+
reader.readAsDataURL( blob );
|
|
747
|
+
reader.onloadend = function () {
|
|
748
|
+
|
|
749
|
+
const base64data = reader.result;
|
|
750
|
+
json.buffers[ 0 ].uri = base64data;
|
|
751
|
+
onDone( json );
|
|
752
|
+
|
|
753
|
+
};
|
|
754
|
+
|
|
755
|
+
} else {
|
|
756
|
+
|
|
757
|
+
onDone( json );
|
|
758
|
+
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Serializes a userData.
|
|
768
|
+
*
|
|
769
|
+
* @param {THREE.Object3D|THREE.Material|THREE.BufferGeometry|THREE.AnimationClip} object
|
|
770
|
+
* @param {Object} objectDef
|
|
771
|
+
*/
|
|
772
|
+
serializeUserData( object, objectDef ) {
|
|
773
|
+
|
|
774
|
+
if ( Object.keys( object.userData ).length === 0 ) return;
|
|
775
|
+
|
|
776
|
+
const options = this.options;
|
|
777
|
+
const extensionsUsed = this.extensionsUsed;
|
|
778
|
+
|
|
779
|
+
try {
|
|
780
|
+
|
|
781
|
+
const json = JSON.parse( JSON.stringify( object.userData ) );
|
|
782
|
+
|
|
783
|
+
if ( options.includeCustomExtensions && json.gltfExtensions ) {
|
|
784
|
+
|
|
785
|
+
if ( objectDef.extensions === undefined ) objectDef.extensions = {};
|
|
786
|
+
|
|
787
|
+
for ( const extensionName in json.gltfExtensions ) {
|
|
788
|
+
|
|
789
|
+
objectDef.extensions[ extensionName ] = json.gltfExtensions[ extensionName ];
|
|
790
|
+
extensionsUsed[ extensionName ] = true;
|
|
791
|
+
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
delete json.gltfExtensions;
|
|
795
|
+
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
if ( Object.keys( json ).length > 0 ) objectDef.extras = json;
|
|
799
|
+
|
|
800
|
+
} catch ( error ) {
|
|
801
|
+
|
|
802
|
+
console.warn( 'THREE.GLTFExporter: userData of \'' + object.name + '\' ' +
|
|
803
|
+
'won\'t be serialized because of JSON.stringify error - ' + error.message );
|
|
804
|
+
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* Returns ids for buffer attributes.
|
|
811
|
+
*
|
|
812
|
+
* @param {Object} attribute
|
|
813
|
+
* @param {boolean} [isRelativeCopy=false]
|
|
814
|
+
* @return {number} An integer
|
|
815
|
+
*/
|
|
816
|
+
getUID( attribute, isRelativeCopy = false ) {
|
|
817
|
+
|
|
818
|
+
if ( this.uids.has( attribute ) === false ) {
|
|
819
|
+
|
|
820
|
+
const uids = new Map();
|
|
821
|
+
|
|
822
|
+
uids.set( true, this.uid ++ );
|
|
823
|
+
uids.set( false, this.uid ++ );
|
|
824
|
+
|
|
825
|
+
this.uids.set( attribute, uids );
|
|
826
|
+
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
const uids = this.uids.get( attribute );
|
|
830
|
+
|
|
831
|
+
return uids.get( isRelativeCopy );
|
|
832
|
+
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* Checks if normal attribute values are normalized.
|
|
837
|
+
*
|
|
838
|
+
* @param {BufferAttribute} normal
|
|
839
|
+
* @returns {boolean}
|
|
840
|
+
*/
|
|
841
|
+
isNormalizedNormalAttribute( normal ) {
|
|
842
|
+
|
|
843
|
+
const cache = this.cache;
|
|
844
|
+
|
|
845
|
+
if ( cache.attributesNormalized.has( normal ) ) return false;
|
|
846
|
+
|
|
847
|
+
const v = new Vector3();
|
|
848
|
+
|
|
849
|
+
for ( let i = 0, il = normal.count; i < il; i ++ ) {
|
|
850
|
+
|
|
851
|
+
// 0.0005 is from glTF-validator
|
|
852
|
+
if ( Math.abs( v.fromBufferAttribute( normal, i ).length() - 1.0 ) > 0.0005 ) return false;
|
|
853
|
+
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
return true;
|
|
857
|
+
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
/**
|
|
861
|
+
* Creates normalized normal buffer attribute.
|
|
862
|
+
*
|
|
863
|
+
* @param {BufferAttribute} normal
|
|
864
|
+
* @returns {BufferAttribute}
|
|
865
|
+
*
|
|
866
|
+
*/
|
|
867
|
+
createNormalizedNormalAttribute( normal ) {
|
|
868
|
+
|
|
869
|
+
const cache = this.cache;
|
|
870
|
+
|
|
871
|
+
if ( cache.attributesNormalized.has( normal ) ) return cache.attributesNormalized.get( normal );
|
|
872
|
+
|
|
873
|
+
const attribute = normal.clone();
|
|
874
|
+
const v = new Vector3();
|
|
875
|
+
|
|
876
|
+
for ( let i = 0, il = attribute.count; i < il; i ++ ) {
|
|
877
|
+
|
|
878
|
+
v.fromBufferAttribute( attribute, i );
|
|
879
|
+
|
|
880
|
+
if ( v.x === 0 && v.y === 0 && v.z === 0 ) {
|
|
881
|
+
|
|
882
|
+
// if values can't be normalized set (1, 0, 0)
|
|
883
|
+
v.setX( 1.0 );
|
|
884
|
+
|
|
885
|
+
} else {
|
|
886
|
+
|
|
887
|
+
v.normalize();
|
|
888
|
+
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
attribute.setXYZ( i, v.x, v.y, v.z );
|
|
892
|
+
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
cache.attributesNormalized.set( normal, attribute );
|
|
896
|
+
|
|
897
|
+
return attribute;
|
|
898
|
+
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* Applies a texture transform, if present, to the map definition. Requires
|
|
903
|
+
* the KHR_texture_transform extension.
|
|
904
|
+
*
|
|
905
|
+
* @param {Object} mapDef
|
|
906
|
+
* @param {THREE.Texture} texture
|
|
907
|
+
*/
|
|
908
|
+
applyTextureTransform( mapDef, texture ) {
|
|
909
|
+
|
|
910
|
+
let didTransform = false;
|
|
911
|
+
const transformDef = {};
|
|
912
|
+
|
|
913
|
+
if ( texture.offset.x !== 0 || texture.offset.y !== 0 ) {
|
|
914
|
+
|
|
915
|
+
transformDef.offset = texture.offset.toArray();
|
|
916
|
+
didTransform = true;
|
|
917
|
+
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
if ( texture.rotation !== 0 ) {
|
|
921
|
+
|
|
922
|
+
transformDef.rotation = texture.rotation;
|
|
923
|
+
didTransform = true;
|
|
924
|
+
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
if ( texture.repeat.x !== 1 || texture.repeat.y !== 1 ) {
|
|
928
|
+
|
|
929
|
+
transformDef.scale = texture.repeat.toArray();
|
|
930
|
+
didTransform = true;
|
|
931
|
+
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
if ( didTransform ) {
|
|
935
|
+
|
|
936
|
+
mapDef.extensions = mapDef.extensions || {};
|
|
937
|
+
mapDef.extensions[ 'KHR_texture_transform' ] = transformDef;
|
|
938
|
+
this.extensionsUsed[ 'KHR_texture_transform' ] = true;
|
|
939
|
+
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
async buildMetalRoughTextureAsync( metalnessMap, roughnessMap ) {
|
|
945
|
+
|
|
946
|
+
if ( metalnessMap === roughnessMap ) return metalnessMap;
|
|
947
|
+
|
|
948
|
+
function getEncodingConversion( map ) {
|
|
949
|
+
|
|
950
|
+
if ( map.colorSpace === SRGBColorSpace ) {
|
|
951
|
+
|
|
952
|
+
return function SRGBToLinear( c ) {
|
|
953
|
+
|
|
954
|
+
return ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );
|
|
955
|
+
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
return function LinearToLinear( c ) {
|
|
961
|
+
|
|
962
|
+
return c;
|
|
963
|
+
|
|
964
|
+
};
|
|
965
|
+
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
if ( metalnessMap instanceof CompressedTexture ) {
|
|
969
|
+
|
|
970
|
+
metalnessMap = await this.decompressTextureAsync( metalnessMap );
|
|
971
|
+
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
if ( roughnessMap instanceof CompressedTexture ) {
|
|
975
|
+
|
|
976
|
+
roughnessMap = await this.decompressTextureAsync( roughnessMap );
|
|
977
|
+
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
const metalness = metalnessMap ? metalnessMap.image : null;
|
|
981
|
+
const roughness = roughnessMap ? roughnessMap.image : null;
|
|
982
|
+
|
|
983
|
+
const width = Math.max( metalness ? metalness.width : 0, roughness ? roughness.width : 0 );
|
|
984
|
+
const height = Math.max( metalness ? metalness.height : 0, roughness ? roughness.height : 0 );
|
|
985
|
+
|
|
986
|
+
const canvas = getCanvas();
|
|
987
|
+
canvas.width = width;
|
|
988
|
+
canvas.height = height;
|
|
989
|
+
|
|
990
|
+
const context = canvas.getContext( '2d', {
|
|
991
|
+
willReadFrequently: true,
|
|
992
|
+
} );
|
|
993
|
+
context.fillStyle = '#00ffff';
|
|
994
|
+
context.fillRect( 0, 0, width, height );
|
|
995
|
+
|
|
996
|
+
const composite = context.getImageData( 0, 0, width, height );
|
|
997
|
+
|
|
998
|
+
if ( metalness ) {
|
|
999
|
+
|
|
1000
|
+
context.drawImage( metalness, 0, 0, width, height );
|
|
1001
|
+
|
|
1002
|
+
const convert = getEncodingConversion( metalnessMap );
|
|
1003
|
+
const data = context.getImageData( 0, 0, width, height ).data;
|
|
1004
|
+
|
|
1005
|
+
for ( let i = 2; i < data.length; i += 4 ) {
|
|
1006
|
+
|
|
1007
|
+
composite.data[ i ] = convert( data[ i ] / 256 ) * 256;
|
|
1008
|
+
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
if ( roughness ) {
|
|
1014
|
+
|
|
1015
|
+
context.drawImage( roughness, 0, 0, width, height );
|
|
1016
|
+
|
|
1017
|
+
const convert = getEncodingConversion( roughnessMap );
|
|
1018
|
+
const data = context.getImageData( 0, 0, width, height ).data;
|
|
1019
|
+
|
|
1020
|
+
for ( let i = 1; i < data.length; i += 4 ) {
|
|
1021
|
+
|
|
1022
|
+
composite.data[ i ] = convert( data[ i ] / 256 ) * 256;
|
|
1023
|
+
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
context.putImageData( composite, 0, 0 );
|
|
1029
|
+
|
|
1030
|
+
//
|
|
1031
|
+
|
|
1032
|
+
const reference = metalnessMap || roughnessMap;
|
|
1033
|
+
|
|
1034
|
+
const texture = reference.clone();
|
|
1035
|
+
|
|
1036
|
+
texture.source = new TextureSource( canvas );
|
|
1037
|
+
texture.colorSpace = NoColorSpace;
|
|
1038
|
+
texture.channel = ( metalnessMap || roughnessMap ).channel;
|
|
1039
|
+
|
|
1040
|
+
if ( metalnessMap && roughnessMap && metalnessMap.channel !== roughnessMap.channel ) {
|
|
1041
|
+
|
|
1042
|
+
console.warn( 'THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match.' );
|
|
1043
|
+
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
console.warn( 'THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.' );
|
|
1047
|
+
|
|
1048
|
+
return texture;
|
|
1049
|
+
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* Builds a copy of the given normal map with the red and/or green channels
|
|
1055
|
+
* inverted (`color = 255 - color`). This is used to bake the sign of
|
|
1056
|
+
* `material.normalScale` and the tangent-space convention into the texture,
|
|
1057
|
+
* since glTF only supports OpenGL-style normal maps with a univariate,
|
|
1058
|
+
* positive scale.
|
|
1059
|
+
*
|
|
1060
|
+
* @param {THREE.Texture} normalMap The source normal map.
|
|
1061
|
+
* @param {boolean} flipX Whether to invert the red channel (normal X).
|
|
1062
|
+
* @param {boolean} flipY Whether to invert the green channel (normal Y).
|
|
1063
|
+
* @return {Promise<THREE.Texture>} The derived normal map texture.
|
|
1064
|
+
*/
|
|
1065
|
+
async buildNormalMapTextureAsync( normalMap, flipX, flipY ) {
|
|
1066
|
+
|
|
1067
|
+
if ( normalMap instanceof CompressedTexture ) {
|
|
1068
|
+
|
|
1069
|
+
normalMap = await this.decompressTextureAsync( normalMap );
|
|
1070
|
+
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
const image = normalMap.image;
|
|
1074
|
+
|
|
1075
|
+
const canvas = getCanvas();
|
|
1076
|
+
canvas.width = image.width;
|
|
1077
|
+
canvas.height = image.height;
|
|
1078
|
+
|
|
1079
|
+
const context = canvas.getContext( '2d', {
|
|
1080
|
+
willReadFrequently: true,
|
|
1081
|
+
} );
|
|
1082
|
+
|
|
1083
|
+
context.drawImage( image, 0, 0, canvas.width, canvas.height );
|
|
1084
|
+
|
|
1085
|
+
const imageData = context.getImageData( 0, 0, canvas.width, canvas.height );
|
|
1086
|
+
const data = imageData.data;
|
|
1087
|
+
|
|
1088
|
+
for ( let i = 0; i < data.length; i += 4 ) {
|
|
1089
|
+
|
|
1090
|
+
if ( flipX ) data[ i + 0 ] = 255 - data[ i + 0 ];
|
|
1091
|
+
if ( flipY ) data[ i + 1 ] = 255 - data[ i + 1 ];
|
|
1092
|
+
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
context.putImageData( imageData, 0, 0 );
|
|
1096
|
+
|
|
1097
|
+
const texture = normalMap.clone();
|
|
1098
|
+
texture.source = new TextureSource( canvas );
|
|
1099
|
+
|
|
1100
|
+
return texture;
|
|
1101
|
+
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
async decompressTextureAsync( texture, maxTextureSize = Infinity ) {
|
|
1105
|
+
|
|
1106
|
+
if ( this.textureUtils === null ) {
|
|
1107
|
+
|
|
1108
|
+
throw new Error( 'THREE.GLTFExporter: setTextureUtils() must be called to process compressed textures.' );
|
|
1109
|
+
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
return await this.textureUtils.decompress( texture, maxTextureSize );
|
|
1113
|
+
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
/**
|
|
1117
|
+
* Process a buffer to append to the default one.
|
|
1118
|
+
* @param {ArrayBuffer} buffer
|
|
1119
|
+
* @return {0}
|
|
1120
|
+
*/
|
|
1121
|
+
processBuffer( buffer ) {
|
|
1122
|
+
|
|
1123
|
+
const json = this.json;
|
|
1124
|
+
const buffers = this.buffers;
|
|
1125
|
+
|
|
1126
|
+
if ( ! json.buffers ) json.buffers = [ { byteLength: 0 } ];
|
|
1127
|
+
|
|
1128
|
+
// All buffers are merged before export.
|
|
1129
|
+
buffers.push( buffer );
|
|
1130
|
+
|
|
1131
|
+
return 0;
|
|
1132
|
+
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
/**
|
|
1136
|
+
* Process and generate a BufferView
|
|
1137
|
+
* @param {BufferAttribute} attribute
|
|
1138
|
+
* @param {number} componentType
|
|
1139
|
+
* @param {number} start
|
|
1140
|
+
* @param {number} count
|
|
1141
|
+
* @param {number} [target] Target usage of the BufferView
|
|
1142
|
+
* @return {Object}
|
|
1143
|
+
*/
|
|
1144
|
+
processBufferView( attribute, componentType, start, count, target ) {
|
|
1145
|
+
|
|
1146
|
+
const json = this.json;
|
|
1147
|
+
|
|
1148
|
+
if ( ! json.bufferViews ) json.bufferViews = [];
|
|
1149
|
+
|
|
1150
|
+
// Create a new dataview and dump the attribute's array into it
|
|
1151
|
+
|
|
1152
|
+
let componentSize;
|
|
1153
|
+
|
|
1154
|
+
switch ( componentType ) {
|
|
1155
|
+
|
|
1156
|
+
case WEBGL_CONSTANTS.BYTE:
|
|
1157
|
+
case WEBGL_CONSTANTS.UNSIGNED_BYTE:
|
|
1158
|
+
|
|
1159
|
+
componentSize = 1;
|
|
1160
|
+
|
|
1161
|
+
break;
|
|
1162
|
+
|
|
1163
|
+
case WEBGL_CONSTANTS.SHORT:
|
|
1164
|
+
case WEBGL_CONSTANTS.UNSIGNED_SHORT:
|
|
1165
|
+
|
|
1166
|
+
componentSize = 2;
|
|
1167
|
+
|
|
1168
|
+
break;
|
|
1169
|
+
|
|
1170
|
+
default:
|
|
1171
|
+
|
|
1172
|
+
componentSize = 4;
|
|
1173
|
+
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
let byteStride = attribute.itemSize * componentSize;
|
|
1177
|
+
|
|
1178
|
+
if ( target === WEBGL_CONSTANTS.ARRAY_BUFFER ) {
|
|
1179
|
+
|
|
1180
|
+
// Each element of a vertex attribute MUST be aligned to 4-byte boundaries
|
|
1181
|
+
// inside a bufferView
|
|
1182
|
+
byteStride = Math.ceil( byteStride / 4 ) * 4;
|
|
1183
|
+
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
const byteLength = getPaddedBufferSize( count * byteStride );
|
|
1187
|
+
const dataView = new DataView( new ArrayBuffer( byteLength ) );
|
|
1188
|
+
let offset = 0;
|
|
1189
|
+
|
|
1190
|
+
for ( let i = start; i < start + count; i ++ ) {
|
|
1191
|
+
|
|
1192
|
+
for ( let a = 0; a < attribute.itemSize; a ++ ) {
|
|
1193
|
+
|
|
1194
|
+
let value;
|
|
1195
|
+
|
|
1196
|
+
if ( attribute.itemSize > 4 ) {
|
|
1197
|
+
|
|
1198
|
+
// no support for interleaved data for itemSize > 4
|
|
1199
|
+
|
|
1200
|
+
value = attribute.array[ i * attribute.itemSize + a ];
|
|
1201
|
+
|
|
1202
|
+
} else {
|
|
1203
|
+
|
|
1204
|
+
if ( a === 0 ) value = attribute.getX( i );
|
|
1205
|
+
else if ( a === 1 ) value = attribute.getY( i );
|
|
1206
|
+
else if ( a === 2 ) value = attribute.getZ( i );
|
|
1207
|
+
else if ( a === 3 ) value = attribute.getW( i );
|
|
1208
|
+
|
|
1209
|
+
if ( attribute.normalized === true ) {
|
|
1210
|
+
|
|
1211
|
+
value = MathUtils.normalize( value, attribute.array );
|
|
1212
|
+
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
if ( componentType === WEBGL_CONSTANTS.FLOAT ) {
|
|
1218
|
+
|
|
1219
|
+
dataView.setFloat32( offset, value, true );
|
|
1220
|
+
|
|
1221
|
+
} else if ( componentType === WEBGL_CONSTANTS.INT ) {
|
|
1222
|
+
|
|
1223
|
+
dataView.setInt32( offset, value, true );
|
|
1224
|
+
|
|
1225
|
+
} else if ( componentType === WEBGL_CONSTANTS.UNSIGNED_INT ) {
|
|
1226
|
+
|
|
1227
|
+
dataView.setUint32( offset, value, true );
|
|
1228
|
+
|
|
1229
|
+
} else if ( componentType === WEBGL_CONSTANTS.SHORT ) {
|
|
1230
|
+
|
|
1231
|
+
dataView.setInt16( offset, value, true );
|
|
1232
|
+
|
|
1233
|
+
} else if ( componentType === WEBGL_CONSTANTS.UNSIGNED_SHORT ) {
|
|
1234
|
+
|
|
1235
|
+
dataView.setUint16( offset, value, true );
|
|
1236
|
+
|
|
1237
|
+
} else if ( componentType === WEBGL_CONSTANTS.BYTE ) {
|
|
1238
|
+
|
|
1239
|
+
dataView.setInt8( offset, value );
|
|
1240
|
+
|
|
1241
|
+
} else if ( componentType === WEBGL_CONSTANTS.UNSIGNED_BYTE ) {
|
|
1242
|
+
|
|
1243
|
+
dataView.setUint8( offset, value );
|
|
1244
|
+
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
offset += componentSize;
|
|
1248
|
+
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
if ( ( offset % byteStride ) !== 0 ) {
|
|
1252
|
+
|
|
1253
|
+
offset += byteStride - ( offset % byteStride );
|
|
1254
|
+
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
const bufferViewDef = {
|
|
1260
|
+
|
|
1261
|
+
buffer: this.processBuffer( dataView.buffer ),
|
|
1262
|
+
byteOffset: this.byteOffset,
|
|
1263
|
+
byteLength: byteLength
|
|
1264
|
+
|
|
1265
|
+
};
|
|
1266
|
+
|
|
1267
|
+
if ( target !== undefined ) bufferViewDef.target = target;
|
|
1268
|
+
|
|
1269
|
+
if ( target === WEBGL_CONSTANTS.ARRAY_BUFFER ) {
|
|
1270
|
+
|
|
1271
|
+
// Only define byteStride for vertex attributes.
|
|
1272
|
+
bufferViewDef.byteStride = byteStride;
|
|
1273
|
+
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
this.byteOffset += byteLength;
|
|
1277
|
+
|
|
1278
|
+
json.bufferViews.push( bufferViewDef );
|
|
1279
|
+
|
|
1280
|
+
// @TODO Merge bufferViews where possible.
|
|
1281
|
+
const output = {
|
|
1282
|
+
|
|
1283
|
+
id: json.bufferViews.length - 1,
|
|
1284
|
+
byteLength: 0
|
|
1285
|
+
|
|
1286
|
+
};
|
|
1287
|
+
|
|
1288
|
+
return output;
|
|
1289
|
+
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
/**
|
|
1293
|
+
* Process and generate a BufferView from an image Blob.
|
|
1294
|
+
* @param {Blob} blob
|
|
1295
|
+
* @return {Promise<number>} An integer
|
|
1296
|
+
*/
|
|
1297
|
+
processBufferViewImage( blob ) {
|
|
1298
|
+
|
|
1299
|
+
const writer = this;
|
|
1300
|
+
const json = writer.json;
|
|
1301
|
+
|
|
1302
|
+
if ( ! json.bufferViews ) json.bufferViews = [];
|
|
1303
|
+
|
|
1304
|
+
return new Promise( function ( resolve ) {
|
|
1305
|
+
|
|
1306
|
+
const reader = new FileReader();
|
|
1307
|
+
reader.readAsArrayBuffer( blob );
|
|
1308
|
+
reader.onloadend = function () {
|
|
1309
|
+
|
|
1310
|
+
const buffer = getPaddedArrayBuffer( reader.result );
|
|
1311
|
+
|
|
1312
|
+
const bufferViewDef = {
|
|
1313
|
+
buffer: writer.processBuffer( buffer ),
|
|
1314
|
+
byteOffset: writer.byteOffset,
|
|
1315
|
+
byteLength: buffer.byteLength
|
|
1316
|
+
};
|
|
1317
|
+
|
|
1318
|
+
writer.byteOffset += buffer.byteLength;
|
|
1319
|
+
resolve( json.bufferViews.push( bufferViewDef ) - 1 );
|
|
1320
|
+
|
|
1321
|
+
};
|
|
1322
|
+
|
|
1323
|
+
} );
|
|
1324
|
+
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
/**
|
|
1328
|
+
* Process attribute to generate an accessor
|
|
1329
|
+
* @param {BufferAttribute} attribute Attribute to process
|
|
1330
|
+
* @param {?BufferGeometry} [geometry] Geometry used for truncated draw range
|
|
1331
|
+
* @param {number} [start=0]
|
|
1332
|
+
* @param {number} [count=Infinity]
|
|
1333
|
+
* @return {?number} Index of the processed accessor on the "accessors" array
|
|
1334
|
+
*/
|
|
1335
|
+
processAccessor( attribute, geometry, start, count ) {
|
|
1336
|
+
|
|
1337
|
+
const json = this.json;
|
|
1338
|
+
|
|
1339
|
+
const types = {
|
|
1340
|
+
|
|
1341
|
+
1: 'SCALAR',
|
|
1342
|
+
2: 'VEC2',
|
|
1343
|
+
3: 'VEC3',
|
|
1344
|
+
4: 'VEC4',
|
|
1345
|
+
9: 'MAT3',
|
|
1346
|
+
16: 'MAT4'
|
|
1347
|
+
|
|
1348
|
+
};
|
|
1349
|
+
|
|
1350
|
+
let componentType;
|
|
1351
|
+
|
|
1352
|
+
// Detect the component type of the attribute array
|
|
1353
|
+
if ( attribute.array.constructor === Float32Array ) {
|
|
1354
|
+
|
|
1355
|
+
componentType = WEBGL_CONSTANTS.FLOAT;
|
|
1356
|
+
|
|
1357
|
+
} else if ( attribute.array.constructor === Int32Array ) {
|
|
1358
|
+
|
|
1359
|
+
componentType = WEBGL_CONSTANTS.INT;
|
|
1360
|
+
|
|
1361
|
+
} else if ( attribute.array.constructor === Uint32Array ) {
|
|
1362
|
+
|
|
1363
|
+
componentType = WEBGL_CONSTANTS.UNSIGNED_INT;
|
|
1364
|
+
|
|
1365
|
+
} else if ( attribute.array.constructor === Int16Array ) {
|
|
1366
|
+
|
|
1367
|
+
componentType = WEBGL_CONSTANTS.SHORT;
|
|
1368
|
+
|
|
1369
|
+
} else if ( attribute.array.constructor === Uint16Array ) {
|
|
1370
|
+
|
|
1371
|
+
componentType = WEBGL_CONSTANTS.UNSIGNED_SHORT;
|
|
1372
|
+
|
|
1373
|
+
} else if ( attribute.array.constructor === Int8Array ) {
|
|
1374
|
+
|
|
1375
|
+
componentType = WEBGL_CONSTANTS.BYTE;
|
|
1376
|
+
|
|
1377
|
+
} else if ( attribute.array.constructor === Uint8Array ) {
|
|
1378
|
+
|
|
1379
|
+
componentType = WEBGL_CONSTANTS.UNSIGNED_BYTE;
|
|
1380
|
+
|
|
1381
|
+
} else {
|
|
1382
|
+
|
|
1383
|
+
throw new Error( 'THREE.GLTFExporter: Unsupported bufferAttribute component type: ' + attribute.array.constructor.name );
|
|
1384
|
+
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
if ( start === undefined ) start = 0;
|
|
1388
|
+
if ( count === undefined || count === Infinity ) count = attribute.count;
|
|
1389
|
+
|
|
1390
|
+
// Skip creating an accessor if the attribute doesn't have data to export
|
|
1391
|
+
if ( count === 0 ) return null;
|
|
1392
|
+
|
|
1393
|
+
const minMax = getMinMax( attribute, start, count );
|
|
1394
|
+
let bufferViewTarget;
|
|
1395
|
+
|
|
1396
|
+
// If geometry isn't provided, don't infer the target usage of the bufferView. For
|
|
1397
|
+
// animation samplers, target must not be set.
|
|
1398
|
+
if ( geometry !== undefined ) {
|
|
1399
|
+
|
|
1400
|
+
bufferViewTarget = attribute === geometry.index ? WEBGL_CONSTANTS.ELEMENT_ARRAY_BUFFER : WEBGL_CONSTANTS.ARRAY_BUFFER;
|
|
1401
|
+
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
const bufferView = this.processBufferView( attribute, componentType, start, count, bufferViewTarget );
|
|
1405
|
+
|
|
1406
|
+
const accessorDef = {
|
|
1407
|
+
|
|
1408
|
+
bufferView: bufferView.id,
|
|
1409
|
+
byteOffset: bufferView.byteOffset,
|
|
1410
|
+
componentType: componentType,
|
|
1411
|
+
count: count,
|
|
1412
|
+
max: minMax.max,
|
|
1413
|
+
min: minMax.min,
|
|
1414
|
+
type: types[ attribute.itemSize ]
|
|
1415
|
+
|
|
1416
|
+
};
|
|
1417
|
+
|
|
1418
|
+
if ( attribute.normalized === true ) accessorDef.normalized = true;
|
|
1419
|
+
if ( ! json.accessors ) json.accessors = [];
|
|
1420
|
+
|
|
1421
|
+
return json.accessors.push( accessorDef ) - 1;
|
|
1422
|
+
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
/**
|
|
1426
|
+
* Process image
|
|
1427
|
+
* @param {Image} image to process
|
|
1428
|
+
* @param {number} format Identifier of the format (RGBAFormat)
|
|
1429
|
+
* @param {boolean} flipY before writing out the image
|
|
1430
|
+
* @param {string} mimeType export format
|
|
1431
|
+
* @return {number} Index of the processed texture in the "images" array
|
|
1432
|
+
*/
|
|
1433
|
+
processImage( image, format, flipY, mimeType = 'image/png' ) {
|
|
1434
|
+
|
|
1435
|
+
if ( image !== null ) {
|
|
1436
|
+
|
|
1437
|
+
const writer = this;
|
|
1438
|
+
const cache = writer.cache;
|
|
1439
|
+
const json = writer.json;
|
|
1440
|
+
const options = writer.options;
|
|
1441
|
+
const pending = writer.pending;
|
|
1442
|
+
|
|
1443
|
+
if ( ! cache.images.has( image ) ) cache.images.set( image, {} );
|
|
1444
|
+
|
|
1445
|
+
const cachedImages = cache.images.get( image );
|
|
1446
|
+
|
|
1447
|
+
const key = mimeType + ':flipY/' + flipY.toString();
|
|
1448
|
+
|
|
1449
|
+
if ( cachedImages[ key ] !== undefined ) return cachedImages[ key ];
|
|
1450
|
+
|
|
1451
|
+
if ( ! json.images ) json.images = [];
|
|
1452
|
+
|
|
1453
|
+
const imageDef = { mimeType: mimeType };
|
|
1454
|
+
|
|
1455
|
+
const canvas = getCanvas();
|
|
1456
|
+
|
|
1457
|
+
canvas.width = Math.min( image.width, options.maxTextureSize );
|
|
1458
|
+
canvas.height = Math.min( image.height, options.maxTextureSize );
|
|
1459
|
+
|
|
1460
|
+
const ctx = canvas.getContext( '2d', {
|
|
1461
|
+
willReadFrequently: true,
|
|
1462
|
+
} );
|
|
1463
|
+
|
|
1464
|
+
if ( flipY === true ) {
|
|
1465
|
+
|
|
1466
|
+
ctx.translate( 0, canvas.height );
|
|
1467
|
+
ctx.scale( 1, - 1 );
|
|
1468
|
+
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
if ( image.data !== undefined ) { // THREE.DataTexture
|
|
1472
|
+
|
|
1473
|
+
if ( format !== RGBAFormat ) {
|
|
1474
|
+
|
|
1475
|
+
console.error( 'GLTFExporter: Only RGBAFormat is supported.', format );
|
|
1476
|
+
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
if ( image.width > options.maxTextureSize || image.height > options.maxTextureSize ) {
|
|
1480
|
+
|
|
1481
|
+
console.warn( 'GLTFExporter: Image size is bigger than maxTextureSize', image );
|
|
1482
|
+
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
const data = new Uint8ClampedArray( image.height * image.width * 4 );
|
|
1486
|
+
|
|
1487
|
+
for ( let i = 0; i < data.length; i += 4 ) {
|
|
1488
|
+
|
|
1489
|
+
data[ i + 0 ] = image.data[ i + 0 ];
|
|
1490
|
+
data[ i + 1 ] = image.data[ i + 1 ];
|
|
1491
|
+
data[ i + 2 ] = image.data[ i + 2 ];
|
|
1492
|
+
data[ i + 3 ] = image.data[ i + 3 ];
|
|
1493
|
+
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
ctx.putImageData( new ImageData( data, image.width, image.height ), 0, 0 );
|
|
1497
|
+
|
|
1498
|
+
} else {
|
|
1499
|
+
|
|
1500
|
+
if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||
|
|
1501
|
+
( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||
|
|
1502
|
+
( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ||
|
|
1503
|
+
( typeof OffscreenCanvas !== 'undefined' && image instanceof OffscreenCanvas ) ) {
|
|
1504
|
+
|
|
1505
|
+
ctx.drawImage( image, 0, 0, canvas.width, canvas.height );
|
|
1506
|
+
|
|
1507
|
+
} else {
|
|
1508
|
+
|
|
1509
|
+
throw new Error( 'THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.' );
|
|
1510
|
+
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
if ( options.binary === true ) {
|
|
1516
|
+
|
|
1517
|
+
pending.push(
|
|
1518
|
+
|
|
1519
|
+
getToBlobPromise( canvas, mimeType )
|
|
1520
|
+
.then( blob => writer.processBufferViewImage( blob ) )
|
|
1521
|
+
.then( bufferViewIndex => {
|
|
1522
|
+
|
|
1523
|
+
imageDef.bufferView = bufferViewIndex;
|
|
1524
|
+
|
|
1525
|
+
} )
|
|
1526
|
+
|
|
1527
|
+
);
|
|
1528
|
+
|
|
1529
|
+
} else {
|
|
1530
|
+
|
|
1531
|
+
imageDef.uri = ImageUtils.getDataURL( canvas, mimeType );
|
|
1532
|
+
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
const index = json.images.push( imageDef ) - 1;
|
|
1536
|
+
cachedImages[ key ] = index;
|
|
1537
|
+
return index;
|
|
1538
|
+
|
|
1539
|
+
} else {
|
|
1540
|
+
|
|
1541
|
+
throw new Error( 'THREE.GLTFExporter: No valid image data found. Unable to process texture.' );
|
|
1542
|
+
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
/**
|
|
1548
|
+
* Process sampler
|
|
1549
|
+
* @param {Texture} map Texture to process
|
|
1550
|
+
* @return {number} Index of the processed texture in the "samplers" array
|
|
1551
|
+
*/
|
|
1552
|
+
processSampler( map ) {
|
|
1553
|
+
|
|
1554
|
+
const json = this.json;
|
|
1555
|
+
|
|
1556
|
+
if ( ! json.samplers ) json.samplers = [];
|
|
1557
|
+
|
|
1558
|
+
const samplerDef = {
|
|
1559
|
+
magFilter: THREE_TO_WEBGL[ map.magFilter ],
|
|
1560
|
+
minFilter: THREE_TO_WEBGL[ map.minFilter ],
|
|
1561
|
+
wrapS: THREE_TO_WEBGL[ map.wrapS ],
|
|
1562
|
+
wrapT: THREE_TO_WEBGL[ map.wrapT ]
|
|
1563
|
+
};
|
|
1564
|
+
|
|
1565
|
+
return json.samplers.push( samplerDef ) - 1;
|
|
1566
|
+
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
/**
|
|
1570
|
+
* Process texture
|
|
1571
|
+
* @param {Texture} map Map to process
|
|
1572
|
+
* @return {Promise<number>} Index of the processed texture in the "textures" array
|
|
1573
|
+
*/
|
|
1574
|
+
async processTextureAsync( map ) {
|
|
1575
|
+
|
|
1576
|
+
const writer = this;
|
|
1577
|
+
const options = writer.options;
|
|
1578
|
+
const cache = this.cache;
|
|
1579
|
+
const json = this.json;
|
|
1580
|
+
|
|
1581
|
+
if ( cache.textures.has( map ) ) return cache.textures.get( map );
|
|
1582
|
+
|
|
1583
|
+
if ( ! json.textures ) json.textures = [];
|
|
1584
|
+
|
|
1585
|
+
// make non-readable textures (e.g. CompressedTexture) readable by blitting them into a new texture
|
|
1586
|
+
if ( map instanceof CompressedTexture ) {
|
|
1587
|
+
|
|
1588
|
+
map = await this.decompressTextureAsync( map, options.maxTextureSize );
|
|
1589
|
+
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
const mimeType = map.userData.mimeType;
|
|
1593
|
+
|
|
1594
|
+
const imageIndex = this.processImage( map.image, map.format, map.flipY, mimeType );
|
|
1595
|
+
|
|
1596
|
+
const textureDef = {
|
|
1597
|
+
sampler: this.processSampler( map )
|
|
1598
|
+
};
|
|
1599
|
+
|
|
1600
|
+
if ( mimeType === 'image/webp' ) {
|
|
1601
|
+
|
|
1602
|
+
textureDef.extensions = textureDef.extensions || {};
|
|
1603
|
+
textureDef.extensions[ 'EXT_texture_webp' ] = {
|
|
1604
|
+
source: imageIndex
|
|
1605
|
+
};
|
|
1606
|
+
|
|
1607
|
+
this.extensionsUsed[ 'EXT_texture_webp' ] = true;
|
|
1608
|
+
this.extensionsRequired[ 'EXT_texture_webp' ] = true;
|
|
1609
|
+
|
|
1610
|
+
} else {
|
|
1611
|
+
|
|
1612
|
+
textureDef.source = imageIndex;
|
|
1613
|
+
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
if ( map.name ) textureDef.name = map.name;
|
|
1617
|
+
|
|
1618
|
+
await this._invokeAllAsync( async function ( ext ) {
|
|
1619
|
+
|
|
1620
|
+
ext.writeTexture && await ext.writeTexture( map, textureDef );
|
|
1621
|
+
|
|
1622
|
+
} );
|
|
1623
|
+
|
|
1624
|
+
const index = json.textures.push( textureDef ) - 1;
|
|
1625
|
+
cache.textures.set( map, index );
|
|
1626
|
+
return index;
|
|
1627
|
+
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
/**
|
|
1631
|
+
* Process material
|
|
1632
|
+
* @param {THREE.Material} material Material to process
|
|
1633
|
+
* @param {THREE.BufferGeometry} [geometry] Geometry the material is used with.
|
|
1634
|
+
* @return {Promise<?number>} Index of the processed material in the "materials" array
|
|
1635
|
+
*/
|
|
1636
|
+
async processMaterialAsync( material, geometry ) {
|
|
1637
|
+
|
|
1638
|
+
const cache = this.cache;
|
|
1639
|
+
const json = this.json;
|
|
1640
|
+
|
|
1641
|
+
// Whether the geometry provides explicit tangents. The exported normal map depends on
|
|
1642
|
+
// this, so it is part of the material cache key.
|
|
1643
|
+
const hasTangent = geometry !== undefined && geometry.hasAttribute( 'tangent' );
|
|
1644
|
+
const cacheKey = material.normalMap ? material.uuid + ':' + hasTangent : material.uuid;
|
|
1645
|
+
|
|
1646
|
+
if ( cache.materials.has( cacheKey ) ) return cache.materials.get( cacheKey );
|
|
1647
|
+
|
|
1648
|
+
if ( material.isShaderMaterial ) {
|
|
1649
|
+
|
|
1650
|
+
console.warn( 'GLTFExporter: THREE.ShaderMaterial not supported.' );
|
|
1651
|
+
return null;
|
|
1652
|
+
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
if ( ! json.materials ) json.materials = [];
|
|
1656
|
+
|
|
1657
|
+
// @QUESTION Should we avoid including any attribute that has the default value?
|
|
1658
|
+
const materialDef = { pbrMetallicRoughness: {} };
|
|
1659
|
+
|
|
1660
|
+
if ( material.isMeshStandardMaterial !== true && material.isMeshBasicMaterial !== true ) {
|
|
1661
|
+
|
|
1662
|
+
console.warn( 'GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.' );
|
|
1663
|
+
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
// pbrMetallicRoughness.baseColorFactor
|
|
1667
|
+
const color = material.color.toArray().concat( [ material.opacity ] );
|
|
1668
|
+
|
|
1669
|
+
if ( ! equalArray( color, [ 1, 1, 1, 1 ] ) ) {
|
|
1670
|
+
|
|
1671
|
+
materialDef.pbrMetallicRoughness.baseColorFactor = color;
|
|
1672
|
+
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
if ( material.isMeshStandardMaterial ) {
|
|
1676
|
+
|
|
1677
|
+
materialDef.pbrMetallicRoughness.metallicFactor = material.metalness;
|
|
1678
|
+
materialDef.pbrMetallicRoughness.roughnessFactor = material.roughness;
|
|
1679
|
+
|
|
1680
|
+
} else {
|
|
1681
|
+
|
|
1682
|
+
materialDef.pbrMetallicRoughness.metallicFactor = 0;
|
|
1683
|
+
materialDef.pbrMetallicRoughness.roughnessFactor = 1;
|
|
1684
|
+
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
// pbrMetallicRoughness.metallicRoughnessTexture
|
|
1688
|
+
if ( material.metalnessMap || material.roughnessMap ) {
|
|
1689
|
+
|
|
1690
|
+
const metalRoughTexture = await this.buildMetalRoughTextureAsync( material.metalnessMap, material.roughnessMap );
|
|
1691
|
+
|
|
1692
|
+
const metalRoughMapDef = {
|
|
1693
|
+
index: await this.processTextureAsync( metalRoughTexture ),
|
|
1694
|
+
texCoord: metalRoughTexture.channel
|
|
1695
|
+
};
|
|
1696
|
+
this.applyTextureTransform( metalRoughMapDef, metalRoughTexture );
|
|
1697
|
+
materialDef.pbrMetallicRoughness.metallicRoughnessTexture = metalRoughMapDef;
|
|
1698
|
+
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
// pbrMetallicRoughness.baseColorTexture
|
|
1702
|
+
if ( material.map ) {
|
|
1703
|
+
|
|
1704
|
+
const baseColorMapDef = {
|
|
1705
|
+
index: await this.processTextureAsync( material.map ),
|
|
1706
|
+
texCoord: material.map.channel
|
|
1707
|
+
};
|
|
1708
|
+
this.applyTextureTransform( baseColorMapDef, material.map );
|
|
1709
|
+
materialDef.pbrMetallicRoughness.baseColorTexture = baseColorMapDef;
|
|
1710
|
+
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
if ( material.emissive ) {
|
|
1714
|
+
|
|
1715
|
+
const emissive = material.emissive;
|
|
1716
|
+
const maxEmissiveComponent = Math.max( emissive.r, emissive.g, emissive.b );
|
|
1717
|
+
|
|
1718
|
+
if ( maxEmissiveComponent > 0 ) {
|
|
1719
|
+
|
|
1720
|
+
materialDef.emissiveFactor = material.emissive.toArray();
|
|
1721
|
+
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
// emissiveTexture
|
|
1725
|
+
if ( material.emissiveMap ) {
|
|
1726
|
+
|
|
1727
|
+
const emissiveMapDef = {
|
|
1728
|
+
index: await this.processTextureAsync( material.emissiveMap ),
|
|
1729
|
+
texCoord: material.emissiveMap.channel
|
|
1730
|
+
};
|
|
1731
|
+
this.applyTextureTransform( emissiveMapDef, material.emissiveMap );
|
|
1732
|
+
materialDef.emissiveTexture = emissiveMapDef;
|
|
1733
|
+
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
// normalTexture
|
|
1739
|
+
if ( material.normalMap ) {
|
|
1740
|
+
|
|
1741
|
+
const normalScale = material.normalScale;
|
|
1742
|
+
|
|
1743
|
+
// glTF only supports OpenGL-style normal maps with a univariate, positive scale.
|
|
1744
|
+
// A negative `normalScale` component is baked into the texture by inverting the
|
|
1745
|
+
// corresponding channel. Meshes without explicit tangents use the opposite
|
|
1746
|
+
// green-channel convention, so the green channel is inverted in that case too.
|
|
1747
|
+
//
|
|
1748
|
+
// The no-tangent green flip is the counterpart of GLTFLoader, which negates
|
|
1749
|
+
// `normalScale.y` on import for the same case.
|
|
1750
|
+
const flipX = normalScale.x < 0;
|
|
1751
|
+
const flipY = hasTangent ? normalScale.y < 0 : normalScale.y > 0;
|
|
1752
|
+
|
|
1753
|
+
let normalMap = material.normalMap;
|
|
1754
|
+
|
|
1755
|
+
if ( flipX || flipY ) {
|
|
1756
|
+
|
|
1757
|
+
if ( cache.normalMaps.has( material.normalMap ) === false ) cache.normalMaps.set( material.normalMap, {} );
|
|
1758
|
+
|
|
1759
|
+
const cachedVariants = cache.normalMaps.get( material.normalMap );
|
|
1760
|
+
const cacheKey = `${flipX}:${flipY}`;
|
|
1761
|
+
|
|
1762
|
+
if ( cachedVariants[ cacheKey ] === undefined ) {
|
|
1763
|
+
|
|
1764
|
+
cachedVariants[ cacheKey ] = await this.buildNormalMapTextureAsync( material.normalMap, flipX, flipY );
|
|
1765
|
+
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
normalMap = cachedVariants[ cacheKey ];
|
|
1769
|
+
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
const normalMapDef = {
|
|
1773
|
+
index: await this.processTextureAsync( normalMap ),
|
|
1774
|
+
texCoord: material.normalMap.channel
|
|
1775
|
+
};
|
|
1776
|
+
|
|
1777
|
+
if ( Math.abs( normalScale.x ) !== 1 ) {
|
|
1778
|
+
|
|
1779
|
+
// glTF normal scale is univariate. The magnitude of `x` is used; the sign of
|
|
1780
|
+
// both components has already been baked into the texture above.
|
|
1781
|
+
normalMapDef.scale = Math.abs( normalScale.x );
|
|
1782
|
+
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
this.applyTextureTransform( normalMapDef, material.normalMap );
|
|
1786
|
+
materialDef.normalTexture = normalMapDef;
|
|
1787
|
+
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1790
|
+
// occlusionTexture
|
|
1791
|
+
if ( material.aoMap ) {
|
|
1792
|
+
|
|
1793
|
+
const occlusionMapDef = {
|
|
1794
|
+
index: await this.processTextureAsync( material.aoMap ),
|
|
1795
|
+
texCoord: material.aoMap.channel
|
|
1796
|
+
};
|
|
1797
|
+
|
|
1798
|
+
if ( material.aoMapIntensity !== 1.0 ) {
|
|
1799
|
+
|
|
1800
|
+
occlusionMapDef.strength = material.aoMapIntensity;
|
|
1801
|
+
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
this.applyTextureTransform( occlusionMapDef, material.aoMap );
|
|
1805
|
+
materialDef.occlusionTexture = occlusionMapDef;
|
|
1806
|
+
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
// alphaMode
|
|
1810
|
+
if ( material.transparent ) {
|
|
1811
|
+
|
|
1812
|
+
materialDef.alphaMode = 'BLEND';
|
|
1813
|
+
|
|
1814
|
+
} else {
|
|
1815
|
+
|
|
1816
|
+
if ( material.alphaTest > 0.0 ) {
|
|
1817
|
+
|
|
1818
|
+
materialDef.alphaMode = 'MASK';
|
|
1819
|
+
materialDef.alphaCutoff = material.alphaTest;
|
|
1820
|
+
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
// doubleSided
|
|
1826
|
+
if ( material.side === DoubleSide ) materialDef.doubleSided = true;
|
|
1827
|
+
if ( material.name !== '' ) materialDef.name = material.name;
|
|
1828
|
+
|
|
1829
|
+
this.serializeUserData( material, materialDef );
|
|
1830
|
+
|
|
1831
|
+
await this._invokeAllAsync( async function ( ext ) {
|
|
1832
|
+
|
|
1833
|
+
ext.writeMaterialAsync && await ext.writeMaterialAsync( material, materialDef );
|
|
1834
|
+
|
|
1835
|
+
} );
|
|
1836
|
+
|
|
1837
|
+
const index = json.materials.push( materialDef ) - 1;
|
|
1838
|
+
cache.materials.set( cacheKey, index );
|
|
1839
|
+
return index;
|
|
1840
|
+
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
/**
|
|
1844
|
+
* Process mesh
|
|
1845
|
+
* @param {THREE.Mesh} mesh Mesh to process
|
|
1846
|
+
* @return {Promise<?number>} Index of the processed mesh in the "meshes" array
|
|
1847
|
+
*/
|
|
1848
|
+
async processMeshAsync( mesh ) {
|
|
1849
|
+
|
|
1850
|
+
const cache = this.cache;
|
|
1851
|
+
const json = this.json;
|
|
1852
|
+
|
|
1853
|
+
const meshCacheKeyParts = [ mesh.geometry.uuid ];
|
|
1854
|
+
|
|
1855
|
+
if ( Array.isArray( mesh.material ) ) {
|
|
1856
|
+
|
|
1857
|
+
for ( let i = 0, l = mesh.material.length; i < l; i ++ ) {
|
|
1858
|
+
|
|
1859
|
+
meshCacheKeyParts.push( mesh.material[ i ].uuid );
|
|
1860
|
+
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
} else {
|
|
1864
|
+
|
|
1865
|
+
meshCacheKeyParts.push( mesh.material.uuid );
|
|
1866
|
+
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
const meshCacheKey = meshCacheKeyParts.join( ':' );
|
|
1870
|
+
|
|
1871
|
+
if ( cache.meshes.has( meshCacheKey ) ) return cache.meshes.get( meshCacheKey );
|
|
1872
|
+
|
|
1873
|
+
const geometry = mesh.geometry;
|
|
1874
|
+
|
|
1875
|
+
let mode;
|
|
1876
|
+
|
|
1877
|
+
// Use the correct mode
|
|
1878
|
+
if ( mesh.isLineSegments ) {
|
|
1879
|
+
|
|
1880
|
+
mode = WEBGL_CONSTANTS.LINES;
|
|
1881
|
+
|
|
1882
|
+
} else if ( mesh.isLineLoop ) {
|
|
1883
|
+
|
|
1884
|
+
mode = WEBGL_CONSTANTS.LINE_LOOP;
|
|
1885
|
+
|
|
1886
|
+
} else if ( mesh.isLine ) {
|
|
1887
|
+
|
|
1888
|
+
mode = WEBGL_CONSTANTS.LINE_STRIP;
|
|
1889
|
+
|
|
1890
|
+
} else if ( mesh.isPoints ) {
|
|
1891
|
+
|
|
1892
|
+
mode = WEBGL_CONSTANTS.POINTS;
|
|
1893
|
+
|
|
1894
|
+
} else {
|
|
1895
|
+
|
|
1896
|
+
mode = mesh.material.wireframe ? WEBGL_CONSTANTS.LINES : WEBGL_CONSTANTS.TRIANGLES;
|
|
1897
|
+
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
const meshDef = {};
|
|
1901
|
+
const attributes = {};
|
|
1902
|
+
const primitives = [];
|
|
1903
|
+
const targets = [];
|
|
1904
|
+
|
|
1905
|
+
// Conversion between attributes names in threejs and gltf spec
|
|
1906
|
+
const nameConversion = {
|
|
1907
|
+
uv: 'TEXCOORD_0',
|
|
1908
|
+
uv1: 'TEXCOORD_1',
|
|
1909
|
+
uv2: 'TEXCOORD_2',
|
|
1910
|
+
uv3: 'TEXCOORD_3',
|
|
1911
|
+
color: 'COLOR_0',
|
|
1912
|
+
skinWeight: 'WEIGHTS_0',
|
|
1913
|
+
skinIndex: 'JOINTS_0'
|
|
1914
|
+
};
|
|
1915
|
+
|
|
1916
|
+
const originalNormal = geometry.getAttribute( 'normal' );
|
|
1917
|
+
|
|
1918
|
+
if ( originalNormal !== undefined && ! this.isNormalizedNormalAttribute( originalNormal ) ) {
|
|
1919
|
+
|
|
1920
|
+
console.warn( 'THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one.' );
|
|
1921
|
+
|
|
1922
|
+
geometry.setAttribute( 'normal', this.createNormalizedNormalAttribute( originalNormal ) );
|
|
1923
|
+
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
// @QUESTION Detect if .vertexColors = true?
|
|
1927
|
+
// For every attribute create an accessor
|
|
1928
|
+
let modifiedAttribute = null;
|
|
1929
|
+
|
|
1930
|
+
for ( let attributeName in geometry.attributes ) {
|
|
1931
|
+
|
|
1932
|
+
// Ignore morph target attributes, which are exported later.
|
|
1933
|
+
if ( attributeName.slice( 0, 5 ) === 'morph' ) continue;
|
|
1934
|
+
|
|
1935
|
+
const attribute = geometry.attributes[ attributeName ];
|
|
1936
|
+
attributeName = nameConversion[ attributeName ] || attributeName.toUpperCase();
|
|
1937
|
+
|
|
1938
|
+
// Prefix all geometry attributes except the ones specifically
|
|
1939
|
+
// listed in the spec; non-spec attributes are considered custom.
|
|
1940
|
+
const validVertexAttributes =
|
|
1941
|
+
/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/;
|
|
1942
|
+
|
|
1943
|
+
if ( ! validVertexAttributes.test( attributeName ) && ! attributeName.startsWith( '_' ) ) attributeName = '_' + attributeName;
|
|
1944
|
+
|
|
1945
|
+
if ( cache.attributes.has( this.getUID( attribute ) ) ) {
|
|
1946
|
+
|
|
1947
|
+
attributes[ attributeName ] = cache.attributes.get( this.getUID( attribute ) );
|
|
1948
|
+
continue;
|
|
1949
|
+
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
// Enforce glTF vertex attribute requirements:
|
|
1953
|
+
// - JOINTS_0 must be UNSIGNED_BYTE or UNSIGNED_SHORT
|
|
1954
|
+
// - Only custom attributes may be INT or UNSIGNED_INT
|
|
1955
|
+
modifiedAttribute = null;
|
|
1956
|
+
const array = attribute.array;
|
|
1957
|
+
|
|
1958
|
+
if ( attributeName === 'JOINTS_0' &&
|
|
1959
|
+
! ( array instanceof Uint16Array ) &&
|
|
1960
|
+
! ( array instanceof Uint8Array ) ) {
|
|
1961
|
+
|
|
1962
|
+
console.warn( 'GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.' );
|
|
1963
|
+
modifiedAttribute = GLTFExporter.Utils.toTypedBufferAttribute( attribute, Uint16Array );
|
|
1964
|
+
|
|
1965
|
+
} else if ( ( array instanceof Uint32Array || array instanceof Int32Array ) && ! attributeName.startsWith( '_' ) ) {
|
|
1966
|
+
|
|
1967
|
+
console.warn( `GLTFExporter: Attribute "${ attributeName }" converted to type FLOAT.` );
|
|
1968
|
+
modifiedAttribute = GLTFExporter.Utils.toTypedBufferAttribute( attribute, Float32Array );
|
|
1969
|
+
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
const accessor = this.processAccessor( modifiedAttribute || attribute, geometry );
|
|
1973
|
+
|
|
1974
|
+
if ( accessor !== null ) {
|
|
1975
|
+
|
|
1976
|
+
if ( ! attributeName.startsWith( '_' ) ) {
|
|
1977
|
+
|
|
1978
|
+
this.detectMeshQuantization( attributeName, attribute );
|
|
1979
|
+
|
|
1980
|
+
}
|
|
1981
|
+
|
|
1982
|
+
attributes[ attributeName ] = accessor;
|
|
1983
|
+
cache.attributes.set( this.getUID( attribute ), accessor );
|
|
1984
|
+
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
if ( originalNormal !== undefined ) geometry.setAttribute( 'normal', originalNormal );
|
|
1990
|
+
|
|
1991
|
+
// Skip if no exportable attributes found
|
|
1992
|
+
if ( Object.keys( attributes ).length === 0 ) return null;
|
|
1993
|
+
|
|
1994
|
+
// Morph targets
|
|
1995
|
+
if ( mesh.morphTargetInfluences !== undefined && mesh.morphTargetInfluences.length > 0 ) {
|
|
1996
|
+
|
|
1997
|
+
const weights = [];
|
|
1998
|
+
const targetNames = [];
|
|
1999
|
+
const reverseDictionary = {};
|
|
2000
|
+
|
|
2001
|
+
if ( mesh.morphTargetDictionary !== undefined ) {
|
|
2002
|
+
|
|
2003
|
+
for ( const key in mesh.morphTargetDictionary ) {
|
|
2004
|
+
|
|
2005
|
+
reverseDictionary[ mesh.morphTargetDictionary[ key ] ] = key;
|
|
2006
|
+
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
for ( let i = 0; i < mesh.morphTargetInfluences.length; ++ i ) {
|
|
2012
|
+
|
|
2013
|
+
const target = {};
|
|
2014
|
+
let warned = false;
|
|
2015
|
+
|
|
2016
|
+
for ( const attributeName in geometry.morphAttributes ) {
|
|
2017
|
+
|
|
2018
|
+
// glTF 2.0 morph supports only POSITION/NORMAL/TANGENT.
|
|
2019
|
+
// Three.js doesn't support TANGENT yet.
|
|
2020
|
+
|
|
2021
|
+
if ( attributeName !== 'position' && attributeName !== 'normal' ) {
|
|
2022
|
+
|
|
2023
|
+
if ( ! warned ) {
|
|
2024
|
+
|
|
2025
|
+
console.warn( 'GLTFExporter: Only POSITION and NORMAL morph are supported.' );
|
|
2026
|
+
warned = true;
|
|
2027
|
+
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
continue;
|
|
2031
|
+
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
const attribute = geometry.morphAttributes[ attributeName ][ i ];
|
|
2035
|
+
const gltfAttributeName = attributeName.toUpperCase();
|
|
2036
|
+
|
|
2037
|
+
// Three.js morph attribute has absolute values while the one of glTF has relative values.
|
|
2038
|
+
//
|
|
2039
|
+
// glTF 2.0 Specification:
|
|
2040
|
+
// https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#morph-targets
|
|
2041
|
+
|
|
2042
|
+
const baseAttribute = geometry.attributes[ attributeName ];
|
|
2043
|
+
|
|
2044
|
+
if ( cache.attributes.has( this.getUID( attribute, true ) ) ) {
|
|
2045
|
+
|
|
2046
|
+
target[ gltfAttributeName ] = cache.attributes.get( this.getUID( attribute, true ) );
|
|
2047
|
+
continue;
|
|
2048
|
+
|
|
2049
|
+
}
|
|
2050
|
+
|
|
2051
|
+
// Clones attribute not to override
|
|
2052
|
+
const relativeAttribute = attribute.clone();
|
|
2053
|
+
|
|
2054
|
+
if ( ! geometry.morphTargetsRelative ) {
|
|
2055
|
+
|
|
2056
|
+
for ( let j = 0, jl = attribute.count; j < jl; j ++ ) {
|
|
2057
|
+
|
|
2058
|
+
for ( let a = 0; a < attribute.itemSize; a ++ ) {
|
|
2059
|
+
|
|
2060
|
+
if ( a === 0 ) relativeAttribute.setX( j, attribute.getX( j ) - baseAttribute.getX( j ) );
|
|
2061
|
+
if ( a === 1 ) relativeAttribute.setY( j, attribute.getY( j ) - baseAttribute.getY( j ) );
|
|
2062
|
+
if ( a === 2 ) relativeAttribute.setZ( j, attribute.getZ( j ) - baseAttribute.getZ( j ) );
|
|
2063
|
+
if ( a === 3 ) relativeAttribute.setW( j, attribute.getW( j ) - baseAttribute.getW( j ) );
|
|
2064
|
+
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
}
|
|
2068
|
+
|
|
2069
|
+
}
|
|
2070
|
+
|
|
2071
|
+
target[ gltfAttributeName ] = this.processAccessor( relativeAttribute, geometry );
|
|
2072
|
+
cache.attributes.set( this.getUID( baseAttribute, true ), target[ gltfAttributeName ] );
|
|
2073
|
+
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
targets.push( target );
|
|
2077
|
+
|
|
2078
|
+
weights.push( mesh.morphTargetInfluences[ i ] );
|
|
2079
|
+
|
|
2080
|
+
if ( mesh.morphTargetDictionary !== undefined ) targetNames.push( reverseDictionary[ i ] );
|
|
2081
|
+
|
|
2082
|
+
}
|
|
2083
|
+
|
|
2084
|
+
meshDef.weights = weights;
|
|
2085
|
+
|
|
2086
|
+
if ( targetNames.length > 0 ) {
|
|
2087
|
+
|
|
2088
|
+
meshDef.extras = {};
|
|
2089
|
+
meshDef.extras.targetNames = targetNames;
|
|
2090
|
+
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2095
|
+
const isMultiMaterial = Array.isArray( mesh.material );
|
|
2096
|
+
|
|
2097
|
+
if ( isMultiMaterial && geometry.groups.length === 0 ) return null;
|
|
2098
|
+
|
|
2099
|
+
let didForceIndices = false;
|
|
2100
|
+
|
|
2101
|
+
if ( isMultiMaterial && geometry.index === null ) {
|
|
2102
|
+
|
|
2103
|
+
const indices = [];
|
|
2104
|
+
|
|
2105
|
+
for ( let i = 0, il = geometry.attributes.position.count; i < il; i ++ ) {
|
|
2106
|
+
|
|
2107
|
+
indices[ i ] = i;
|
|
2108
|
+
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2111
|
+
geometry.setIndex( indices );
|
|
2112
|
+
|
|
2113
|
+
didForceIndices = true;
|
|
2114
|
+
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
const materials = isMultiMaterial ? mesh.material : [ mesh.material ];
|
|
2118
|
+
const groups = isMultiMaterial ? geometry.groups : [ { materialIndex: 0, start: undefined, count: undefined } ];
|
|
2119
|
+
|
|
2120
|
+
for ( let i = 0, il = groups.length; i < il; i ++ ) {
|
|
2121
|
+
|
|
2122
|
+
const primitive = {
|
|
2123
|
+
mode: mode,
|
|
2124
|
+
attributes: attributes,
|
|
2125
|
+
};
|
|
2126
|
+
|
|
2127
|
+
this.serializeUserData( geometry, primitive );
|
|
2128
|
+
|
|
2129
|
+
if ( targets.length > 0 ) primitive.targets = targets;
|
|
2130
|
+
|
|
2131
|
+
if ( geometry.index !== null ) {
|
|
2132
|
+
|
|
2133
|
+
let cacheKey = this.getUID( geometry.index );
|
|
2134
|
+
|
|
2135
|
+
if ( groups[ i ].start !== undefined || groups[ i ].count !== undefined ) {
|
|
2136
|
+
|
|
2137
|
+
cacheKey += ':' + groups[ i ].start + ':' + groups[ i ].count;
|
|
2138
|
+
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2141
|
+
if ( cache.attributes.has( cacheKey ) ) {
|
|
2142
|
+
|
|
2143
|
+
primitive.indices = cache.attributes.get( cacheKey );
|
|
2144
|
+
|
|
2145
|
+
} else {
|
|
2146
|
+
|
|
2147
|
+
primitive.indices = this.processAccessor( geometry.index, geometry, groups[ i ].start, groups[ i ].count );
|
|
2148
|
+
cache.attributes.set( cacheKey, primitive.indices );
|
|
2149
|
+
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
if ( primitive.indices === null ) delete primitive.indices;
|
|
2153
|
+
|
|
2154
|
+
}
|
|
2155
|
+
|
|
2156
|
+
const material = await this.processMaterialAsync( materials[ groups[ i ].materialIndex ], geometry );
|
|
2157
|
+
|
|
2158
|
+
if ( material !== null ) primitive.material = material;
|
|
2159
|
+
|
|
2160
|
+
primitives.push( primitive );
|
|
2161
|
+
|
|
2162
|
+
}
|
|
2163
|
+
|
|
2164
|
+
if ( didForceIndices === true ) {
|
|
2165
|
+
|
|
2166
|
+
geometry.setIndex( null );
|
|
2167
|
+
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2170
|
+
meshDef.primitives = primitives;
|
|
2171
|
+
|
|
2172
|
+
if ( ! json.meshes ) json.meshes = [];
|
|
2173
|
+
|
|
2174
|
+
await this._invokeAllAsync( function ( ext ) {
|
|
2175
|
+
|
|
2176
|
+
ext.writeMesh && ext.writeMesh( mesh, meshDef );
|
|
2177
|
+
|
|
2178
|
+
} );
|
|
2179
|
+
|
|
2180
|
+
const index = json.meshes.push( meshDef ) - 1;
|
|
2181
|
+
cache.meshes.set( meshCacheKey, index );
|
|
2182
|
+
return index;
|
|
2183
|
+
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
/**
|
|
2187
|
+
* If a vertex attribute with a
|
|
2188
|
+
* [non-standard data type](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#meshes-overview)
|
|
2189
|
+
* is used, it is checked whether it is a valid data type according to the
|
|
2190
|
+
* [KHR_mesh_quantization](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_mesh_quantization/README.md)
|
|
2191
|
+
* extension.
|
|
2192
|
+
* In this case the extension is automatically added to the list of used extensions.
|
|
2193
|
+
*
|
|
2194
|
+
* @param {string} attributeName
|
|
2195
|
+
* @param {THREE.BufferAttribute} attribute
|
|
2196
|
+
*/
|
|
2197
|
+
detectMeshQuantization( attributeName, attribute ) {
|
|
2198
|
+
|
|
2199
|
+
if ( this.extensionsUsed[ KHR_MESH_QUANTIZATION ] ) return;
|
|
2200
|
+
|
|
2201
|
+
let attrType = undefined;
|
|
2202
|
+
|
|
2203
|
+
switch ( attribute.array.constructor ) {
|
|
2204
|
+
|
|
2205
|
+
case Int8Array:
|
|
2206
|
+
|
|
2207
|
+
attrType = 'byte';
|
|
2208
|
+
|
|
2209
|
+
break;
|
|
2210
|
+
|
|
2211
|
+
case Uint8Array:
|
|
2212
|
+
|
|
2213
|
+
attrType = 'unsigned byte';
|
|
2214
|
+
|
|
2215
|
+
break;
|
|
2216
|
+
|
|
2217
|
+
case Int16Array:
|
|
2218
|
+
|
|
2219
|
+
attrType = 'short';
|
|
2220
|
+
|
|
2221
|
+
break;
|
|
2222
|
+
|
|
2223
|
+
case Uint16Array:
|
|
2224
|
+
|
|
2225
|
+
attrType = 'unsigned short';
|
|
2226
|
+
|
|
2227
|
+
break;
|
|
2228
|
+
|
|
2229
|
+
default:
|
|
2230
|
+
|
|
2231
|
+
return;
|
|
2232
|
+
|
|
2233
|
+
}
|
|
2234
|
+
|
|
2235
|
+
if ( attribute.normalized ) attrType += ' normalized';
|
|
2236
|
+
|
|
2237
|
+
const attrNamePrefix = attributeName.split( '_', 1 )[ 0 ];
|
|
2238
|
+
|
|
2239
|
+
if ( KHR_mesh_quantization_ExtraAttrTypes[ attrNamePrefix ] && KHR_mesh_quantization_ExtraAttrTypes[ attrNamePrefix ].includes( attrType ) ) {
|
|
2240
|
+
|
|
2241
|
+
this.extensionsUsed[ KHR_MESH_QUANTIZATION ] = true;
|
|
2242
|
+
this.extensionsRequired[ KHR_MESH_QUANTIZATION ] = true;
|
|
2243
|
+
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2248
|
+
/**
|
|
2249
|
+
* Process camera
|
|
2250
|
+
* @param {THREE.Camera} camera Camera to process
|
|
2251
|
+
* @return {number} Index of the processed mesh in the "camera" array
|
|
2252
|
+
*/
|
|
2253
|
+
processCamera( camera ) {
|
|
2254
|
+
|
|
2255
|
+
const json = this.json;
|
|
2256
|
+
|
|
2257
|
+
if ( ! json.cameras ) json.cameras = [];
|
|
2258
|
+
|
|
2259
|
+
const isOrtho = camera.isOrthographicCamera;
|
|
2260
|
+
|
|
2261
|
+
const cameraDef = {
|
|
2262
|
+
type: isOrtho ? 'orthographic' : 'perspective'
|
|
2263
|
+
};
|
|
2264
|
+
|
|
2265
|
+
if ( isOrtho ) {
|
|
2266
|
+
|
|
2267
|
+
cameraDef.orthographic = {
|
|
2268
|
+
xmag: camera.right,
|
|
2269
|
+
ymag: camera.top,
|
|
2270
|
+
zfar: camera.far <= 0 ? 0.001 : camera.far,
|
|
2271
|
+
znear: camera.near < 0 ? 0 : camera.near
|
|
2272
|
+
};
|
|
2273
|
+
|
|
2274
|
+
} else {
|
|
2275
|
+
|
|
2276
|
+
cameraDef.perspective = {
|
|
2277
|
+
aspectRatio: camera.aspect,
|
|
2278
|
+
yfov: MathUtils.degToRad( camera.fov ),
|
|
2279
|
+
zfar: camera.far <= 0 ? 0.001 : camera.far,
|
|
2280
|
+
znear: camera.near < 0 ? 0 : camera.near
|
|
2281
|
+
};
|
|
2282
|
+
|
|
2283
|
+
}
|
|
2284
|
+
|
|
2285
|
+
// Question: Is saving "type" as name intentional?
|
|
2286
|
+
if ( camera.name !== '' ) cameraDef.name = camera.type;
|
|
2287
|
+
|
|
2288
|
+
return json.cameras.push( cameraDef ) - 1;
|
|
2289
|
+
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
/**
|
|
2293
|
+
* Creates glTF animation entry from AnimationClip object.
|
|
2294
|
+
*
|
|
2295
|
+
* Status:
|
|
2296
|
+
* - Only properties listed in PATH_PROPERTIES may be animated.
|
|
2297
|
+
*
|
|
2298
|
+
* @param {THREE.AnimationClip} clip
|
|
2299
|
+
* @param {THREE.Object3D} root
|
|
2300
|
+
* @return {?number}
|
|
2301
|
+
*/
|
|
2302
|
+
processAnimation( clip, root ) {
|
|
2303
|
+
|
|
2304
|
+
const json = this.json;
|
|
2305
|
+
const nodeMap = this.nodeMap;
|
|
2306
|
+
|
|
2307
|
+
if ( ! json.animations ) json.animations = [];
|
|
2308
|
+
|
|
2309
|
+
clip = GLTFExporter.Utils.mergeMorphTargetTracks( clip.clone(), root );
|
|
2310
|
+
|
|
2311
|
+
const tracks = clip.tracks;
|
|
2312
|
+
const channels = [];
|
|
2313
|
+
const samplers = [];
|
|
2314
|
+
|
|
2315
|
+
for ( let i = 0; i < tracks.length; ++ i ) {
|
|
2316
|
+
|
|
2317
|
+
const track = tracks[ i ];
|
|
2318
|
+
const trackBinding = PropertyBinding.parseTrackName( track.name );
|
|
2319
|
+
let trackNode = PropertyBinding.findNode( root, trackBinding.nodeName );
|
|
2320
|
+
const trackProperty = PATH_PROPERTIES[ trackBinding.propertyName ];
|
|
2321
|
+
|
|
2322
|
+
if ( trackBinding.objectName === 'bones' ) {
|
|
2323
|
+
|
|
2324
|
+
if ( trackNode.isSkinnedMesh === true ) {
|
|
2325
|
+
|
|
2326
|
+
trackNode = trackNode.skeleton.getBoneByName( trackBinding.objectIndex );
|
|
2327
|
+
|
|
2328
|
+
} else {
|
|
2329
|
+
|
|
2330
|
+
trackNode = undefined;
|
|
2331
|
+
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
if ( ! trackNode || ! trackProperty ) {
|
|
2337
|
+
|
|
2338
|
+
console.warn( 'THREE.GLTFExporter: Could not export animation track "%s".', track.name );
|
|
2339
|
+
continue;
|
|
2340
|
+
|
|
2341
|
+
}
|
|
2342
|
+
|
|
2343
|
+
const inputItemSize = 1;
|
|
2344
|
+
let outputItemSize = track.values.length / track.times.length;
|
|
2345
|
+
|
|
2346
|
+
if ( trackProperty === PATH_PROPERTIES.morphTargetInfluences ) {
|
|
2347
|
+
|
|
2348
|
+
outputItemSize /= trackNode.morphTargetInfluences.length;
|
|
2349
|
+
|
|
2350
|
+
}
|
|
2351
|
+
|
|
2352
|
+
let interpolation;
|
|
2353
|
+
|
|
2354
|
+
// @TODO export CubicInterpolant(InterpolateSmooth) as CUBICSPLINE
|
|
2355
|
+
|
|
2356
|
+
// Detecting glTF cubic spline interpolant by checking factory method's special property
|
|
2357
|
+
// GLTFCubicSplineInterpolant is a custom interpolant and track doesn't return
|
|
2358
|
+
// valid value from .getInterpolation().
|
|
2359
|
+
if ( track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === true ) {
|
|
2360
|
+
|
|
2361
|
+
interpolation = 'CUBICSPLINE';
|
|
2362
|
+
|
|
2363
|
+
// itemSize of CUBICSPLINE keyframe is 9
|
|
2364
|
+
// (VEC3 * 3: inTangent, splineVertex, and outTangent)
|
|
2365
|
+
// but needs to be stored as VEC3 so dividing by 3 here.
|
|
2366
|
+
outputItemSize /= 3;
|
|
2367
|
+
|
|
2368
|
+
} else if ( track.getInterpolation() === InterpolateDiscrete ) {
|
|
2369
|
+
|
|
2370
|
+
interpolation = 'STEP';
|
|
2371
|
+
|
|
2372
|
+
} else {
|
|
2373
|
+
|
|
2374
|
+
interpolation = 'LINEAR';
|
|
2375
|
+
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
samplers.push( {
|
|
2379
|
+
input: this.processAccessor( new BufferAttribute( track.times, inputItemSize ) ),
|
|
2380
|
+
output: this.processAccessor( new BufferAttribute( track.values, outputItemSize ) ),
|
|
2381
|
+
interpolation: interpolation
|
|
2382
|
+
} );
|
|
2383
|
+
|
|
2384
|
+
channels.push( {
|
|
2385
|
+
sampler: samplers.length - 1,
|
|
2386
|
+
target: {
|
|
2387
|
+
node: nodeMap.get( trackNode ),
|
|
2388
|
+
path: trackProperty
|
|
2389
|
+
}
|
|
2390
|
+
} );
|
|
2391
|
+
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
const animationDef = {
|
|
2395
|
+
name: clip.name || 'clip_' + json.animations.length,
|
|
2396
|
+
samplers: samplers,
|
|
2397
|
+
channels: channels
|
|
2398
|
+
};
|
|
2399
|
+
|
|
2400
|
+
this.serializeUserData( clip, animationDef );
|
|
2401
|
+
|
|
2402
|
+
json.animations.push( animationDef );
|
|
2403
|
+
|
|
2404
|
+
return json.animations.length - 1;
|
|
2405
|
+
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
/**
|
|
2409
|
+
* @param {THREE.Object3D} object
|
|
2410
|
+
* @return {?number}
|
|
2411
|
+
*/
|
|
2412
|
+
processSkin( object ) {
|
|
2413
|
+
|
|
2414
|
+
const json = this.json;
|
|
2415
|
+
const nodeMap = this.nodeMap;
|
|
2416
|
+
|
|
2417
|
+
const node = json.nodes[ nodeMap.get( object ) ];
|
|
2418
|
+
|
|
2419
|
+
const skeleton = object.skeleton;
|
|
2420
|
+
|
|
2421
|
+
if ( skeleton === undefined ) return null;
|
|
2422
|
+
|
|
2423
|
+
const rootJoint = object.skeleton.bones[ 0 ];
|
|
2424
|
+
|
|
2425
|
+
if ( rootJoint === undefined ) return null;
|
|
2426
|
+
|
|
2427
|
+
const joints = [];
|
|
2428
|
+
const inverseBindMatrices = new Float32Array( skeleton.bones.length * 16 );
|
|
2429
|
+
const temporaryBoneInverse = new Matrix4();
|
|
2430
|
+
|
|
2431
|
+
for ( let i = 0; i < skeleton.bones.length; ++ i ) {
|
|
2432
|
+
|
|
2433
|
+
joints.push( nodeMap.get( skeleton.bones[ i ] ) );
|
|
2434
|
+
temporaryBoneInverse.copy( skeleton.boneInverses[ i ] );
|
|
2435
|
+
temporaryBoneInverse.multiply( object.bindMatrix ).toArray( inverseBindMatrices, i * 16 );
|
|
2436
|
+
|
|
2437
|
+
}
|
|
2438
|
+
|
|
2439
|
+
if ( json.skins === undefined ) json.skins = [];
|
|
2440
|
+
|
|
2441
|
+
json.skins.push( {
|
|
2442
|
+
inverseBindMatrices: this.processAccessor( new BufferAttribute( inverseBindMatrices, 16 ) ),
|
|
2443
|
+
joints: joints,
|
|
2444
|
+
skeleton: nodeMap.get( rootJoint )
|
|
2445
|
+
} );
|
|
2446
|
+
|
|
2447
|
+
const skinIndex = node.skin = json.skins.length - 1;
|
|
2448
|
+
|
|
2449
|
+
return skinIndex;
|
|
2450
|
+
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
/**
|
|
2454
|
+
* Process Object3D node
|
|
2455
|
+
* @param {THREE.Object3D} object Object3D to processNodeAsync
|
|
2456
|
+
* @return {Promise<number>} Index of the node in the nodes list
|
|
2457
|
+
*/
|
|
2458
|
+
async processNodeAsync( object ) {
|
|
2459
|
+
|
|
2460
|
+
const json = this.json;
|
|
2461
|
+
const options = this.options;
|
|
2462
|
+
const nodeMap = this.nodeMap;
|
|
2463
|
+
|
|
2464
|
+
if ( ! json.nodes ) json.nodes = [];
|
|
2465
|
+
|
|
2466
|
+
// Handle pivot by creating a container node
|
|
2467
|
+
if ( object.pivot !== null ) {
|
|
2468
|
+
|
|
2469
|
+
return await this._processNodeWithPivotAsync( object );
|
|
2470
|
+
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
const nodeDef = {};
|
|
2474
|
+
|
|
2475
|
+
if ( options.trs ) {
|
|
2476
|
+
|
|
2477
|
+
const rotation = object.quaternion.toArray();
|
|
2478
|
+
const position = object.position.toArray();
|
|
2479
|
+
const scale = object.scale.toArray();
|
|
2480
|
+
|
|
2481
|
+
if ( ! equalArray( rotation, [ 0, 0, 0, 1 ] ) ) {
|
|
2482
|
+
|
|
2483
|
+
nodeDef.rotation = rotation;
|
|
2484
|
+
|
|
2485
|
+
}
|
|
2486
|
+
|
|
2487
|
+
if ( ! equalArray( position, [ 0, 0, 0 ] ) ) {
|
|
2488
|
+
|
|
2489
|
+
nodeDef.translation = position;
|
|
2490
|
+
|
|
2491
|
+
}
|
|
2492
|
+
|
|
2493
|
+
if ( ! equalArray( scale, [ 1, 1, 1 ] ) ) {
|
|
2494
|
+
|
|
2495
|
+
nodeDef.scale = scale;
|
|
2496
|
+
|
|
2497
|
+
}
|
|
2498
|
+
|
|
2499
|
+
} else {
|
|
2500
|
+
|
|
2501
|
+
if ( object.matrixAutoUpdate ) {
|
|
2502
|
+
|
|
2503
|
+
object.updateMatrix();
|
|
2504
|
+
|
|
2505
|
+
}
|
|
2506
|
+
|
|
2507
|
+
if ( isIdentityMatrix( object.matrix ) === false ) {
|
|
2508
|
+
|
|
2509
|
+
nodeDef.matrix = object.matrix.elements;
|
|
2510
|
+
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
// We don't export empty strings name because it represents no-name in Three.js.
|
|
2516
|
+
if ( object.name !== '' ) nodeDef.name = String( object.name );
|
|
2517
|
+
|
|
2518
|
+
this.serializeUserData( object, nodeDef );
|
|
2519
|
+
|
|
2520
|
+
if ( object.isMesh || object.isLine || object.isPoints ) {
|
|
2521
|
+
|
|
2522
|
+
const meshIndex = await this.processMeshAsync( object );
|
|
2523
|
+
|
|
2524
|
+
if ( meshIndex !== null ) nodeDef.mesh = meshIndex;
|
|
2525
|
+
|
|
2526
|
+
} else if ( object.isCamera ) {
|
|
2527
|
+
|
|
2528
|
+
nodeDef.camera = this.processCamera( object );
|
|
2529
|
+
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2532
|
+
if ( object.isSkinnedMesh ) this.skins.push( object );
|
|
2533
|
+
|
|
2534
|
+
const nodeIndex = json.nodes.push( nodeDef ) - 1;
|
|
2535
|
+
nodeMap.set( object, nodeIndex );
|
|
2536
|
+
|
|
2537
|
+
if ( object.children.length > 0 ) {
|
|
2538
|
+
|
|
2539
|
+
const children = [];
|
|
2540
|
+
|
|
2541
|
+
for ( let i = 0, l = object.children.length; i < l; i ++ ) {
|
|
2542
|
+
|
|
2543
|
+
const child = object.children[ i ];
|
|
2544
|
+
|
|
2545
|
+
if ( child.visible || options.onlyVisible === false ) {
|
|
2546
|
+
|
|
2547
|
+
const childNodeIndex = await this.processNodeAsync( child );
|
|
2548
|
+
|
|
2549
|
+
if ( childNodeIndex !== null ) children.push( childNodeIndex );
|
|
2550
|
+
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
}
|
|
2554
|
+
|
|
2555
|
+
if ( children.length > 0 ) nodeDef.children = children;
|
|
2556
|
+
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
await this._invokeAllAsync( function ( ext ) {
|
|
2560
|
+
|
|
2561
|
+
ext.writeNode && ext.writeNode( object, nodeDef );
|
|
2562
|
+
|
|
2563
|
+
} );
|
|
2564
|
+
|
|
2565
|
+
return nodeIndex;
|
|
2566
|
+
|
|
2567
|
+
}
|
|
2568
|
+
|
|
2569
|
+
/**
|
|
2570
|
+
* Process Object3D node with pivot using container approach
|
|
2571
|
+
* @param {THREE.Object3D} object Object3D with pivot
|
|
2572
|
+
* @return {Promise<number>} Index of the container node
|
|
2573
|
+
*/
|
|
2574
|
+
async _processNodeWithPivotAsync( object ) {
|
|
2575
|
+
|
|
2576
|
+
const json = this.json;
|
|
2577
|
+
const options = this.options;
|
|
2578
|
+
const nodeMap = this.nodeMap;
|
|
2579
|
+
|
|
2580
|
+
const pivot = object.pivot;
|
|
2581
|
+
|
|
2582
|
+
// Container node: holds position + pivot offset, rotation, scale
|
|
2583
|
+
// Animations will target this node
|
|
2584
|
+
const containerDef = {};
|
|
2585
|
+
|
|
2586
|
+
const rotation = object.quaternion.toArray();
|
|
2587
|
+
const position = [
|
|
2588
|
+
object.position.x + pivot.x,
|
|
2589
|
+
object.position.y + pivot.y,
|
|
2590
|
+
object.position.z + pivot.z
|
|
2591
|
+
];
|
|
2592
|
+
const scale = object.scale.toArray();
|
|
2593
|
+
|
|
2594
|
+
if ( ! equalArray( rotation, [ 0, 0, 0, 1 ] ) ) {
|
|
2595
|
+
|
|
2596
|
+
containerDef.rotation = rotation;
|
|
2597
|
+
|
|
2598
|
+
}
|
|
2599
|
+
|
|
2600
|
+
if ( ! equalArray( position, [ 0, 0, 0 ] ) ) {
|
|
2601
|
+
|
|
2602
|
+
containerDef.translation = position;
|
|
2603
|
+
|
|
2604
|
+
}
|
|
2605
|
+
|
|
2606
|
+
if ( ! equalArray( scale, [ 1, 1, 1 ] ) ) {
|
|
2607
|
+
|
|
2608
|
+
containerDef.scale = scale;
|
|
2609
|
+
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
// Store pivot in extras for round-trip reconstruction
|
|
2613
|
+
containerDef.extras = { pivot: pivot.toArray() };
|
|
2614
|
+
|
|
2615
|
+
if ( object.name !== '' ) containerDef.name = String( object.name );
|
|
2616
|
+
|
|
2617
|
+
this.serializeUserData( object, containerDef );
|
|
2618
|
+
|
|
2619
|
+
const containerIndex = json.nodes.push( containerDef ) - 1;
|
|
2620
|
+
|
|
2621
|
+
// Map original object to container so animations target it
|
|
2622
|
+
nodeMap.set( object, containerIndex );
|
|
2623
|
+
|
|
2624
|
+
// Child node: holds mesh with -pivot offset
|
|
2625
|
+
const childDef = {};
|
|
2626
|
+
|
|
2627
|
+
const childPosition = [ - pivot.x, - pivot.y, - pivot.z ];
|
|
2628
|
+
|
|
2629
|
+
if ( ! equalArray( childPosition, [ 0, 0, 0 ] ) ) {
|
|
2630
|
+
|
|
2631
|
+
childDef.translation = childPosition;
|
|
2632
|
+
|
|
2633
|
+
}
|
|
2634
|
+
|
|
2635
|
+
if ( object.isMesh || object.isLine || object.isPoints ) {
|
|
2636
|
+
|
|
2637
|
+
const meshIndex = await this.processMeshAsync( object );
|
|
2638
|
+
|
|
2639
|
+
if ( meshIndex !== null ) childDef.mesh = meshIndex;
|
|
2640
|
+
|
|
2641
|
+
} else if ( object.isCamera ) {
|
|
2642
|
+
|
|
2643
|
+
childDef.camera = this.processCamera( object );
|
|
2644
|
+
|
|
2645
|
+
}
|
|
2646
|
+
|
|
2647
|
+
if ( object.isSkinnedMesh ) this.skins.push( object );
|
|
2648
|
+
|
|
2649
|
+
const childIndex = json.nodes.push( childDef ) - 1;
|
|
2650
|
+
|
|
2651
|
+
// Build children array for container
|
|
2652
|
+
const containerChildren = [ childIndex ];
|
|
2653
|
+
|
|
2654
|
+
// Process object's children as children of the child node
|
|
2655
|
+
if ( object.children.length > 0 ) {
|
|
2656
|
+
|
|
2657
|
+
const grandchildren = [];
|
|
2658
|
+
|
|
2659
|
+
for ( let i = 0, l = object.children.length; i < l; i ++ ) {
|
|
2660
|
+
|
|
2661
|
+
const child = object.children[ i ];
|
|
2662
|
+
|
|
2663
|
+
if ( child.visible || options.onlyVisible === false ) {
|
|
2664
|
+
|
|
2665
|
+
const childNodeIndex = await this.processNodeAsync( child );
|
|
2666
|
+
|
|
2667
|
+
if ( childNodeIndex !== null ) grandchildren.push( childNodeIndex );
|
|
2668
|
+
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2671
|
+
}
|
|
2672
|
+
|
|
2673
|
+
if ( grandchildren.length > 0 ) childDef.children = grandchildren;
|
|
2674
|
+
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2677
|
+
containerDef.children = containerChildren;
|
|
2678
|
+
|
|
2679
|
+
await this._invokeAllAsync( function ( ext ) {
|
|
2680
|
+
|
|
2681
|
+
ext.writeNode && ext.writeNode( object, containerDef );
|
|
2682
|
+
|
|
2683
|
+
} );
|
|
2684
|
+
|
|
2685
|
+
return containerIndex;
|
|
2686
|
+
|
|
2687
|
+
}
|
|
2688
|
+
|
|
2689
|
+
/**
|
|
2690
|
+
* Process Scene
|
|
2691
|
+
* @param {Scene} scene Scene to process
|
|
2692
|
+
*/
|
|
2693
|
+
async processSceneAsync( scene ) {
|
|
2694
|
+
|
|
2695
|
+
const json = this.json;
|
|
2696
|
+
const options = this.options;
|
|
2697
|
+
|
|
2698
|
+
if ( ! json.scenes ) {
|
|
2699
|
+
|
|
2700
|
+
json.scenes = [];
|
|
2701
|
+
json.scene = 0;
|
|
2702
|
+
|
|
2703
|
+
}
|
|
2704
|
+
|
|
2705
|
+
const sceneDef = {};
|
|
2706
|
+
|
|
2707
|
+
if ( scene.name !== '' ) sceneDef.name = scene.name;
|
|
2708
|
+
|
|
2709
|
+
json.scenes.push( sceneDef );
|
|
2710
|
+
|
|
2711
|
+
const nodes = [];
|
|
2712
|
+
|
|
2713
|
+
for ( let i = 0, l = scene.children.length; i < l; i ++ ) {
|
|
2714
|
+
|
|
2715
|
+
const child = scene.children[ i ];
|
|
2716
|
+
|
|
2717
|
+
if ( child.visible || options.onlyVisible === false ) {
|
|
2718
|
+
|
|
2719
|
+
const nodeIndex = await this.processNodeAsync( child );
|
|
2720
|
+
|
|
2721
|
+
if ( nodeIndex !== null ) nodes.push( nodeIndex );
|
|
2722
|
+
|
|
2723
|
+
}
|
|
2724
|
+
|
|
2725
|
+
}
|
|
2726
|
+
|
|
2727
|
+
if ( nodes.length > 0 ) sceneDef.nodes = nodes;
|
|
2728
|
+
|
|
2729
|
+
this.serializeUserData( scene, sceneDef );
|
|
2730
|
+
|
|
2731
|
+
}
|
|
2732
|
+
|
|
2733
|
+
/**
|
|
2734
|
+
* Creates a Scene to hold a list of objects and parse it
|
|
2735
|
+
* @param {Array<THREE.Object3D>} objects List of objects to process
|
|
2736
|
+
*/
|
|
2737
|
+
async processObjectsAsync( objects ) {
|
|
2738
|
+
|
|
2739
|
+
const scene = new Scene();
|
|
2740
|
+
scene.name = 'AuxScene';
|
|
2741
|
+
|
|
2742
|
+
for ( let i = 0; i < objects.length; i ++ ) {
|
|
2743
|
+
|
|
2744
|
+
// We push directly to children instead of calling `add` to prevent
|
|
2745
|
+
// modify the .parent and break its original scene and hierarchy
|
|
2746
|
+
scene.children.push( objects[ i ] );
|
|
2747
|
+
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2750
|
+
await this.processSceneAsync( scene );
|
|
2751
|
+
|
|
2752
|
+
}
|
|
2753
|
+
|
|
2754
|
+
/**
|
|
2755
|
+
* @param {THREE.Object3D|Array<THREE.Object3D>} input
|
|
2756
|
+
*/
|
|
2757
|
+
async processInputAsync( input ) {
|
|
2758
|
+
|
|
2759
|
+
const options = this.options;
|
|
2760
|
+
|
|
2761
|
+
input = input instanceof Array ? input : [ input ];
|
|
2762
|
+
|
|
2763
|
+
await this._invokeAllAsync( function ( ext ) {
|
|
2764
|
+
|
|
2765
|
+
ext.beforeParse && ext.beforeParse( input );
|
|
2766
|
+
|
|
2767
|
+
} );
|
|
2768
|
+
|
|
2769
|
+
const objectsWithoutScene = [];
|
|
2770
|
+
|
|
2771
|
+
for ( let i = 0; i < input.length; i ++ ) {
|
|
2772
|
+
|
|
2773
|
+
if ( input[ i ] instanceof Scene ) {
|
|
2774
|
+
|
|
2775
|
+
await this.processSceneAsync( input[ i ] );
|
|
2776
|
+
|
|
2777
|
+
} else {
|
|
2778
|
+
|
|
2779
|
+
objectsWithoutScene.push( input[ i ] );
|
|
2780
|
+
|
|
2781
|
+
}
|
|
2782
|
+
|
|
2783
|
+
}
|
|
2784
|
+
|
|
2785
|
+
if ( objectsWithoutScene.length > 0 ) {
|
|
2786
|
+
|
|
2787
|
+
await this.processObjectsAsync( objectsWithoutScene );
|
|
2788
|
+
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2791
|
+
for ( let i = 0; i < this.skins.length; ++ i ) {
|
|
2792
|
+
|
|
2793
|
+
this.processSkin( this.skins[ i ] );
|
|
2794
|
+
|
|
2795
|
+
}
|
|
2796
|
+
|
|
2797
|
+
// animations
|
|
2798
|
+
|
|
2799
|
+
if ( input.length === 1 ) {
|
|
2800
|
+
|
|
2801
|
+
// default: single input, flat animations array
|
|
2802
|
+
|
|
2803
|
+
for ( let i = 0; i < options.animations.length; ++ i ) {
|
|
2804
|
+
|
|
2805
|
+
this.processAnimation( options.animations[ i ], input[ 0 ] );
|
|
2806
|
+
|
|
2807
|
+
}
|
|
2808
|
+
|
|
2809
|
+
} else {
|
|
2810
|
+
|
|
2811
|
+
// multi-input with multi-dimensional animations array
|
|
2812
|
+
|
|
2813
|
+
for ( let i = 0; i < input.length; i ++ ) {
|
|
2814
|
+
|
|
2815
|
+
const animations = options.animations[ i ] || [];
|
|
2816
|
+
|
|
2817
|
+
for ( let j = 0; j < animations.length; ++ j ) {
|
|
2818
|
+
|
|
2819
|
+
this.processAnimation( animations[ j ], input[ i ] );
|
|
2820
|
+
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
}
|
|
2824
|
+
|
|
2825
|
+
}
|
|
2826
|
+
|
|
2827
|
+
await this._invokeAllAsync( function ( ext ) {
|
|
2828
|
+
|
|
2829
|
+
ext.afterParse && ext.afterParse( input );
|
|
2830
|
+
|
|
2831
|
+
} );
|
|
2832
|
+
|
|
2833
|
+
}
|
|
2834
|
+
|
|
2835
|
+
async _invokeAllAsync( func ) {
|
|
2836
|
+
|
|
2837
|
+
for ( let i = 0, il = this.plugins.length; i < il; i ++ ) {
|
|
2838
|
+
|
|
2839
|
+
await func( this.plugins[ i ] );
|
|
2840
|
+
|
|
2841
|
+
}
|
|
2842
|
+
|
|
2843
|
+
}
|
|
2844
|
+
|
|
2845
|
+
}
|
|
2846
|
+
|
|
2847
|
+
/**
|
|
2848
|
+
* Punctual Lights Extension
|
|
2849
|
+
*
|
|
2850
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual
|
|
2851
|
+
*
|
|
2852
|
+
* @private
|
|
2853
|
+
*/
|
|
2854
|
+
class GLTFLightExtension {
|
|
2855
|
+
|
|
2856
|
+
constructor( writer ) {
|
|
2857
|
+
|
|
2858
|
+
this.writer = writer;
|
|
2859
|
+
this.name = 'KHR_lights_punctual';
|
|
2860
|
+
|
|
2861
|
+
}
|
|
2862
|
+
|
|
2863
|
+
writeNode( light, nodeDef ) {
|
|
2864
|
+
|
|
2865
|
+
if ( ! light.isLight ) return;
|
|
2866
|
+
|
|
2867
|
+
if ( ! light.isDirectionalLight && ! light.isPointLight && ! light.isSpotLight ) {
|
|
2868
|
+
|
|
2869
|
+
console.warn( 'THREE.GLTFExporter: Only directional, point, and spot lights are supported.', light );
|
|
2870
|
+
return;
|
|
2871
|
+
|
|
2872
|
+
}
|
|
2873
|
+
|
|
2874
|
+
const writer = this.writer;
|
|
2875
|
+
const json = writer.json;
|
|
2876
|
+
const extensionsUsed = writer.extensionsUsed;
|
|
2877
|
+
|
|
2878
|
+
const lightDef = {};
|
|
2879
|
+
|
|
2880
|
+
if ( light.name ) lightDef.name = light.name;
|
|
2881
|
+
|
|
2882
|
+
lightDef.color = light.color.toArray();
|
|
2883
|
+
|
|
2884
|
+
lightDef.intensity = light.intensity;
|
|
2885
|
+
|
|
2886
|
+
if ( light.isDirectionalLight ) {
|
|
2887
|
+
|
|
2888
|
+
lightDef.type = 'directional';
|
|
2889
|
+
|
|
2890
|
+
} else if ( light.isPointLight ) {
|
|
2891
|
+
|
|
2892
|
+
lightDef.type = 'point';
|
|
2893
|
+
|
|
2894
|
+
if ( light.distance > 0 ) lightDef.range = light.distance;
|
|
2895
|
+
|
|
2896
|
+
} else if ( light.isSpotLight ) {
|
|
2897
|
+
|
|
2898
|
+
lightDef.type = 'spot';
|
|
2899
|
+
|
|
2900
|
+
if ( light.distance > 0 ) lightDef.range = light.distance;
|
|
2901
|
+
|
|
2902
|
+
lightDef.spot = {};
|
|
2903
|
+
lightDef.spot.innerConeAngle = ( 1.0 - light.penumbra ) * light.angle;
|
|
2904
|
+
lightDef.spot.outerConeAngle = light.angle;
|
|
2905
|
+
|
|
2906
|
+
}
|
|
2907
|
+
|
|
2908
|
+
if ( light.decay !== undefined && light.decay !== 2 ) {
|
|
2909
|
+
|
|
2910
|
+
console.warn( 'THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, '
|
|
2911
|
+
+ 'and expects light.decay=2.' );
|
|
2912
|
+
|
|
2913
|
+
}
|
|
2914
|
+
|
|
2915
|
+
if ( light.target
|
|
2916
|
+
&& ( light.target.parent !== light
|
|
2917
|
+
|| light.target.position.x !== 0
|
|
2918
|
+
|| light.target.position.y !== 0
|
|
2919
|
+
|| light.target.position.z !== - 1 ) ) {
|
|
2920
|
+
|
|
2921
|
+
console.warn( 'THREE.GLTFExporter: Light direction may be lost. For best results, '
|
|
2922
|
+
+ 'make light.target a child of the light with position 0,0,-1.' );
|
|
2923
|
+
|
|
2924
|
+
}
|
|
2925
|
+
|
|
2926
|
+
if ( ! extensionsUsed[ this.name ] ) {
|
|
2927
|
+
|
|
2928
|
+
json.extensions = json.extensions || {};
|
|
2929
|
+
json.extensions[ this.name ] = { lights: [] };
|
|
2930
|
+
extensionsUsed[ this.name ] = true;
|
|
2931
|
+
|
|
2932
|
+
}
|
|
2933
|
+
|
|
2934
|
+
const lights = json.extensions[ this.name ].lights;
|
|
2935
|
+
lights.push( lightDef );
|
|
2936
|
+
|
|
2937
|
+
nodeDef.extensions = nodeDef.extensions || {};
|
|
2938
|
+
nodeDef.extensions[ this.name ] = { light: lights.length - 1 };
|
|
2939
|
+
|
|
2940
|
+
}
|
|
2941
|
+
|
|
2942
|
+
}
|
|
2943
|
+
|
|
2944
|
+
/**
|
|
2945
|
+
* Unlit Materials Extension
|
|
2946
|
+
*
|
|
2947
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit
|
|
2948
|
+
*
|
|
2949
|
+
* @private
|
|
2950
|
+
*/
|
|
2951
|
+
class GLTFMaterialsUnlitExtension {
|
|
2952
|
+
|
|
2953
|
+
constructor( writer ) {
|
|
2954
|
+
|
|
2955
|
+
this.writer = writer;
|
|
2956
|
+
this.name = 'KHR_materials_unlit';
|
|
2957
|
+
|
|
2958
|
+
}
|
|
2959
|
+
|
|
2960
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
2961
|
+
|
|
2962
|
+
if ( ! material.isMeshBasicMaterial ) return;
|
|
2963
|
+
|
|
2964
|
+
const writer = this.writer;
|
|
2965
|
+
const extensionsUsed = writer.extensionsUsed;
|
|
2966
|
+
|
|
2967
|
+
materialDef.extensions = materialDef.extensions || {};
|
|
2968
|
+
materialDef.extensions[ this.name ] = {};
|
|
2969
|
+
|
|
2970
|
+
extensionsUsed[ this.name ] = true;
|
|
2971
|
+
|
|
2972
|
+
materialDef.pbrMetallicRoughness.metallicFactor = 0.0;
|
|
2973
|
+
materialDef.pbrMetallicRoughness.roughnessFactor = 0.9;
|
|
2974
|
+
|
|
2975
|
+
}
|
|
2976
|
+
|
|
2977
|
+
}
|
|
2978
|
+
|
|
2979
|
+
/**
|
|
2980
|
+
* Clearcoat Materials Extension
|
|
2981
|
+
*
|
|
2982
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_clearcoat
|
|
2983
|
+
*
|
|
2984
|
+
* @private
|
|
2985
|
+
*/
|
|
2986
|
+
class GLTFMaterialsClearcoatExtension {
|
|
2987
|
+
|
|
2988
|
+
constructor( writer ) {
|
|
2989
|
+
|
|
2990
|
+
this.writer = writer;
|
|
2991
|
+
this.name = 'KHR_materials_clearcoat';
|
|
2992
|
+
|
|
2993
|
+
}
|
|
2994
|
+
|
|
2995
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
2996
|
+
|
|
2997
|
+
if ( ! material.isMeshPhysicalMaterial || material.clearcoat === 0 ) return;
|
|
2998
|
+
|
|
2999
|
+
const writer = this.writer;
|
|
3000
|
+
const extensionsUsed = writer.extensionsUsed;
|
|
3001
|
+
|
|
3002
|
+
const extensionDef = {};
|
|
3003
|
+
|
|
3004
|
+
extensionDef.clearcoatFactor = material.clearcoat;
|
|
3005
|
+
|
|
3006
|
+
if ( material.clearcoatMap ) {
|
|
3007
|
+
|
|
3008
|
+
const clearcoatMapDef = {
|
|
3009
|
+
index: await writer.processTextureAsync( material.clearcoatMap ),
|
|
3010
|
+
texCoord: material.clearcoatMap.channel
|
|
3011
|
+
};
|
|
3012
|
+
writer.applyTextureTransform( clearcoatMapDef, material.clearcoatMap );
|
|
3013
|
+
extensionDef.clearcoatTexture = clearcoatMapDef;
|
|
3014
|
+
|
|
3015
|
+
}
|
|
3016
|
+
|
|
3017
|
+
extensionDef.clearcoatRoughnessFactor = material.clearcoatRoughness;
|
|
3018
|
+
|
|
3019
|
+
if ( material.clearcoatRoughnessMap ) {
|
|
3020
|
+
|
|
3021
|
+
const clearcoatRoughnessMapDef = {
|
|
3022
|
+
index: await writer.processTextureAsync( material.clearcoatRoughnessMap ),
|
|
3023
|
+
texCoord: material.clearcoatRoughnessMap.channel
|
|
3024
|
+
};
|
|
3025
|
+
writer.applyTextureTransform( clearcoatRoughnessMapDef, material.clearcoatRoughnessMap );
|
|
3026
|
+
extensionDef.clearcoatRoughnessTexture = clearcoatRoughnessMapDef;
|
|
3027
|
+
|
|
3028
|
+
}
|
|
3029
|
+
|
|
3030
|
+
if ( material.clearcoatNormalMap ) {
|
|
3031
|
+
|
|
3032
|
+
const clearcoatNormalMapDef = {
|
|
3033
|
+
index: await writer.processTextureAsync( material.clearcoatNormalMap ),
|
|
3034
|
+
texCoord: material.clearcoatNormalMap.channel
|
|
3035
|
+
};
|
|
3036
|
+
|
|
3037
|
+
if ( material.clearcoatNormalScale.x !== 1 ) clearcoatNormalMapDef.scale = material.clearcoatNormalScale.x;
|
|
3038
|
+
|
|
3039
|
+
writer.applyTextureTransform( clearcoatNormalMapDef, material.clearcoatNormalMap );
|
|
3040
|
+
extensionDef.clearcoatNormalTexture = clearcoatNormalMapDef;
|
|
3041
|
+
|
|
3042
|
+
}
|
|
3043
|
+
|
|
3044
|
+
materialDef.extensions = materialDef.extensions || {};
|
|
3045
|
+
materialDef.extensions[ this.name ] = extensionDef;
|
|
3046
|
+
|
|
3047
|
+
extensionsUsed[ this.name ] = true;
|
|
3048
|
+
|
|
3049
|
+
|
|
3050
|
+
}
|
|
3051
|
+
|
|
3052
|
+
}
|
|
3053
|
+
|
|
3054
|
+
/**
|
|
3055
|
+
* Materials dispersion Extension
|
|
3056
|
+
*
|
|
3057
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_dispersion
|
|
3058
|
+
*
|
|
3059
|
+
* @private
|
|
3060
|
+
*/
|
|
3061
|
+
class GLTFMaterialsDispersionExtension {
|
|
3062
|
+
|
|
3063
|
+
constructor( writer ) {
|
|
3064
|
+
|
|
3065
|
+
this.writer = writer;
|
|
3066
|
+
this.name = 'KHR_materials_dispersion';
|
|
3067
|
+
|
|
3068
|
+
}
|
|
3069
|
+
|
|
3070
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
3071
|
+
|
|
3072
|
+
if ( ! material.isMeshPhysicalMaterial || material.dispersion === 0 ) return;
|
|
3073
|
+
|
|
3074
|
+
const writer = this.writer;
|
|
3075
|
+
const extensionsUsed = writer.extensionsUsed;
|
|
3076
|
+
|
|
3077
|
+
const extensionDef = {};
|
|
3078
|
+
|
|
3079
|
+
extensionDef.dispersion = material.dispersion;
|
|
3080
|
+
|
|
3081
|
+
materialDef.extensions = materialDef.extensions || {};
|
|
3082
|
+
materialDef.extensions[ this.name ] = extensionDef;
|
|
3083
|
+
|
|
3084
|
+
extensionsUsed[ this.name ] = true;
|
|
3085
|
+
|
|
3086
|
+
}
|
|
3087
|
+
|
|
3088
|
+
}
|
|
3089
|
+
|
|
3090
|
+
/**
|
|
3091
|
+
* Iridescence Materials Extension
|
|
3092
|
+
*
|
|
3093
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_iridescence
|
|
3094
|
+
*
|
|
3095
|
+
* @private
|
|
3096
|
+
*/
|
|
3097
|
+
class GLTFMaterialsIridescenceExtension {
|
|
3098
|
+
|
|
3099
|
+
constructor( writer ) {
|
|
3100
|
+
|
|
3101
|
+
this.writer = writer;
|
|
3102
|
+
this.name = 'KHR_materials_iridescence';
|
|
3103
|
+
|
|
3104
|
+
}
|
|
3105
|
+
|
|
3106
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
3107
|
+
|
|
3108
|
+
if ( ! material.isMeshPhysicalMaterial || material.iridescence === 0 ) return;
|
|
3109
|
+
|
|
3110
|
+
const writer = this.writer;
|
|
3111
|
+
const extensionsUsed = writer.extensionsUsed;
|
|
3112
|
+
|
|
3113
|
+
const extensionDef = {};
|
|
3114
|
+
|
|
3115
|
+
extensionDef.iridescenceFactor = material.iridescence;
|
|
3116
|
+
|
|
3117
|
+
if ( material.iridescenceMap ) {
|
|
3118
|
+
|
|
3119
|
+
const iridescenceMapDef = {
|
|
3120
|
+
index: await writer.processTextureAsync( material.iridescenceMap ),
|
|
3121
|
+
texCoord: material.iridescenceMap.channel
|
|
3122
|
+
};
|
|
3123
|
+
writer.applyTextureTransform( iridescenceMapDef, material.iridescenceMap );
|
|
3124
|
+
extensionDef.iridescenceTexture = iridescenceMapDef;
|
|
3125
|
+
|
|
3126
|
+
}
|
|
3127
|
+
|
|
3128
|
+
extensionDef.iridescenceIor = material.iridescenceIOR;
|
|
3129
|
+
extensionDef.iridescenceThicknessMinimum = material.iridescenceThicknessMinimum;
|
|
3130
|
+
extensionDef.iridescenceThicknessMaximum = material.iridescenceThicknessMaximum;
|
|
3131
|
+
|
|
3132
|
+
if ( material.iridescenceThicknessMap ) {
|
|
3133
|
+
|
|
3134
|
+
const iridescenceThicknessMapDef = {
|
|
3135
|
+
index: await writer.processTextureAsync( material.iridescenceThicknessMap ),
|
|
3136
|
+
texCoord: material.iridescenceThicknessMap.channel
|
|
3137
|
+
};
|
|
3138
|
+
writer.applyTextureTransform( iridescenceThicknessMapDef, material.iridescenceThicknessMap );
|
|
3139
|
+
extensionDef.iridescenceThicknessTexture = iridescenceThicknessMapDef;
|
|
3140
|
+
|
|
3141
|
+
}
|
|
3142
|
+
|
|
3143
|
+
materialDef.extensions = materialDef.extensions || {};
|
|
3144
|
+
materialDef.extensions[ this.name ] = extensionDef;
|
|
3145
|
+
|
|
3146
|
+
extensionsUsed[ this.name ] = true;
|
|
3147
|
+
|
|
3148
|
+
}
|
|
3149
|
+
|
|
3150
|
+
}
|
|
3151
|
+
|
|
3152
|
+
/**
|
|
3153
|
+
* Transmission Materials Extension
|
|
3154
|
+
*
|
|
3155
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_transmission
|
|
3156
|
+
*
|
|
3157
|
+
* @private
|
|
3158
|
+
*/
|
|
3159
|
+
class GLTFMaterialsTransmissionExtension {
|
|
3160
|
+
|
|
3161
|
+
constructor( writer ) {
|
|
3162
|
+
|
|
3163
|
+
this.writer = writer;
|
|
3164
|
+
this.name = 'KHR_materials_transmission';
|
|
3165
|
+
|
|
3166
|
+
}
|
|
3167
|
+
|
|
3168
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
3169
|
+
|
|
3170
|
+
if ( ! material.isMeshPhysicalMaterial || material.transmission === 0 ) return;
|
|
3171
|
+
|
|
3172
|
+
const writer = this.writer;
|
|
3173
|
+
const extensionsUsed = writer.extensionsUsed;
|
|
3174
|
+
|
|
3175
|
+
const extensionDef = {};
|
|
3176
|
+
|
|
3177
|
+
extensionDef.transmissionFactor = material.transmission;
|
|
3178
|
+
|
|
3179
|
+
if ( material.transmissionMap ) {
|
|
3180
|
+
|
|
3181
|
+
const transmissionMapDef = {
|
|
3182
|
+
index: await writer.processTextureAsync( material.transmissionMap ),
|
|
3183
|
+
texCoord: material.transmissionMap.channel
|
|
3184
|
+
};
|
|
3185
|
+
writer.applyTextureTransform( transmissionMapDef, material.transmissionMap );
|
|
3186
|
+
extensionDef.transmissionTexture = transmissionMapDef;
|
|
3187
|
+
|
|
3188
|
+
}
|
|
3189
|
+
|
|
3190
|
+
materialDef.extensions = materialDef.extensions || {};
|
|
3191
|
+
materialDef.extensions[ this.name ] = extensionDef;
|
|
3192
|
+
|
|
3193
|
+
extensionsUsed[ this.name ] = true;
|
|
3194
|
+
|
|
3195
|
+
}
|
|
3196
|
+
|
|
3197
|
+
}
|
|
3198
|
+
|
|
3199
|
+
/**
|
|
3200
|
+
* Materials Volume Extension
|
|
3201
|
+
*
|
|
3202
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_volume
|
|
3203
|
+
*
|
|
3204
|
+
* @private
|
|
3205
|
+
*/
|
|
3206
|
+
class GLTFMaterialsVolumeExtension {
|
|
3207
|
+
|
|
3208
|
+
constructor( writer ) {
|
|
3209
|
+
|
|
3210
|
+
this.writer = writer;
|
|
3211
|
+
this.name = 'KHR_materials_volume';
|
|
3212
|
+
|
|
3213
|
+
}
|
|
3214
|
+
|
|
3215
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
3216
|
+
|
|
3217
|
+
if ( ! material.isMeshPhysicalMaterial || material.transmission === 0 ) return;
|
|
3218
|
+
|
|
3219
|
+
const writer = this.writer;
|
|
3220
|
+
const extensionsUsed = writer.extensionsUsed;
|
|
3221
|
+
|
|
3222
|
+
const extensionDef = {};
|
|
3223
|
+
|
|
3224
|
+
extensionDef.thicknessFactor = material.thickness;
|
|
3225
|
+
|
|
3226
|
+
if ( material.thicknessMap ) {
|
|
3227
|
+
|
|
3228
|
+
const thicknessMapDef = {
|
|
3229
|
+
index: await writer.processTextureAsync( material.thicknessMap ),
|
|
3230
|
+
texCoord: material.thicknessMap.channel
|
|
3231
|
+
};
|
|
3232
|
+
writer.applyTextureTransform( thicknessMapDef, material.thicknessMap );
|
|
3233
|
+
extensionDef.thicknessTexture = thicknessMapDef;
|
|
3234
|
+
|
|
3235
|
+
}
|
|
3236
|
+
|
|
3237
|
+
if ( material.attenuationDistance !== Infinity ) {
|
|
3238
|
+
|
|
3239
|
+
extensionDef.attenuationDistance = material.attenuationDistance;
|
|
3240
|
+
|
|
3241
|
+
}
|
|
3242
|
+
|
|
3243
|
+
extensionDef.attenuationColor = material.attenuationColor.toArray();
|
|
3244
|
+
|
|
3245
|
+
materialDef.extensions = materialDef.extensions || {};
|
|
3246
|
+
materialDef.extensions[ this.name ] = extensionDef;
|
|
3247
|
+
|
|
3248
|
+
extensionsUsed[ this.name ] = true;
|
|
3249
|
+
|
|
3250
|
+
}
|
|
3251
|
+
|
|
3252
|
+
}
|
|
3253
|
+
|
|
3254
|
+
/**
|
|
3255
|
+
* Materials ior Extension
|
|
3256
|
+
*
|
|
3257
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_ior
|
|
3258
|
+
*
|
|
3259
|
+
* @private
|
|
3260
|
+
*/
|
|
3261
|
+
class GLTFMaterialsIorExtension {
|
|
3262
|
+
|
|
3263
|
+
constructor( writer ) {
|
|
3264
|
+
|
|
3265
|
+
this.writer = writer;
|
|
3266
|
+
this.name = 'KHR_materials_ior';
|
|
3267
|
+
|
|
3268
|
+
}
|
|
3269
|
+
|
|
3270
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
3271
|
+
|
|
3272
|
+
if ( ! material.isMeshPhysicalMaterial || material.ior === 1.5 ) return;
|
|
3273
|
+
|
|
3274
|
+
const writer = this.writer;
|
|
3275
|
+
const extensionsUsed = writer.extensionsUsed;
|
|
3276
|
+
|
|
3277
|
+
const extensionDef = {};
|
|
3278
|
+
|
|
3279
|
+
extensionDef.ior = material.ior;
|
|
3280
|
+
|
|
3281
|
+
materialDef.extensions = materialDef.extensions || {};
|
|
3282
|
+
materialDef.extensions[ this.name ] = extensionDef;
|
|
3283
|
+
|
|
3284
|
+
extensionsUsed[ this.name ] = true;
|
|
3285
|
+
|
|
3286
|
+
}
|
|
3287
|
+
|
|
3288
|
+
}
|
|
3289
|
+
|
|
3290
|
+
/**
|
|
3291
|
+
* Materials specular Extension
|
|
3292
|
+
*
|
|
3293
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_specular
|
|
3294
|
+
*
|
|
3295
|
+
* @private
|
|
3296
|
+
*/
|
|
3297
|
+
class GLTFMaterialsSpecularExtension {
|
|
3298
|
+
|
|
3299
|
+
constructor( writer ) {
|
|
3300
|
+
|
|
3301
|
+
this.writer = writer;
|
|
3302
|
+
this.name = 'KHR_materials_specular';
|
|
3303
|
+
|
|
3304
|
+
}
|
|
3305
|
+
|
|
3306
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
3307
|
+
|
|
3308
|
+
if ( ! material.isMeshPhysicalMaterial || ( material.specularIntensity === 1.0 &&
|
|
3309
|
+
material.specularColor.equals( DEFAULT_SPECULAR_COLOR ) &&
|
|
3310
|
+
! material.specularIntensityMap && ! material.specularColorMap ) ) return;
|
|
3311
|
+
|
|
3312
|
+
const writer = this.writer;
|
|
3313
|
+
const extensionsUsed = writer.extensionsUsed;
|
|
3314
|
+
|
|
3315
|
+
const extensionDef = {};
|
|
3316
|
+
|
|
3317
|
+
if ( material.specularIntensityMap ) {
|
|
3318
|
+
|
|
3319
|
+
const specularIntensityMapDef = {
|
|
3320
|
+
index: await writer.processTextureAsync( material.specularIntensityMap ),
|
|
3321
|
+
texCoord: material.specularIntensityMap.channel
|
|
3322
|
+
};
|
|
3323
|
+
writer.applyTextureTransform( specularIntensityMapDef, material.specularIntensityMap );
|
|
3324
|
+
extensionDef.specularTexture = specularIntensityMapDef;
|
|
3325
|
+
|
|
3326
|
+
}
|
|
3327
|
+
|
|
3328
|
+
if ( material.specularColorMap ) {
|
|
3329
|
+
|
|
3330
|
+
const specularColorMapDef = {
|
|
3331
|
+
index: await writer.processTextureAsync( material.specularColorMap ),
|
|
3332
|
+
texCoord: material.specularColorMap.channel
|
|
3333
|
+
};
|
|
3334
|
+
writer.applyTextureTransform( specularColorMapDef, material.specularColorMap );
|
|
3335
|
+
extensionDef.specularColorTexture = specularColorMapDef;
|
|
3336
|
+
|
|
3337
|
+
}
|
|
3338
|
+
|
|
3339
|
+
extensionDef.specularFactor = material.specularIntensity;
|
|
3340
|
+
extensionDef.specularColorFactor = material.specularColor.toArray();
|
|
3341
|
+
|
|
3342
|
+
materialDef.extensions = materialDef.extensions || {};
|
|
3343
|
+
materialDef.extensions[ this.name ] = extensionDef;
|
|
3344
|
+
|
|
3345
|
+
extensionsUsed[ this.name ] = true;
|
|
3346
|
+
|
|
3347
|
+
}
|
|
3348
|
+
|
|
3349
|
+
}
|
|
3350
|
+
|
|
3351
|
+
/**
|
|
3352
|
+
* Sheen Materials Extension
|
|
3353
|
+
*
|
|
3354
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_sheen
|
|
3355
|
+
*
|
|
3356
|
+
* @private
|
|
3357
|
+
*/
|
|
3358
|
+
class GLTFMaterialsSheenExtension {
|
|
3359
|
+
|
|
3360
|
+
constructor( writer ) {
|
|
3361
|
+
|
|
3362
|
+
this.writer = writer;
|
|
3363
|
+
this.name = 'KHR_materials_sheen';
|
|
3364
|
+
|
|
3365
|
+
}
|
|
3366
|
+
|
|
3367
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
3368
|
+
|
|
3369
|
+
if ( ! material.isMeshPhysicalMaterial || material.sheen == 0.0 ) return;
|
|
3370
|
+
|
|
3371
|
+
const writer = this.writer;
|
|
3372
|
+
const extensionsUsed = writer.extensionsUsed;
|
|
3373
|
+
|
|
3374
|
+
const extensionDef = {};
|
|
3375
|
+
|
|
3376
|
+
if ( material.sheenRoughnessMap ) {
|
|
3377
|
+
|
|
3378
|
+
const sheenRoughnessMapDef = {
|
|
3379
|
+
index: await writer.processTextureAsync( material.sheenRoughnessMap ),
|
|
3380
|
+
texCoord: material.sheenRoughnessMap.channel
|
|
3381
|
+
};
|
|
3382
|
+
writer.applyTextureTransform( sheenRoughnessMapDef, material.sheenRoughnessMap );
|
|
3383
|
+
extensionDef.sheenRoughnessTexture = sheenRoughnessMapDef;
|
|
3384
|
+
|
|
3385
|
+
}
|
|
3386
|
+
|
|
3387
|
+
if ( material.sheenColorMap ) {
|
|
3388
|
+
|
|
3389
|
+
const sheenColorMapDef = {
|
|
3390
|
+
index: await writer.processTextureAsync( material.sheenColorMap ),
|
|
3391
|
+
texCoord: material.sheenColorMap.channel
|
|
3392
|
+
};
|
|
3393
|
+
writer.applyTextureTransform( sheenColorMapDef, material.sheenColorMap );
|
|
3394
|
+
extensionDef.sheenColorTexture = sheenColorMapDef;
|
|
3395
|
+
|
|
3396
|
+
}
|
|
3397
|
+
|
|
3398
|
+
extensionDef.sheenRoughnessFactor = material.sheenRoughness;
|
|
3399
|
+
extensionDef.sheenColorFactor = material.sheenColor.toArray();
|
|
3400
|
+
|
|
3401
|
+
materialDef.extensions = materialDef.extensions || {};
|
|
3402
|
+
materialDef.extensions[ this.name ] = extensionDef;
|
|
3403
|
+
|
|
3404
|
+
extensionsUsed[ this.name ] = true;
|
|
3405
|
+
|
|
3406
|
+
}
|
|
3407
|
+
|
|
3408
|
+
}
|
|
3409
|
+
|
|
3410
|
+
/**
|
|
3411
|
+
* Anisotropy Materials Extension
|
|
3412
|
+
*
|
|
3413
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_anisotropy
|
|
3414
|
+
*
|
|
3415
|
+
* @private
|
|
3416
|
+
*/
|
|
3417
|
+
class GLTFMaterialsAnisotropyExtension {
|
|
3418
|
+
|
|
3419
|
+
constructor( writer ) {
|
|
3420
|
+
|
|
3421
|
+
this.writer = writer;
|
|
3422
|
+
this.name = 'KHR_materials_anisotropy';
|
|
3423
|
+
|
|
3424
|
+
}
|
|
3425
|
+
|
|
3426
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
3427
|
+
|
|
3428
|
+
if ( ! material.isMeshPhysicalMaterial || material.anisotropy == 0.0 ) return;
|
|
3429
|
+
|
|
3430
|
+
const writer = this.writer;
|
|
3431
|
+
const extensionsUsed = writer.extensionsUsed;
|
|
3432
|
+
|
|
3433
|
+
const extensionDef = {};
|
|
3434
|
+
|
|
3435
|
+
if ( material.anisotropyMap ) {
|
|
3436
|
+
|
|
3437
|
+
const anisotropyMapDef = { index: await writer.processTextureAsync( material.anisotropyMap ) };
|
|
3438
|
+
writer.applyTextureTransform( anisotropyMapDef, material.anisotropyMap );
|
|
3439
|
+
extensionDef.anisotropyTexture = anisotropyMapDef;
|
|
3440
|
+
|
|
3441
|
+
}
|
|
3442
|
+
|
|
3443
|
+
extensionDef.anisotropyStrength = material.anisotropy;
|
|
3444
|
+
extensionDef.anisotropyRotation = material.anisotropyRotation;
|
|
3445
|
+
|
|
3446
|
+
materialDef.extensions = materialDef.extensions || {};
|
|
3447
|
+
materialDef.extensions[ this.name ] = extensionDef;
|
|
3448
|
+
|
|
3449
|
+
extensionsUsed[ this.name ] = true;
|
|
3450
|
+
|
|
3451
|
+
}
|
|
3452
|
+
|
|
3453
|
+
}
|
|
3454
|
+
|
|
3455
|
+
/**
|
|
3456
|
+
* Materials Emissive Strength Extension
|
|
3457
|
+
*
|
|
3458
|
+
* Specification: https://github.com/KhronosGroup/glTF/blob/5768b3ce0ef32bc39cdf1bef10b948586635ead3/extensions/2.0/Khronos/KHR_materials_emissive_strength/README.md
|
|
3459
|
+
*
|
|
3460
|
+
* @private
|
|
3461
|
+
*/
|
|
3462
|
+
class GLTFMaterialsEmissiveStrengthExtension {
|
|
3463
|
+
|
|
3464
|
+
constructor( writer ) {
|
|
3465
|
+
|
|
3466
|
+
this.writer = writer;
|
|
3467
|
+
this.name = 'KHR_materials_emissive_strength';
|
|
3468
|
+
|
|
3469
|
+
}
|
|
3470
|
+
|
|
3471
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
3472
|
+
|
|
3473
|
+
if ( ! material.isMeshStandardMaterial || material.emissiveIntensity === 1.0 ) return;
|
|
3474
|
+
|
|
3475
|
+
const writer = this.writer;
|
|
3476
|
+
const extensionsUsed = writer.extensionsUsed;
|
|
3477
|
+
|
|
3478
|
+
const extensionDef = {};
|
|
3479
|
+
|
|
3480
|
+
extensionDef.emissiveStrength = material.emissiveIntensity;
|
|
3481
|
+
|
|
3482
|
+
materialDef.extensions = materialDef.extensions || {};
|
|
3483
|
+
materialDef.extensions[ this.name ] = extensionDef;
|
|
3484
|
+
|
|
3485
|
+
extensionsUsed[ this.name ] = true;
|
|
3486
|
+
|
|
3487
|
+
}
|
|
3488
|
+
|
|
3489
|
+
}
|
|
3490
|
+
|
|
3491
|
+
|
|
3492
|
+
/**
|
|
3493
|
+
* Materials bump Extension
|
|
3494
|
+
*
|
|
3495
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/EXT_materials_bump
|
|
3496
|
+
*
|
|
3497
|
+
* @private
|
|
3498
|
+
*/
|
|
3499
|
+
class GLTFMaterialsBumpExtension {
|
|
3500
|
+
|
|
3501
|
+
constructor( writer ) {
|
|
3502
|
+
|
|
3503
|
+
this.writer = writer;
|
|
3504
|
+
this.name = 'EXT_materials_bump';
|
|
3505
|
+
|
|
3506
|
+
}
|
|
3507
|
+
|
|
3508
|
+
async writeMaterialAsync( material, materialDef ) {
|
|
3509
|
+
|
|
3510
|
+
if ( ! material.isMeshStandardMaterial || (
|
|
3511
|
+
material.bumpScale === 1 &&
|
|
3512
|
+
! material.bumpMap ) ) return;
|
|
3513
|
+
|
|
3514
|
+
const writer = this.writer;
|
|
3515
|
+
const extensionsUsed = writer.extensionsUsed;
|
|
3516
|
+
|
|
3517
|
+
const extensionDef = {};
|
|
3518
|
+
|
|
3519
|
+
if ( material.bumpMap ) {
|
|
3520
|
+
|
|
3521
|
+
const bumpMapDef = {
|
|
3522
|
+
index: await writer.processTextureAsync( material.bumpMap ),
|
|
3523
|
+
texCoord: material.bumpMap.channel
|
|
3524
|
+
};
|
|
3525
|
+
writer.applyTextureTransform( bumpMapDef, material.bumpMap );
|
|
3526
|
+
extensionDef.bumpTexture = bumpMapDef;
|
|
3527
|
+
|
|
3528
|
+
}
|
|
3529
|
+
|
|
3530
|
+
extensionDef.bumpFactor = material.bumpScale;
|
|
3531
|
+
|
|
3532
|
+
materialDef.extensions = materialDef.extensions || {};
|
|
3533
|
+
materialDef.extensions[ this.name ] = extensionDef;
|
|
3534
|
+
|
|
3535
|
+
extensionsUsed[ this.name ] = true;
|
|
3536
|
+
|
|
3537
|
+
}
|
|
3538
|
+
|
|
3539
|
+
}
|
|
3540
|
+
|
|
3541
|
+
/**
|
|
3542
|
+
* GPU Instancing Extension
|
|
3543
|
+
*
|
|
3544
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_mesh_gpu_instancing
|
|
3545
|
+
*
|
|
3546
|
+
* @private
|
|
3547
|
+
*/
|
|
3548
|
+
class GLTFMeshGpuInstancing {
|
|
3549
|
+
|
|
3550
|
+
constructor( writer ) {
|
|
3551
|
+
|
|
3552
|
+
this.writer = writer;
|
|
3553
|
+
this.name = 'EXT_mesh_gpu_instancing';
|
|
3554
|
+
|
|
3555
|
+
}
|
|
3556
|
+
|
|
3557
|
+
writeNode( object, nodeDef ) {
|
|
3558
|
+
|
|
3559
|
+
if ( ! object.isInstancedMesh ) return;
|
|
3560
|
+
|
|
3561
|
+
const writer = this.writer;
|
|
3562
|
+
|
|
3563
|
+
const mesh = object;
|
|
3564
|
+
|
|
3565
|
+
const translationAttr = new Float32Array( mesh.count * 3 );
|
|
3566
|
+
const rotationAttr = new Float32Array( mesh.count * 4 );
|
|
3567
|
+
const scaleAttr = new Float32Array( mesh.count * 3 );
|
|
3568
|
+
|
|
3569
|
+
const matrix = new Matrix4();
|
|
3570
|
+
const position = new Vector3();
|
|
3571
|
+
const quaternion = new Quaternion();
|
|
3572
|
+
const scale = new Vector3();
|
|
3573
|
+
|
|
3574
|
+
for ( let i = 0; i < mesh.count; i ++ ) {
|
|
3575
|
+
|
|
3576
|
+
mesh.getMatrixAt( i, matrix );
|
|
3577
|
+
matrix.decompose( position, quaternion, scale );
|
|
3578
|
+
|
|
3579
|
+
position.toArray( translationAttr, i * 3 );
|
|
3580
|
+
quaternion.toArray( rotationAttr, i * 4 );
|
|
3581
|
+
scale.toArray( scaleAttr, i * 3 );
|
|
3582
|
+
|
|
3583
|
+
}
|
|
3584
|
+
|
|
3585
|
+
const attributes = {
|
|
3586
|
+
TRANSLATION: writer.processAccessor( new BufferAttribute( translationAttr, 3 ) ),
|
|
3587
|
+
ROTATION: writer.processAccessor( new BufferAttribute( rotationAttr, 4 ) ),
|
|
3588
|
+
SCALE: writer.processAccessor( new BufferAttribute( scaleAttr, 3 ) ),
|
|
3589
|
+
};
|
|
3590
|
+
|
|
3591
|
+
if ( mesh.instanceColor )
|
|
3592
|
+
attributes._COLOR_0 = writer.processAccessor( mesh.instanceColor );
|
|
3593
|
+
|
|
3594
|
+
nodeDef.extensions = nodeDef.extensions || {};
|
|
3595
|
+
nodeDef.extensions[ this.name ] = { attributes };
|
|
3596
|
+
|
|
3597
|
+
writer.extensionsUsed[ this.name ] = true;
|
|
3598
|
+
writer.extensionsRequired[ this.name ] = true;
|
|
3599
|
+
|
|
3600
|
+
}
|
|
3601
|
+
|
|
3602
|
+
}
|
|
3603
|
+
|
|
3604
|
+
/**
|
|
3605
|
+
* Static utility functions
|
|
3606
|
+
*
|
|
3607
|
+
* @private
|
|
3608
|
+
*/
|
|
3609
|
+
GLTFExporter.Utils = {
|
|
3610
|
+
|
|
3611
|
+
insertKeyframe: function ( track, time ) {
|
|
3612
|
+
|
|
3613
|
+
const tolerance = 0.001; // 1ms
|
|
3614
|
+
const valueSize = track.getValueSize();
|
|
3615
|
+
|
|
3616
|
+
const times = new track.TimeBufferType( track.times.length + 1 );
|
|
3617
|
+
const values = new track.ValueBufferType( track.values.length + valueSize );
|
|
3618
|
+
const interpolant = track.createInterpolant( new track.ValueBufferType( valueSize ) );
|
|
3619
|
+
|
|
3620
|
+
let index;
|
|
3621
|
+
|
|
3622
|
+
if ( track.times.length === 0 ) {
|
|
3623
|
+
|
|
3624
|
+
times[ 0 ] = time;
|
|
3625
|
+
|
|
3626
|
+
for ( let i = 0; i < valueSize; i ++ ) {
|
|
3627
|
+
|
|
3628
|
+
values[ i ] = 0;
|
|
3629
|
+
|
|
3630
|
+
}
|
|
3631
|
+
|
|
3632
|
+
index = 0;
|
|
3633
|
+
|
|
3634
|
+
} else if ( time < track.times[ 0 ] ) {
|
|
3635
|
+
|
|
3636
|
+
if ( Math.abs( track.times[ 0 ] - time ) < tolerance ) return 0;
|
|
3637
|
+
|
|
3638
|
+
times[ 0 ] = time;
|
|
3639
|
+
times.set( track.times, 1 );
|
|
3640
|
+
|
|
3641
|
+
values.set( interpolant.evaluate( time ), 0 );
|
|
3642
|
+
values.set( track.values, valueSize );
|
|
3643
|
+
|
|
3644
|
+
index = 0;
|
|
3645
|
+
|
|
3646
|
+
} else if ( time > track.times[ track.times.length - 1 ] ) {
|
|
3647
|
+
|
|
3648
|
+
if ( Math.abs( track.times[ track.times.length - 1 ] - time ) < tolerance ) {
|
|
3649
|
+
|
|
3650
|
+
return track.times.length - 1;
|
|
3651
|
+
|
|
3652
|
+
}
|
|
3653
|
+
|
|
3654
|
+
times[ times.length - 1 ] = time;
|
|
3655
|
+
times.set( track.times, 0 );
|
|
3656
|
+
|
|
3657
|
+
values.set( track.values, 0 );
|
|
3658
|
+
values.set( interpolant.evaluate( time ), track.values.length );
|
|
3659
|
+
|
|
3660
|
+
index = times.length - 1;
|
|
3661
|
+
|
|
3662
|
+
} else {
|
|
3663
|
+
|
|
3664
|
+
for ( let i = 0; i < track.times.length; i ++ ) {
|
|
3665
|
+
|
|
3666
|
+
if ( Math.abs( track.times[ i ] - time ) < tolerance ) return i;
|
|
3667
|
+
|
|
3668
|
+
if ( track.times[ i ] < time && track.times[ i + 1 ] > time ) {
|
|
3669
|
+
|
|
3670
|
+
times.set( track.times.slice( 0, i + 1 ), 0 );
|
|
3671
|
+
times[ i + 1 ] = time;
|
|
3672
|
+
times.set( track.times.slice( i + 1 ), i + 2 );
|
|
3673
|
+
|
|
3674
|
+
values.set( track.values.slice( 0, ( i + 1 ) * valueSize ), 0 );
|
|
3675
|
+
values.set( interpolant.evaluate( time ), ( i + 1 ) * valueSize );
|
|
3676
|
+
values.set( track.values.slice( ( i + 1 ) * valueSize ), ( i + 2 ) * valueSize );
|
|
3677
|
+
|
|
3678
|
+
index = i + 1;
|
|
3679
|
+
|
|
3680
|
+
break;
|
|
3681
|
+
|
|
3682
|
+
}
|
|
3683
|
+
|
|
3684
|
+
}
|
|
3685
|
+
|
|
3686
|
+
}
|
|
3687
|
+
|
|
3688
|
+
track.times = times;
|
|
3689
|
+
track.values = values;
|
|
3690
|
+
|
|
3691
|
+
return index;
|
|
3692
|
+
|
|
3693
|
+
},
|
|
3694
|
+
|
|
3695
|
+
mergeMorphTargetTracks: function ( clip, root ) {
|
|
3696
|
+
|
|
3697
|
+
const tracks = [];
|
|
3698
|
+
const mergedTracks = {};
|
|
3699
|
+
const sourceTracks = clip.tracks;
|
|
3700
|
+
|
|
3701
|
+
for ( let i = 0; i < sourceTracks.length; ++ i ) {
|
|
3702
|
+
|
|
3703
|
+
let sourceTrack = sourceTracks[ i ];
|
|
3704
|
+
const sourceTrackBinding = PropertyBinding.parseTrackName( sourceTrack.name );
|
|
3705
|
+
const sourceTrackNode = PropertyBinding.findNode( root, sourceTrackBinding.nodeName );
|
|
3706
|
+
|
|
3707
|
+
if ( sourceTrackBinding.propertyName !== 'morphTargetInfluences' || sourceTrackBinding.propertyIndex === undefined ) {
|
|
3708
|
+
|
|
3709
|
+
// Tracks that don't affect morph targets, or that affect all morph targets together, can be left as-is.
|
|
3710
|
+
tracks.push( sourceTrack );
|
|
3711
|
+
continue;
|
|
3712
|
+
|
|
3713
|
+
}
|
|
3714
|
+
|
|
3715
|
+
if ( sourceTrack.createInterpolant !== sourceTrack.InterpolantFactoryMethodDiscrete
|
|
3716
|
+
&& sourceTrack.createInterpolant !== sourceTrack.InterpolantFactoryMethodLinear ) {
|
|
3717
|
+
|
|
3718
|
+
if ( sourceTrack.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline ) {
|
|
3719
|
+
|
|
3720
|
+
// This should never happen, because glTF morph target animations
|
|
3721
|
+
// affect all targets already.
|
|
3722
|
+
throw new Error( 'THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.' );
|
|
3723
|
+
|
|
3724
|
+
}
|
|
3725
|
+
|
|
3726
|
+
console.warn( 'THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.' );
|
|
3727
|
+
|
|
3728
|
+
sourceTrack = sourceTrack.clone();
|
|
3729
|
+
sourceTrack.setInterpolation( InterpolateLinear );
|
|
3730
|
+
|
|
3731
|
+
}
|
|
3732
|
+
|
|
3733
|
+
const targetCount = sourceTrackNode.morphTargetInfluences.length;
|
|
3734
|
+
const targetIndex = sourceTrackNode.morphTargetDictionary[ sourceTrackBinding.propertyIndex ];
|
|
3735
|
+
|
|
3736
|
+
if ( targetIndex === undefined ) {
|
|
3737
|
+
|
|
3738
|
+
throw new Error( 'THREE.GLTFExporter: Morph target name not found: ' + sourceTrackBinding.propertyIndex );
|
|
3739
|
+
|
|
3740
|
+
}
|
|
3741
|
+
|
|
3742
|
+
let mergedTrack;
|
|
3743
|
+
|
|
3744
|
+
// If this is the first time we've seen this object, create a new
|
|
3745
|
+
// track to store merged keyframe data for each morph target.
|
|
3746
|
+
if ( mergedTracks[ sourceTrackNode.uuid ] === undefined ) {
|
|
3747
|
+
|
|
3748
|
+
mergedTrack = sourceTrack.clone();
|
|
3749
|
+
|
|
3750
|
+
const values = new mergedTrack.ValueBufferType( targetCount * mergedTrack.times.length );
|
|
3751
|
+
|
|
3752
|
+
for ( let j = 0; j < mergedTrack.times.length; j ++ ) {
|
|
3753
|
+
|
|
3754
|
+
values[ j * targetCount + targetIndex ] = mergedTrack.values[ j ];
|
|
3755
|
+
|
|
3756
|
+
}
|
|
3757
|
+
|
|
3758
|
+
// We need to take into consideration the intended target node
|
|
3759
|
+
// of our original un-merged morphTarget animation.
|
|
3760
|
+
mergedTrack.name = ( sourceTrackBinding.nodeName || '' ) + '.morphTargetInfluences';
|
|
3761
|
+
mergedTrack.values = values;
|
|
3762
|
+
|
|
3763
|
+
mergedTracks[ sourceTrackNode.uuid ] = mergedTrack;
|
|
3764
|
+
tracks.push( mergedTrack );
|
|
3765
|
+
|
|
3766
|
+
continue;
|
|
3767
|
+
|
|
3768
|
+
}
|
|
3769
|
+
|
|
3770
|
+
const sourceInterpolant = sourceTrack.createInterpolant( new sourceTrack.ValueBufferType( 1 ) );
|
|
3771
|
+
|
|
3772
|
+
mergedTrack = mergedTracks[ sourceTrackNode.uuid ];
|
|
3773
|
+
|
|
3774
|
+
// For every existing keyframe of the merged track, write a (possibly
|
|
3775
|
+
// interpolated) value from the source track.
|
|
3776
|
+
for ( let j = 0; j < mergedTrack.times.length; j ++ ) {
|
|
3777
|
+
|
|
3778
|
+
mergedTrack.values[ j * targetCount + targetIndex ] = sourceInterpolant.evaluate( mergedTrack.times[ j ] );
|
|
3779
|
+
|
|
3780
|
+
}
|
|
3781
|
+
|
|
3782
|
+
// For every existing keyframe of the source track, write a (possibly
|
|
3783
|
+
// new) keyframe to the merged track. Values from the previous loop may
|
|
3784
|
+
// be written again, but keyframes are de-duplicated.
|
|
3785
|
+
for ( let j = 0; j < sourceTrack.times.length; j ++ ) {
|
|
3786
|
+
|
|
3787
|
+
const keyframeIndex = this.insertKeyframe( mergedTrack, sourceTrack.times[ j ] );
|
|
3788
|
+
mergedTrack.values[ keyframeIndex * targetCount + targetIndex ] = sourceTrack.values[ j ];
|
|
3789
|
+
|
|
3790
|
+
}
|
|
3791
|
+
|
|
3792
|
+
}
|
|
3793
|
+
|
|
3794
|
+
clip.tracks = tracks;
|
|
3795
|
+
|
|
3796
|
+
return clip;
|
|
3797
|
+
|
|
3798
|
+
},
|
|
3799
|
+
|
|
3800
|
+
toTypedBufferAttribute: function ( srcAttribute, TypedArray ) {
|
|
3801
|
+
|
|
3802
|
+
const dstAttribute = new BufferAttribute( new TypedArray( srcAttribute.count * srcAttribute.itemSize ), srcAttribute.itemSize, false );
|
|
3803
|
+
|
|
3804
|
+
if ( ! srcAttribute.normalized && ! srcAttribute.isInterleavedBufferAttribute ) {
|
|
3805
|
+
|
|
3806
|
+
dstAttribute.array.set( srcAttribute.array );
|
|
3807
|
+
|
|
3808
|
+
return dstAttribute;
|
|
3809
|
+
|
|
3810
|
+
}
|
|
3811
|
+
|
|
3812
|
+
for ( let i = 0, il = srcAttribute.count; i < il; i ++ ) {
|
|
3813
|
+
|
|
3814
|
+
for ( let j = 0; j < srcAttribute.itemSize; j ++ ) {
|
|
3815
|
+
|
|
3816
|
+
dstAttribute.setComponent( i, j, srcAttribute.getComponent( i, j ) );
|
|
3817
|
+
|
|
3818
|
+
}
|
|
3819
|
+
|
|
3820
|
+
}
|
|
3821
|
+
|
|
3822
|
+
return dstAttribute;
|
|
3823
|
+
|
|
3824
|
+
}
|
|
3825
|
+
|
|
3826
|
+
};
|
|
3827
|
+
|
|
3828
|
+
/**
|
|
3829
|
+
* Export options of `GLTFExporter`.
|
|
3830
|
+
*
|
|
3831
|
+
* @typedef {Object} GLTFExporter~Options
|
|
3832
|
+
* @property {boolean} [trs=false] - Export position, rotation and scale instead of matrix per node.
|
|
3833
|
+
* @property {boolean} [onlyVisible=true] - Export only visible 3D objects.
|
|
3834
|
+
* @property {boolean} [binary=false] - Export in binary (.glb) format, returning an ArrayBuffer.
|
|
3835
|
+
* @property {number} [maxTextureSize=Infinity] - Restricts the image maximum size (both width and height) to the given value.
|
|
3836
|
+
* @property {Array<AnimationClip>|Array<Array<AnimationClip>>} [animations=[]] - List of animations to be included in the export. When exporting a single 3D object or scene, this is a flat list of clips.
|
|
3837
|
+
* When exporting an array of multiple scenes, this must be a nested array with one list of clips per scene, matched to the input by index.
|
|
3838
|
+
* @property {boolean} [includeCustomExtensions=false] - Export custom glTF extensions defined on an object's `userData.gltfExtensions` property.
|
|
3839
|
+
* @property {string} [copyright=null] - Export with a copyright notice embedded in the glTF.
|
|
3840
|
+
**/
|
|
3841
|
+
|
|
3842
|
+
/**
|
|
3843
|
+
* onDone callback of `GLTFExporter`.
|
|
3844
|
+
*
|
|
3845
|
+
* @callback GLTFExporter~OnDone
|
|
3846
|
+
* @param {ArrayBuffer|string} result - The generated .gltf (JSON) or .glb (binary).
|
|
3847
|
+
*/
|
|
3848
|
+
|
|
3849
|
+
/**
|
|
3850
|
+
* onError callback of `GLTFExporter`.
|
|
3851
|
+
*
|
|
3852
|
+
* @callback GLTFExporter~OnError
|
|
3853
|
+
* @param {Error} error - The error object.
|
|
3854
|
+
*/
|
|
3855
|
+
|
|
3856
|
+
export { GLTFExporter };
|