@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,4660 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AmbientLight,
|
|
3
|
+
AnimationClip,
|
|
4
|
+
Bone,
|
|
5
|
+
BufferGeometry,
|
|
6
|
+
ClampToEdgeWrapping,
|
|
7
|
+
Color,
|
|
8
|
+
ColorManagement,
|
|
9
|
+
DirectionalLight,
|
|
10
|
+
EquirectangularReflectionMapping,
|
|
11
|
+
Euler,
|
|
12
|
+
FileLoader,
|
|
13
|
+
Float32BufferAttribute,
|
|
14
|
+
Group,
|
|
15
|
+
Line,
|
|
16
|
+
LineBasicMaterial,
|
|
17
|
+
Loader,
|
|
18
|
+
LoaderUtils,
|
|
19
|
+
MathUtils,
|
|
20
|
+
Matrix3,
|
|
21
|
+
Matrix4,
|
|
22
|
+
Mesh,
|
|
23
|
+
MeshLambertMaterial,
|
|
24
|
+
MeshPhongMaterial,
|
|
25
|
+
NumberKeyframeTrack,
|
|
26
|
+
Object3D,
|
|
27
|
+
PerspectiveCamera,
|
|
28
|
+
PointLight,
|
|
29
|
+
PropertyBinding,
|
|
30
|
+
Quaternion,
|
|
31
|
+
QuaternionKeyframeTrack,
|
|
32
|
+
RepeatWrapping,
|
|
33
|
+
SRGBColorSpace,
|
|
34
|
+
ShapeUtils,
|
|
35
|
+
Skeleton,
|
|
36
|
+
SkinnedMesh,
|
|
37
|
+
SpotLight,
|
|
38
|
+
Texture,
|
|
39
|
+
TextureLoader,
|
|
40
|
+
Uint16BufferAttribute,
|
|
41
|
+
Vector2,
|
|
42
|
+
Vector3,
|
|
43
|
+
Vector4,
|
|
44
|
+
VectorKeyframeTrack
|
|
45
|
+
} from 'three';
|
|
46
|
+
|
|
47
|
+
import { unzlibSync } from '../libs/fflate.module.js';
|
|
48
|
+
import { NURBSCurve } from '../curves/NURBSCurve.js';
|
|
49
|
+
|
|
50
|
+
let fbxTree;
|
|
51
|
+
let connections;
|
|
52
|
+
let sceneGraph;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* A loader for the FBX format.
|
|
56
|
+
*
|
|
57
|
+
* Requires FBX file to be >= 7.0 and in ASCII or >= 6400 in Binary format.
|
|
58
|
+
* Versions lower than this may load but will probably have errors.
|
|
59
|
+
*
|
|
60
|
+
* Needs Support:
|
|
61
|
+
* - Morph normals / blend shape normals
|
|
62
|
+
*
|
|
63
|
+
* FBX format references:
|
|
64
|
+
* - [C++ SDK reference](https://help.autodesk.com/view/FBX/2017/ENU/?guid=__cpp_ref_index_html)
|
|
65
|
+
*
|
|
66
|
+
* Binary format specification:
|
|
67
|
+
* - [FBX binary file format specification](https://code.blender.org/2013/08/fbx-binary-file-format-specification/)
|
|
68
|
+
*
|
|
69
|
+
* ```js
|
|
70
|
+
* const loader = new FBXLoader();
|
|
71
|
+
* const object = await loader.loadAsync( 'models/fbx/stanford-bunny.fbx' );
|
|
72
|
+
* scene.add( object );
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @augments Loader
|
|
76
|
+
* @three_import import { FBXLoader } from 'three/addons/loaders/FBXLoader.js';
|
|
77
|
+
*/
|
|
78
|
+
class FBXLoader extends Loader {
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Constructs a new FBX loader.
|
|
82
|
+
*
|
|
83
|
+
* @param {LoadingManager} [manager] - The loading manager.
|
|
84
|
+
*/
|
|
85
|
+
constructor( manager ) {
|
|
86
|
+
|
|
87
|
+
super( manager );
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Whether to trim animation clips to the time range of their
|
|
91
|
+
* animation stacks and shift them to start at time zero. Useful
|
|
92
|
+
* for assets that define multiple clips on a single timeline.
|
|
93
|
+
*
|
|
94
|
+
* @type {boolean}
|
|
95
|
+
* @default false
|
|
96
|
+
*/
|
|
97
|
+
this.trimAnimationClips = false;
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Starts loading from the given URL and passes the loaded FBX asset
|
|
103
|
+
* to the `onLoad()` callback.
|
|
104
|
+
*
|
|
105
|
+
* @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
|
|
106
|
+
* @param {function(Group)} onLoad - Executed when the loading process has been finished.
|
|
107
|
+
* @param {onProgressCallback} onProgress - Executed while the loading is in progress.
|
|
108
|
+
* @param {onErrorCallback} onError - Executed when errors occur.
|
|
109
|
+
*/
|
|
110
|
+
load( url, onLoad, onProgress, onError ) {
|
|
111
|
+
|
|
112
|
+
const scope = this;
|
|
113
|
+
|
|
114
|
+
const path = ( scope.path === '' ) ? LoaderUtils.extractUrlBase( url ) : scope.path;
|
|
115
|
+
|
|
116
|
+
const loader = new FileLoader( this.manager );
|
|
117
|
+
loader.setPriority( this.priority );
|
|
118
|
+
loader.setCache( this.cache );
|
|
119
|
+
loader.setPath( scope.path );
|
|
120
|
+
loader.setResponseType( 'arraybuffer' );
|
|
121
|
+
loader.setRequestHeader( scope.requestHeader );
|
|
122
|
+
loader.setWithCredentials( scope.withCredentials );
|
|
123
|
+
|
|
124
|
+
loader.load( url, function ( buffer ) {
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
|
|
128
|
+
onLoad( scope.parse( buffer, path ) );
|
|
129
|
+
|
|
130
|
+
} catch ( e ) {
|
|
131
|
+
|
|
132
|
+
if ( onError ) {
|
|
133
|
+
|
|
134
|
+
onError( e );
|
|
135
|
+
|
|
136
|
+
} else {
|
|
137
|
+
|
|
138
|
+
console.error( e );
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
scope.manager.itemError( url );
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
}, onProgress, onError );
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Parses the given FBX data and returns the resulting group.
|
|
152
|
+
*
|
|
153
|
+
* @param {ArrayBuffer} FBXBuffer - The raw FBX data as an array buffer.
|
|
154
|
+
* @param {string} path - The URL base path.
|
|
155
|
+
* @return {Group} An object representing the parsed asset.
|
|
156
|
+
*/
|
|
157
|
+
parse( FBXBuffer, path ) {
|
|
158
|
+
|
|
159
|
+
if ( isFbxFormatBinary( FBXBuffer ) ) {
|
|
160
|
+
|
|
161
|
+
fbxTree = new BinaryParser().parse( FBXBuffer );
|
|
162
|
+
|
|
163
|
+
} else {
|
|
164
|
+
|
|
165
|
+
const FBXText = convertArrayBufferToString( FBXBuffer );
|
|
166
|
+
|
|
167
|
+
if ( ! isFbxFormatASCII( FBXText ) ) {
|
|
168
|
+
|
|
169
|
+
throw new Error( 'THREE.FBXLoader: Unknown format.' );
|
|
170
|
+
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if ( getFbxVersion( FBXText ) < 7000 ) {
|
|
174
|
+
|
|
175
|
+
throw new Error( 'THREE.FBXLoader: FBX version not supported, FileVersion: ' + getFbxVersion( FBXText ) );
|
|
176
|
+
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
fbxTree = new TextParser().parse( FBXText );
|
|
180
|
+
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// console.log( fbxTree );
|
|
184
|
+
|
|
185
|
+
const textureLoader = new TextureLoader( this.manager ).setPath( this.resourcePath || path ).setCrossOrigin( this.crossOrigin );
|
|
186
|
+
textureLoader.setPriority( this.priority );
|
|
187
|
+
textureLoader.setCache( this.cache );
|
|
188
|
+
|
|
189
|
+
return new FBXTreeParser( textureLoader, this.manager, this.trimAnimationClips ).parse( fbxTree );
|
|
190
|
+
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Parse the FBXTree object returned by the BinaryParser or TextParser and return a Group
|
|
196
|
+
class FBXTreeParser {
|
|
197
|
+
|
|
198
|
+
constructor( textureLoader, manager, trimAnimationClips ) {
|
|
199
|
+
|
|
200
|
+
this.textureLoader = textureLoader;
|
|
201
|
+
this.manager = manager;
|
|
202
|
+
this.trimAnimationClips = trimAnimationClips;
|
|
203
|
+
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
parse() {
|
|
207
|
+
|
|
208
|
+
connections = this.parseConnections();
|
|
209
|
+
|
|
210
|
+
const images = this.parseImages();
|
|
211
|
+
const textures = this.parseTextures( images );
|
|
212
|
+
const materials = this.parseMaterials( textures );
|
|
213
|
+
const deformers = this.parseDeformers();
|
|
214
|
+
const geometryMap = new GeometryParser().parse( deformers );
|
|
215
|
+
|
|
216
|
+
this.parseScene( deformers, geometryMap, materials );
|
|
217
|
+
|
|
218
|
+
return sceneGraph;
|
|
219
|
+
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Parses FBXTree.Connections which holds parent-child connections between objects (e.g. material -> texture, model->geometry )
|
|
223
|
+
// and details the connection type
|
|
224
|
+
parseConnections() {
|
|
225
|
+
|
|
226
|
+
const connectionMap = new Map();
|
|
227
|
+
|
|
228
|
+
if ( 'Connections' in fbxTree ) {
|
|
229
|
+
|
|
230
|
+
const rawConnections = fbxTree.Connections.connections;
|
|
231
|
+
|
|
232
|
+
rawConnections.forEach( function ( rawConnection ) {
|
|
233
|
+
|
|
234
|
+
const fromID = rawConnection[ 0 ];
|
|
235
|
+
const toID = rawConnection[ 1 ];
|
|
236
|
+
const relationship = rawConnection[ 2 ];
|
|
237
|
+
|
|
238
|
+
if ( ! connectionMap.has( fromID ) ) {
|
|
239
|
+
|
|
240
|
+
connectionMap.set( fromID, {
|
|
241
|
+
parents: [],
|
|
242
|
+
children: []
|
|
243
|
+
} );
|
|
244
|
+
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const parentRelationship = { ID: toID, relationship: relationship };
|
|
248
|
+
connectionMap.get( fromID ).parents.push( parentRelationship );
|
|
249
|
+
|
|
250
|
+
if ( ! connectionMap.has( toID ) ) {
|
|
251
|
+
|
|
252
|
+
connectionMap.set( toID, {
|
|
253
|
+
parents: [],
|
|
254
|
+
children: []
|
|
255
|
+
} );
|
|
256
|
+
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const childRelationship = { ID: fromID, relationship: relationship };
|
|
260
|
+
connectionMap.get( toID ).children.push( childRelationship );
|
|
261
|
+
|
|
262
|
+
} );
|
|
263
|
+
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return connectionMap;
|
|
267
|
+
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Parse FBXTree.Objects.Video for embedded image data
|
|
271
|
+
// These images are connected to textures in FBXTree.Objects.Textures
|
|
272
|
+
// via FBXTree.Connections.
|
|
273
|
+
parseImages() {
|
|
274
|
+
|
|
275
|
+
const images = {};
|
|
276
|
+
const blobs = {};
|
|
277
|
+
|
|
278
|
+
if ( 'Video' in fbxTree.Objects ) {
|
|
279
|
+
|
|
280
|
+
const videoNodes = fbxTree.Objects.Video;
|
|
281
|
+
|
|
282
|
+
for ( const nodeID in videoNodes ) {
|
|
283
|
+
|
|
284
|
+
const videoNode = videoNodes[ nodeID ];
|
|
285
|
+
|
|
286
|
+
const id = parseInt( nodeID );
|
|
287
|
+
|
|
288
|
+
images[ id ] = videoNode.RelativeFilename || videoNode.Filename;
|
|
289
|
+
|
|
290
|
+
// raw image data is in videoNode.Content
|
|
291
|
+
if ( 'Content' in videoNode ) {
|
|
292
|
+
|
|
293
|
+
const arrayBufferContent = ( videoNode.Content instanceof ArrayBuffer ) && ( videoNode.Content.byteLength > 0 );
|
|
294
|
+
const base64Content = ( typeof videoNode.Content === 'string' ) && ( videoNode.Content !== '' );
|
|
295
|
+
|
|
296
|
+
if ( arrayBufferContent || base64Content ) {
|
|
297
|
+
|
|
298
|
+
const image = this.parseImage( videoNodes[ nodeID ] );
|
|
299
|
+
|
|
300
|
+
blobs[ videoNode.RelativeFilename || videoNode.Filename ] = image;
|
|
301
|
+
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
for ( const id in images ) {
|
|
311
|
+
|
|
312
|
+
const filename = images[ id ];
|
|
313
|
+
|
|
314
|
+
if ( blobs[ filename ] !== undefined ) images[ id ] = blobs[ filename ];
|
|
315
|
+
else images[ id ] = images[ id ].split( '\\' ).pop();
|
|
316
|
+
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return images;
|
|
320
|
+
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Parse embedded image data in FBXTree.Video.Content
|
|
324
|
+
parseImage( videoNode ) {
|
|
325
|
+
|
|
326
|
+
const content = videoNode.Content;
|
|
327
|
+
const fileName = videoNode.RelativeFilename || videoNode.Filename;
|
|
328
|
+
const extension = fileName.slice( fileName.lastIndexOf( '.' ) + 1 ).toLowerCase();
|
|
329
|
+
|
|
330
|
+
let type;
|
|
331
|
+
|
|
332
|
+
switch ( extension ) {
|
|
333
|
+
|
|
334
|
+
case 'bmp':
|
|
335
|
+
|
|
336
|
+
type = 'image/bmp';
|
|
337
|
+
break;
|
|
338
|
+
|
|
339
|
+
case 'jpg':
|
|
340
|
+
case 'jpeg':
|
|
341
|
+
|
|
342
|
+
type = 'image/jpeg';
|
|
343
|
+
break;
|
|
344
|
+
|
|
345
|
+
case 'png':
|
|
346
|
+
|
|
347
|
+
type = 'image/png';
|
|
348
|
+
break;
|
|
349
|
+
|
|
350
|
+
case 'tif':
|
|
351
|
+
|
|
352
|
+
type = 'image/tiff';
|
|
353
|
+
break;
|
|
354
|
+
|
|
355
|
+
case 'tga':
|
|
356
|
+
|
|
357
|
+
if ( this.manager.getHandler( '.tga' ) === null ) {
|
|
358
|
+
|
|
359
|
+
console.warn( 'FBXLoader: TGA loader not found, skipping ', fileName );
|
|
360
|
+
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
type = 'image/tga';
|
|
364
|
+
break;
|
|
365
|
+
|
|
366
|
+
case 'webp':
|
|
367
|
+
|
|
368
|
+
type = 'image/webp';
|
|
369
|
+
break;
|
|
370
|
+
|
|
371
|
+
default:
|
|
372
|
+
|
|
373
|
+
console.warn( 'FBXLoader: Image type "' + extension + '" is not supported.' );
|
|
374
|
+
return;
|
|
375
|
+
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if ( typeof content === 'string' ) { // ASCII format
|
|
379
|
+
|
|
380
|
+
return 'data:' + type + ';base64,' + content;
|
|
381
|
+
|
|
382
|
+
} else { // Binary Format
|
|
383
|
+
|
|
384
|
+
const array = new Uint8Array( content );
|
|
385
|
+
return URL.createObjectURL( new Blob( [ array ], { type: type } ) );
|
|
386
|
+
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// Parse nodes in FBXTree.Objects.Texture
|
|
392
|
+
// These contain details such as UV scaling, cropping, rotation etc and are connected
|
|
393
|
+
// to images in FBXTree.Objects.Video
|
|
394
|
+
parseTextures( images ) {
|
|
395
|
+
|
|
396
|
+
const textureMap = new Map();
|
|
397
|
+
|
|
398
|
+
if ( 'Texture' in fbxTree.Objects ) {
|
|
399
|
+
|
|
400
|
+
const textureNodes = fbxTree.Objects.Texture;
|
|
401
|
+
for ( const nodeID in textureNodes ) {
|
|
402
|
+
|
|
403
|
+
const texture = this.parseTexture( textureNodes[ nodeID ], images );
|
|
404
|
+
textureMap.set( parseInt( nodeID ), texture );
|
|
405
|
+
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
return textureMap;
|
|
411
|
+
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// Parse individual node in FBXTree.Objects.Texture
|
|
415
|
+
parseTexture( textureNode, images ) {
|
|
416
|
+
|
|
417
|
+
const texture = this.loadTexture( textureNode, images );
|
|
418
|
+
|
|
419
|
+
texture.ID = textureNode.id;
|
|
420
|
+
|
|
421
|
+
texture.name = textureNode.attrName;
|
|
422
|
+
|
|
423
|
+
const wrapModeU = textureNode.WrapModeU;
|
|
424
|
+
const wrapModeV = textureNode.WrapModeV;
|
|
425
|
+
|
|
426
|
+
const valueU = wrapModeU !== undefined ? wrapModeU.value : 0;
|
|
427
|
+
const valueV = wrapModeV !== undefined ? wrapModeV.value : 0;
|
|
428
|
+
|
|
429
|
+
// http://download.autodesk.com/us/fbx/SDKdocs/FBX_SDK_Help/files/fbxsdkref/class_k_fbx_texture.html#889640e63e2e681259ea81061b85143a
|
|
430
|
+
// 0: repeat(default), 1: clamp
|
|
431
|
+
|
|
432
|
+
texture.wrapS = valueU === 0 ? RepeatWrapping : ClampToEdgeWrapping;
|
|
433
|
+
texture.wrapT = valueV === 0 ? RepeatWrapping : ClampToEdgeWrapping;
|
|
434
|
+
|
|
435
|
+
if ( 'Scaling' in textureNode ) {
|
|
436
|
+
|
|
437
|
+
const values = textureNode.Scaling.value;
|
|
438
|
+
|
|
439
|
+
texture.repeat.x = values[ 0 ];
|
|
440
|
+
texture.repeat.y = values[ 1 ];
|
|
441
|
+
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
if ( 'Translation' in textureNode ) {
|
|
445
|
+
|
|
446
|
+
const values = textureNode.Translation.value;
|
|
447
|
+
|
|
448
|
+
texture.offset.x = values[ 0 ];
|
|
449
|
+
texture.offset.y = values[ 1 ];
|
|
450
|
+
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
return texture;
|
|
454
|
+
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// load a texture specified as a blob or data URI, or via an external URL using TextureLoader
|
|
458
|
+
loadTexture( textureNode, images ) {
|
|
459
|
+
|
|
460
|
+
const extension = textureNode.FileName.split( '.' ).pop().toLowerCase();
|
|
461
|
+
|
|
462
|
+
let loader = this.manager.getHandler( `.${extension}` );
|
|
463
|
+
if ( loader === null ) loader = this.textureLoader;
|
|
464
|
+
|
|
465
|
+
const loaderPath = loader.path;
|
|
466
|
+
|
|
467
|
+
if ( ! loaderPath ) {
|
|
468
|
+
|
|
469
|
+
loader.setPath( this.textureLoader.path );
|
|
470
|
+
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
const children = connections.get( textureNode.id ).children;
|
|
474
|
+
|
|
475
|
+
let fileName;
|
|
476
|
+
|
|
477
|
+
if ( children !== undefined && children.length > 0 && images[ children[ 0 ].ID ] !== undefined ) {
|
|
478
|
+
|
|
479
|
+
fileName = images[ children[ 0 ].ID ];
|
|
480
|
+
|
|
481
|
+
if ( fileName.indexOf( 'blob:' ) === 0 || fileName.indexOf( 'data:' ) === 0 ) {
|
|
482
|
+
|
|
483
|
+
loader.setPath( undefined );
|
|
484
|
+
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
if ( fileName === undefined ) {
|
|
490
|
+
|
|
491
|
+
console.warn( 'FBXLoader: Undefined filename, creating placeholder texture.' );
|
|
492
|
+
return new Texture();
|
|
493
|
+
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
const texture = loader.load( fileName );
|
|
497
|
+
|
|
498
|
+
// revert to initial path
|
|
499
|
+
loader.setPath( loaderPath );
|
|
500
|
+
|
|
501
|
+
return texture;
|
|
502
|
+
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// Parse nodes in FBXTree.Objects.Material
|
|
506
|
+
parseMaterials( textureMap ) {
|
|
507
|
+
|
|
508
|
+
const materialMap = new Map();
|
|
509
|
+
|
|
510
|
+
if ( 'Material' in fbxTree.Objects ) {
|
|
511
|
+
|
|
512
|
+
const materialNodes = fbxTree.Objects.Material;
|
|
513
|
+
|
|
514
|
+
for ( const nodeID in materialNodes ) {
|
|
515
|
+
|
|
516
|
+
const material = this.parseMaterial( materialNodes[ nodeID ], textureMap );
|
|
517
|
+
|
|
518
|
+
if ( material !== null ) materialMap.set( parseInt( nodeID ), material );
|
|
519
|
+
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
return materialMap;
|
|
525
|
+
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// Parse single node in FBXTree.Objects.Material
|
|
529
|
+
// Materials are connected to texture maps in FBXTree.Objects.Textures
|
|
530
|
+
// FBX format currently only supports Lambert and Phong shading models
|
|
531
|
+
parseMaterial( materialNode, textureMap ) {
|
|
532
|
+
|
|
533
|
+
const ID = materialNode.id;
|
|
534
|
+
const name = materialNode.attrName;
|
|
535
|
+
let type = materialNode.ShadingModel;
|
|
536
|
+
|
|
537
|
+
// Case where FBX wraps shading model in property object.
|
|
538
|
+
if ( typeof type === 'object' ) {
|
|
539
|
+
|
|
540
|
+
type = type.value;
|
|
541
|
+
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// Ignore unused materials which don't have any connections.
|
|
545
|
+
if ( ! connections.has( ID ) ) return null;
|
|
546
|
+
|
|
547
|
+
const parameters = this.parseParameters( materialNode, textureMap, ID );
|
|
548
|
+
|
|
549
|
+
let material;
|
|
550
|
+
|
|
551
|
+
switch ( type.toLowerCase() ) {
|
|
552
|
+
|
|
553
|
+
case 'phong':
|
|
554
|
+
material = new MeshPhongMaterial();
|
|
555
|
+
break;
|
|
556
|
+
case 'lambert':
|
|
557
|
+
material = new MeshLambertMaterial();
|
|
558
|
+
break;
|
|
559
|
+
default:
|
|
560
|
+
console.warn( 'THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.', type );
|
|
561
|
+
material = new MeshPhongMaterial();
|
|
562
|
+
break;
|
|
563
|
+
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
material.setValues( parameters );
|
|
567
|
+
material.name = name;
|
|
568
|
+
|
|
569
|
+
return material;
|
|
570
|
+
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// Parse FBX material and return parameters suitable for a three.js material
|
|
574
|
+
// Also parse the texture map and return any textures associated with the material
|
|
575
|
+
parseParameters( materialNode, textureMap, ID ) {
|
|
576
|
+
|
|
577
|
+
const parameters = {};
|
|
578
|
+
|
|
579
|
+
if ( materialNode.BumpFactor ) {
|
|
580
|
+
|
|
581
|
+
parameters.bumpScale = materialNode.BumpFactor.value;
|
|
582
|
+
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
if ( materialNode.Diffuse ) {
|
|
586
|
+
|
|
587
|
+
parameters.color = ColorManagement.colorSpaceToWorking( new Color().fromArray( materialNode.Diffuse.value ), SRGBColorSpace );
|
|
588
|
+
|
|
589
|
+
} else if ( materialNode.DiffuseColor && ( materialNode.DiffuseColor.type === 'Color' || materialNode.DiffuseColor.type === 'ColorRGB' ) ) {
|
|
590
|
+
|
|
591
|
+
// The blender exporter exports diffuse here instead of in materialNode.Diffuse
|
|
592
|
+
parameters.color = ColorManagement.colorSpaceToWorking( new Color().fromArray( materialNode.DiffuseColor.value ), SRGBColorSpace );
|
|
593
|
+
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
if ( materialNode.DisplacementFactor ) {
|
|
597
|
+
|
|
598
|
+
parameters.displacementScale = materialNode.DisplacementFactor.value;
|
|
599
|
+
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
if ( materialNode.Emissive ) {
|
|
603
|
+
|
|
604
|
+
parameters.emissive = ColorManagement.colorSpaceToWorking( new Color().fromArray( materialNode.Emissive.value ), SRGBColorSpace );
|
|
605
|
+
|
|
606
|
+
} else if ( materialNode.EmissiveColor && ( materialNode.EmissiveColor.type === 'Color' || materialNode.EmissiveColor.type === 'ColorRGB' ) ) {
|
|
607
|
+
|
|
608
|
+
// The blender exporter exports emissive color here instead of in materialNode.Emissive
|
|
609
|
+
parameters.emissive = ColorManagement.colorSpaceToWorking( new Color().fromArray( materialNode.EmissiveColor.value ), SRGBColorSpace );
|
|
610
|
+
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
if ( materialNode.EmissiveFactor ) {
|
|
614
|
+
|
|
615
|
+
parameters.emissiveIntensity = parseFloat( materialNode.EmissiveFactor.value );
|
|
616
|
+
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
// the transparency handling is implemented based on Blender's approach:
|
|
620
|
+
// https://github.com/blender/blender/blob/main/scripts/addons_core/io_scene_fbx/import_fbx.py
|
|
621
|
+
|
|
622
|
+
parameters.opacity = 1 - ( materialNode.TransparencyFactor ? parseFloat( materialNode.TransparencyFactor.value ) : 0 );
|
|
623
|
+
|
|
624
|
+
if ( parameters.opacity === 1 || parameters.opacity === 0 ) {
|
|
625
|
+
|
|
626
|
+
parameters.opacity = ( materialNode.Opacity ? parseFloat( materialNode.Opacity.value ) : null );
|
|
627
|
+
|
|
628
|
+
if ( parameters.opacity === null ) {
|
|
629
|
+
|
|
630
|
+
// Default to opaque. Some exporters (e.g. 3ds Max) define TransparentColor
|
|
631
|
+
// as white (1,1,1) without intending transparency, which makes the Unity-style
|
|
632
|
+
// fallback of `1 - TransparentColor.r` produce incorrect zero opacity.
|
|
633
|
+
parameters.opacity = 1;
|
|
634
|
+
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
if ( parameters.opacity < 1.0 ) {
|
|
640
|
+
|
|
641
|
+
parameters.transparent = true;
|
|
642
|
+
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
if ( materialNode.ReflectionFactor ) {
|
|
646
|
+
|
|
647
|
+
parameters.reflectivity = materialNode.ReflectionFactor.value;
|
|
648
|
+
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
if ( materialNode.Shininess ) {
|
|
652
|
+
|
|
653
|
+
parameters.shininess = materialNode.Shininess.value;
|
|
654
|
+
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
if ( materialNode.Specular ) {
|
|
658
|
+
|
|
659
|
+
parameters.specular = ColorManagement.colorSpaceToWorking( new Color().fromArray( materialNode.Specular.value ), SRGBColorSpace );
|
|
660
|
+
|
|
661
|
+
} else if ( materialNode.SpecularColor && materialNode.SpecularColor.type === 'Color' ) {
|
|
662
|
+
|
|
663
|
+
// The blender exporter exports specular color here instead of in materialNode.Specular
|
|
664
|
+
parameters.specular = ColorManagement.colorSpaceToWorking( new Color().fromArray( materialNode.SpecularColor.value ), SRGBColorSpace );
|
|
665
|
+
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
const scope = this;
|
|
669
|
+
connections.get( ID ).children.forEach( function ( child ) {
|
|
670
|
+
|
|
671
|
+
const type = child.relationship;
|
|
672
|
+
|
|
673
|
+
switch ( type ) {
|
|
674
|
+
|
|
675
|
+
case 'Bump':
|
|
676
|
+
parameters.bumpMap = scope.getTexture( textureMap, child.ID );
|
|
677
|
+
break;
|
|
678
|
+
|
|
679
|
+
case 'Maya|TEX_ao_map':
|
|
680
|
+
parameters.aoMap = scope.getTexture( textureMap, child.ID );
|
|
681
|
+
break;
|
|
682
|
+
|
|
683
|
+
case 'DiffuseColor':
|
|
684
|
+
case 'Maya|TEX_color_map':
|
|
685
|
+
parameters.map = scope.getTexture( textureMap, child.ID );
|
|
686
|
+
if ( parameters.map !== undefined ) {
|
|
687
|
+
|
|
688
|
+
parameters.map.colorSpace = SRGBColorSpace;
|
|
689
|
+
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
break;
|
|
693
|
+
|
|
694
|
+
case 'DisplacementColor':
|
|
695
|
+
parameters.displacementMap = scope.getTexture( textureMap, child.ID );
|
|
696
|
+
break;
|
|
697
|
+
|
|
698
|
+
case 'EmissiveColor':
|
|
699
|
+
parameters.emissiveMap = scope.getTexture( textureMap, child.ID );
|
|
700
|
+
if ( parameters.emissiveMap !== undefined ) {
|
|
701
|
+
|
|
702
|
+
parameters.emissiveMap.colorSpace = SRGBColorSpace;
|
|
703
|
+
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
break;
|
|
707
|
+
|
|
708
|
+
case 'NormalMap':
|
|
709
|
+
case 'Maya|TEX_normal_map':
|
|
710
|
+
parameters.normalMap = scope.getTexture( textureMap, child.ID );
|
|
711
|
+
break;
|
|
712
|
+
|
|
713
|
+
case 'ReflectionColor':
|
|
714
|
+
parameters.envMap = scope.getTexture( textureMap, child.ID );
|
|
715
|
+
if ( parameters.envMap !== undefined ) {
|
|
716
|
+
|
|
717
|
+
parameters.envMap.mapping = EquirectangularReflectionMapping;
|
|
718
|
+
parameters.envMap.colorSpace = SRGBColorSpace;
|
|
719
|
+
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
break;
|
|
723
|
+
|
|
724
|
+
case 'SpecularColor':
|
|
725
|
+
parameters.specularMap = scope.getTexture( textureMap, child.ID );
|
|
726
|
+
if ( parameters.specularMap !== undefined ) {
|
|
727
|
+
|
|
728
|
+
parameters.specularMap.colorSpace = SRGBColorSpace;
|
|
729
|
+
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
break;
|
|
733
|
+
|
|
734
|
+
case 'TransparentColor':
|
|
735
|
+
case 'TransparencyFactor':
|
|
736
|
+
parameters.alphaMap = scope.getTexture( textureMap, child.ID );
|
|
737
|
+
parameters.transparent = true;
|
|
738
|
+
break;
|
|
739
|
+
|
|
740
|
+
case 'AmbientColor':
|
|
741
|
+
case 'ShininessExponent': // AKA glossiness map
|
|
742
|
+
case 'SpecularFactor': // AKA specularLevel
|
|
743
|
+
case 'VectorDisplacementColor': // NOTE: Seems to be a copy of DisplacementColor
|
|
744
|
+
default:
|
|
745
|
+
console.warn( 'THREE.FBXLoader: %s map is not supported in three.js, skipping texture.', type );
|
|
746
|
+
break;
|
|
747
|
+
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
} );
|
|
751
|
+
|
|
752
|
+
return parameters;
|
|
753
|
+
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
// get a texture from the textureMap for use by a material.
|
|
757
|
+
getTexture( textureMap, id ) {
|
|
758
|
+
|
|
759
|
+
// if the texture is a layered texture, just use the first layer and issue a warning
|
|
760
|
+
if ( 'LayeredTexture' in fbxTree.Objects && id in fbxTree.Objects.LayeredTexture ) {
|
|
761
|
+
|
|
762
|
+
console.warn( 'THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer.' );
|
|
763
|
+
id = connections.get( id ).children[ 0 ].ID;
|
|
764
|
+
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
return textureMap.get( id );
|
|
768
|
+
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
// Parse nodes in FBXTree.Objects.Deformer
|
|
772
|
+
// Deformer node can contain skinning or Vertex Cache animation data, however only skinning is supported here
|
|
773
|
+
// Generates map of Skeleton-like objects for use later when generating and binding skeletons.
|
|
774
|
+
parseDeformers() {
|
|
775
|
+
|
|
776
|
+
const skeletons = {};
|
|
777
|
+
const morphTargets = {};
|
|
778
|
+
|
|
779
|
+
if ( 'Deformer' in fbxTree.Objects ) {
|
|
780
|
+
|
|
781
|
+
const DeformerNodes = fbxTree.Objects.Deformer;
|
|
782
|
+
|
|
783
|
+
for ( const nodeID in DeformerNodes ) {
|
|
784
|
+
|
|
785
|
+
const deformerNode = DeformerNodes[ nodeID ];
|
|
786
|
+
|
|
787
|
+
const relationships = connections.get( parseInt( nodeID ) );
|
|
788
|
+
|
|
789
|
+
if ( deformerNode.attrType === 'Skin' ) {
|
|
790
|
+
|
|
791
|
+
const skeleton = this.parseSkeleton( relationships, DeformerNodes );
|
|
792
|
+
skeleton.ID = nodeID;
|
|
793
|
+
|
|
794
|
+
if ( relationships.parents.length > 1 ) console.warn( 'THREE.FBXLoader: skeleton attached to more than one geometry is not supported.' );
|
|
795
|
+
skeleton.geometryID = relationships.parents[ 0 ].ID;
|
|
796
|
+
|
|
797
|
+
skeletons[ nodeID ] = skeleton;
|
|
798
|
+
|
|
799
|
+
} else if ( deformerNode.attrType === 'BlendShape' ) {
|
|
800
|
+
|
|
801
|
+
const morphTarget = {
|
|
802
|
+
id: nodeID,
|
|
803
|
+
};
|
|
804
|
+
|
|
805
|
+
morphTarget.rawTargets = this.parseMorphTargets( relationships, DeformerNodes );
|
|
806
|
+
morphTarget.id = nodeID;
|
|
807
|
+
|
|
808
|
+
if ( relationships.parents.length > 1 ) console.warn( 'THREE.FBXLoader: morph target attached to more than one geometry is not supported.' );
|
|
809
|
+
|
|
810
|
+
morphTargets[ nodeID ] = morphTarget;
|
|
811
|
+
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
return {
|
|
819
|
+
|
|
820
|
+
skeletons: skeletons,
|
|
821
|
+
morphTargets: morphTargets,
|
|
822
|
+
|
|
823
|
+
};
|
|
824
|
+
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
// Parse single nodes in FBXTree.Objects.Deformer
|
|
828
|
+
// The top level skeleton node has type 'Skin' and sub nodes have type 'Cluster'
|
|
829
|
+
// Each skin node represents a skeleton and each cluster node represents a bone
|
|
830
|
+
parseSkeleton( relationships, deformerNodes ) {
|
|
831
|
+
|
|
832
|
+
const rawBones = [];
|
|
833
|
+
|
|
834
|
+
relationships.children.forEach( function ( child ) {
|
|
835
|
+
|
|
836
|
+
const boneNode = deformerNodes[ child.ID ];
|
|
837
|
+
|
|
838
|
+
if ( boneNode.attrType !== 'Cluster' ) return;
|
|
839
|
+
|
|
840
|
+
const rawBone = {
|
|
841
|
+
|
|
842
|
+
ID: child.ID,
|
|
843
|
+
indices: [],
|
|
844
|
+
weights: [],
|
|
845
|
+
transformLink: new Matrix4().fromArray( boneNode.TransformLink.a ),
|
|
846
|
+
|
|
847
|
+
};
|
|
848
|
+
|
|
849
|
+
if ( 'Indexes' in boneNode ) {
|
|
850
|
+
|
|
851
|
+
rawBone.indices = boneNode.Indexes.a;
|
|
852
|
+
rawBone.weights = boneNode.Weights.a;
|
|
853
|
+
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
rawBones.push( rawBone );
|
|
857
|
+
|
|
858
|
+
} );
|
|
859
|
+
|
|
860
|
+
return {
|
|
861
|
+
|
|
862
|
+
rawBones: rawBones,
|
|
863
|
+
bones: []
|
|
864
|
+
|
|
865
|
+
};
|
|
866
|
+
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
// The top level morph deformer node has type "BlendShape" and sub nodes have type "BlendShapeChannel"
|
|
870
|
+
parseMorphTargets( relationships, deformerNodes ) {
|
|
871
|
+
|
|
872
|
+
const rawMorphTargets = [];
|
|
873
|
+
|
|
874
|
+
for ( let i = 0; i < relationships.children.length; i ++ ) {
|
|
875
|
+
|
|
876
|
+
const child = relationships.children[ i ];
|
|
877
|
+
|
|
878
|
+
const morphTargetNode = deformerNodes[ child.ID ];
|
|
879
|
+
|
|
880
|
+
const rawMorphTarget = {
|
|
881
|
+
|
|
882
|
+
name: morphTargetNode.attrName,
|
|
883
|
+
initialWeight: morphTargetNode.DeformPercent,
|
|
884
|
+
id: morphTargetNode.id,
|
|
885
|
+
fullWeights: morphTargetNode.FullWeights.a
|
|
886
|
+
|
|
887
|
+
};
|
|
888
|
+
|
|
889
|
+
if ( morphTargetNode.attrType !== 'BlendShapeChannel' ) return;
|
|
890
|
+
|
|
891
|
+
rawMorphTarget.geoID = connections.get( parseInt( child.ID ) ).children.filter( function ( child ) {
|
|
892
|
+
|
|
893
|
+
return child.relationship === undefined;
|
|
894
|
+
|
|
895
|
+
} )[ 0 ].ID;
|
|
896
|
+
|
|
897
|
+
rawMorphTargets.push( rawMorphTarget );
|
|
898
|
+
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
return rawMorphTargets;
|
|
902
|
+
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
// create the main Group() to be returned by the loader
|
|
906
|
+
parseScene( deformers, geometryMap, materialMap ) {
|
|
907
|
+
|
|
908
|
+
sceneGraph = new Group();
|
|
909
|
+
|
|
910
|
+
const modelMap = this.parseModels( deformers.skeletons, geometryMap, materialMap );
|
|
911
|
+
|
|
912
|
+
const modelNodes = fbxTree.Objects.Model;
|
|
913
|
+
|
|
914
|
+
const scope = this;
|
|
915
|
+
modelMap.forEach( function ( model ) {
|
|
916
|
+
|
|
917
|
+
const modelNode = modelNodes[ model.ID ];
|
|
918
|
+
scope.setLookAtProperties( model, modelNode );
|
|
919
|
+
|
|
920
|
+
const parentConnections = connections.get( model.ID ).parents;
|
|
921
|
+
|
|
922
|
+
parentConnections.forEach( function ( connection ) {
|
|
923
|
+
|
|
924
|
+
const parent = modelMap.get( connection.ID );
|
|
925
|
+
if ( parent !== undefined ) parent.add( model );
|
|
926
|
+
|
|
927
|
+
} );
|
|
928
|
+
|
|
929
|
+
if ( model.parent === null ) {
|
|
930
|
+
|
|
931
|
+
sceneGraph.add( model );
|
|
932
|
+
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
|
|
936
|
+
} );
|
|
937
|
+
|
|
938
|
+
this.addGlobalSceneSettings();
|
|
939
|
+
|
|
940
|
+
sceneGraph.traverse( function ( node ) {
|
|
941
|
+
|
|
942
|
+
if ( node.userData.transformData ) {
|
|
943
|
+
|
|
944
|
+
if ( node.parent ) {
|
|
945
|
+
|
|
946
|
+
node.userData.transformData.parentMatrix = node.parent.matrix;
|
|
947
|
+
node.userData.transformData.parentMatrixWorld = node.parent.matrixWorld;
|
|
948
|
+
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
const transform = generateTransform( node.userData.transformData );
|
|
952
|
+
|
|
953
|
+
node.applyMatrix4( transform );
|
|
954
|
+
node.updateWorldMatrix();
|
|
955
|
+
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
} );
|
|
959
|
+
|
|
960
|
+
// Like Blender's FBX importer, use the BindPose section to set the
|
|
961
|
+
// rest pose for bones that are not part of a skin cluster. The BindPose
|
|
962
|
+
// provides a more authoritative rest pose than the Lcl properties which
|
|
963
|
+
// may represent an animation frame rather than the true rest state.
|
|
964
|
+
// Bones WITH clusters will get their bind pose from TransformLink
|
|
965
|
+
// (set via bindSkeleton below), which takes priority.
|
|
966
|
+
const bindPoseMatrices = this.parsePoseNodes();
|
|
967
|
+
const clusterBoneIDs = new Set();
|
|
968
|
+
|
|
969
|
+
for ( const ID in deformers.skeletons ) {
|
|
970
|
+
|
|
971
|
+
deformers.skeletons[ ID ].rawBones.forEach( function ( _, i ) {
|
|
972
|
+
|
|
973
|
+
const bone = deformers.skeletons[ ID ].bones[ i ];
|
|
974
|
+
if ( bone ) clusterBoneIDs.add( bone.ID );
|
|
975
|
+
|
|
976
|
+
} );
|
|
977
|
+
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
const tempMatrix = new Matrix4();
|
|
981
|
+
|
|
982
|
+
sceneGraph.traverse( function ( node ) {
|
|
983
|
+
|
|
984
|
+
if ( node.isBone && node.ID !== undefined && ! clusterBoneIDs.has( node.ID ) ) {
|
|
985
|
+
|
|
986
|
+
const bindPose = bindPoseMatrices[ node.ID ];
|
|
987
|
+
|
|
988
|
+
if ( bindPose !== undefined ) {
|
|
989
|
+
|
|
990
|
+
if ( node.parent ) {
|
|
991
|
+
|
|
992
|
+
tempMatrix.copy( node.parent.matrixWorld ).invert();
|
|
993
|
+
tempMatrix.multiply( bindPose );
|
|
994
|
+
|
|
995
|
+
} else {
|
|
996
|
+
|
|
997
|
+
tempMatrix.copy( bindPose );
|
|
998
|
+
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
tempMatrix.decompose( node.position, node.quaternion, node.scale );
|
|
1002
|
+
node.updateMatrix();
|
|
1003
|
+
node.matrixWorld.copy( bindPose );
|
|
1004
|
+
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
} );
|
|
1010
|
+
|
|
1011
|
+
// Bind skeletons after transforms are applied so that bind matrices
|
|
1012
|
+
// are computed from the final scene state. This ensures the rest pose
|
|
1013
|
+
// is correct even when the FBX file's Cluster TransformLink matrices
|
|
1014
|
+
// differ from the reconstructed bone transforms (common in files
|
|
1015
|
+
// without a BindPose section).
|
|
1016
|
+
this.bindSkeleton( deformers.skeletons, geometryMap, modelMap );
|
|
1017
|
+
|
|
1018
|
+
const animations = new AnimationParser( this.trimAnimationClips ).parse();
|
|
1019
|
+
|
|
1020
|
+
// if all the models where already combined in a single group, just return that
|
|
1021
|
+
if ( sceneGraph.children.length === 1 && sceneGraph.children[ 0 ].isGroup ) {
|
|
1022
|
+
|
|
1023
|
+
sceneGraph.children[ 0 ].animations = animations;
|
|
1024
|
+
Object.assign( sceneGraph.children[ 0 ].userData, sceneGraph.userData );
|
|
1025
|
+
sceneGraph = sceneGraph.children[ 0 ];
|
|
1026
|
+
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
sceneGraph.animations = animations;
|
|
1030
|
+
|
|
1031
|
+
// Apply coordinate system correction. FBX files can use different
|
|
1032
|
+
// up-axis conventions (Y-up or Z-up). Three.js uses Y-up, so rotate
|
|
1033
|
+
// the scene when the file uses Z-up (UpAxis === 2).
|
|
1034
|
+
|
|
1035
|
+
if ( 'GlobalSettings' in fbxTree && 'UpAxis' in fbxTree.GlobalSettings ) {
|
|
1036
|
+
|
|
1037
|
+
const upAxis = fbxTree.GlobalSettings.UpAxis.value;
|
|
1038
|
+
|
|
1039
|
+
if ( upAxis === 2 ) {
|
|
1040
|
+
|
|
1041
|
+
console.warn( 'THREE.FBXLoader: You are loading an asset with a Z-UP coordinate system. The loader just rotates the asset to transform it into Y-UP. The vertex data are not converted.' );
|
|
1042
|
+
|
|
1043
|
+
sceneGraph.rotation.set( - Math.PI / 2, 0, 0 );
|
|
1044
|
+
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
// parse nodes in FBXTree.Objects.Model
|
|
1052
|
+
parseModels( skeletons, geometryMap, materialMap ) {
|
|
1053
|
+
|
|
1054
|
+
const modelMap = new Map();
|
|
1055
|
+
const modelNodes = fbxTree.Objects.Model;
|
|
1056
|
+
|
|
1057
|
+
for ( const nodeID in modelNodes ) {
|
|
1058
|
+
|
|
1059
|
+
const id = parseInt( nodeID );
|
|
1060
|
+
const node = modelNodes[ nodeID ];
|
|
1061
|
+
const relationships = connections.get( id );
|
|
1062
|
+
|
|
1063
|
+
let model = this.buildSkeleton( relationships, skeletons, id, node.attrName );
|
|
1064
|
+
|
|
1065
|
+
if ( ! model ) {
|
|
1066
|
+
|
|
1067
|
+
switch ( node.attrType ) {
|
|
1068
|
+
|
|
1069
|
+
case 'Camera':
|
|
1070
|
+
model = this.createCamera( relationships );
|
|
1071
|
+
break;
|
|
1072
|
+
case 'Light':
|
|
1073
|
+
model = this.createLight( relationships );
|
|
1074
|
+
break;
|
|
1075
|
+
case 'Mesh':
|
|
1076
|
+
model = this.createMesh( relationships, geometryMap, materialMap );
|
|
1077
|
+
break;
|
|
1078
|
+
case 'NurbsCurve':
|
|
1079
|
+
model = this.createCurve( relationships, geometryMap );
|
|
1080
|
+
break;
|
|
1081
|
+
case 'LimbNode':
|
|
1082
|
+
case 'Root':
|
|
1083
|
+
model = new Bone();
|
|
1084
|
+
break;
|
|
1085
|
+
case 'Null':
|
|
1086
|
+
default:
|
|
1087
|
+
model = new Group();
|
|
1088
|
+
break;
|
|
1089
|
+
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
model.name = node.attrName ? PropertyBinding.sanitizeNodeName( node.attrName ) : '';
|
|
1093
|
+
model.userData.originalName = node.attrName;
|
|
1094
|
+
|
|
1095
|
+
model.ID = id;
|
|
1096
|
+
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
this.getTransformData( model, node );
|
|
1100
|
+
modelMap.set( id, model );
|
|
1101
|
+
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
return modelMap;
|
|
1105
|
+
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
buildSkeleton( relationships, skeletons, id, name ) {
|
|
1109
|
+
|
|
1110
|
+
let bone = null;
|
|
1111
|
+
|
|
1112
|
+
relationships.parents.forEach( function ( parent ) {
|
|
1113
|
+
|
|
1114
|
+
for ( const ID in skeletons ) {
|
|
1115
|
+
|
|
1116
|
+
const skeleton = skeletons[ ID ];
|
|
1117
|
+
|
|
1118
|
+
skeleton.rawBones.forEach( function ( rawBone, i ) {
|
|
1119
|
+
|
|
1120
|
+
if ( rawBone.ID === parent.ID ) {
|
|
1121
|
+
|
|
1122
|
+
const subBone = bone;
|
|
1123
|
+
bone = new Bone();
|
|
1124
|
+
|
|
1125
|
+
bone.matrixWorld.copy( rawBone.transformLink );
|
|
1126
|
+
|
|
1127
|
+
// set name and id here - otherwise in cases where "subBone" is created it will not have a name / id
|
|
1128
|
+
|
|
1129
|
+
bone.name = name ? PropertyBinding.sanitizeNodeName( name ) : '';
|
|
1130
|
+
bone.userData.originalName = name;
|
|
1131
|
+
bone.ID = id;
|
|
1132
|
+
|
|
1133
|
+
skeleton.bones[ i ] = bone;
|
|
1134
|
+
|
|
1135
|
+
// In cases where a bone is shared between multiple meshes
|
|
1136
|
+
// duplicate the bone here and add it as a child of the first bone
|
|
1137
|
+
if ( subBone !== null ) {
|
|
1138
|
+
|
|
1139
|
+
bone.add( subBone );
|
|
1140
|
+
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
} );
|
|
1146
|
+
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
} );
|
|
1150
|
+
|
|
1151
|
+
return bone;
|
|
1152
|
+
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
// create a PerspectiveCamera or OrthographicCamera
|
|
1156
|
+
createCamera( relationships ) {
|
|
1157
|
+
|
|
1158
|
+
let model;
|
|
1159
|
+
let cameraAttribute;
|
|
1160
|
+
|
|
1161
|
+
relationships.children.forEach( function ( child ) {
|
|
1162
|
+
|
|
1163
|
+
const attr = fbxTree.Objects.NodeAttribute[ child.ID ];
|
|
1164
|
+
|
|
1165
|
+
if ( attr !== undefined ) {
|
|
1166
|
+
|
|
1167
|
+
cameraAttribute = attr;
|
|
1168
|
+
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
} );
|
|
1172
|
+
|
|
1173
|
+
if ( cameraAttribute === undefined ) {
|
|
1174
|
+
|
|
1175
|
+
model = new Object3D();
|
|
1176
|
+
|
|
1177
|
+
} else {
|
|
1178
|
+
|
|
1179
|
+
let type = 0;
|
|
1180
|
+
if ( cameraAttribute.CameraProjectionType !== undefined && cameraAttribute.CameraProjectionType.value === 1 ) {
|
|
1181
|
+
|
|
1182
|
+
type = 1;
|
|
1183
|
+
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
let nearClippingPlane = 1;
|
|
1187
|
+
if ( cameraAttribute.NearPlane !== undefined ) {
|
|
1188
|
+
|
|
1189
|
+
nearClippingPlane = cameraAttribute.NearPlane.value / 1000;
|
|
1190
|
+
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
let farClippingPlane = 1000;
|
|
1194
|
+
if ( cameraAttribute.FarPlane !== undefined ) {
|
|
1195
|
+
|
|
1196
|
+
farClippingPlane = cameraAttribute.FarPlane.value / 1000;
|
|
1197
|
+
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
|
|
1201
|
+
let width = window.innerWidth;
|
|
1202
|
+
let height = window.innerHeight;
|
|
1203
|
+
|
|
1204
|
+
if ( cameraAttribute.AspectWidth !== undefined && cameraAttribute.AspectHeight !== undefined ) {
|
|
1205
|
+
|
|
1206
|
+
width = cameraAttribute.AspectWidth.value;
|
|
1207
|
+
height = cameraAttribute.AspectHeight.value;
|
|
1208
|
+
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
const aspect = width / height;
|
|
1212
|
+
|
|
1213
|
+
let fov = 45;
|
|
1214
|
+
if ( cameraAttribute.FieldOfView !== undefined ) {
|
|
1215
|
+
|
|
1216
|
+
fov = cameraAttribute.FieldOfView.value;
|
|
1217
|
+
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
const focalLength = cameraAttribute.FocalLength ? cameraAttribute.FocalLength.value : null;
|
|
1221
|
+
|
|
1222
|
+
switch ( type ) {
|
|
1223
|
+
|
|
1224
|
+
case 0: // Perspective
|
|
1225
|
+
model = new PerspectiveCamera( fov, aspect, nearClippingPlane, farClippingPlane );
|
|
1226
|
+
if ( focalLength !== null ) model.setFocalLength( focalLength );
|
|
1227
|
+
break;
|
|
1228
|
+
|
|
1229
|
+
case 1: // Orthographic
|
|
1230
|
+
console.warn( 'THREE.FBXLoader: Orthographic cameras not supported yet.' );
|
|
1231
|
+
model = new Object3D();
|
|
1232
|
+
break;
|
|
1233
|
+
|
|
1234
|
+
default:
|
|
1235
|
+
console.warn( 'THREE.FBXLoader: Unknown camera type ' + type + '.' );
|
|
1236
|
+
model = new Object3D();
|
|
1237
|
+
break;
|
|
1238
|
+
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
return model;
|
|
1244
|
+
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
// Create a DirectionalLight, PointLight or SpotLight
|
|
1248
|
+
createLight( relationships ) {
|
|
1249
|
+
|
|
1250
|
+
let model;
|
|
1251
|
+
let lightAttribute;
|
|
1252
|
+
|
|
1253
|
+
relationships.children.forEach( function ( child ) {
|
|
1254
|
+
|
|
1255
|
+
const attr = fbxTree.Objects.NodeAttribute[ child.ID ];
|
|
1256
|
+
|
|
1257
|
+
if ( attr !== undefined ) {
|
|
1258
|
+
|
|
1259
|
+
lightAttribute = attr;
|
|
1260
|
+
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
} );
|
|
1264
|
+
|
|
1265
|
+
if ( lightAttribute === undefined ) {
|
|
1266
|
+
|
|
1267
|
+
model = new Object3D();
|
|
1268
|
+
|
|
1269
|
+
} else {
|
|
1270
|
+
|
|
1271
|
+
let type;
|
|
1272
|
+
|
|
1273
|
+
// LightType can be undefined for Point lights
|
|
1274
|
+
if ( lightAttribute.LightType === undefined ) {
|
|
1275
|
+
|
|
1276
|
+
type = 0;
|
|
1277
|
+
|
|
1278
|
+
} else {
|
|
1279
|
+
|
|
1280
|
+
type = lightAttribute.LightType.value;
|
|
1281
|
+
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
let color = 0xffffff;
|
|
1285
|
+
|
|
1286
|
+
if ( lightAttribute.Color !== undefined ) {
|
|
1287
|
+
|
|
1288
|
+
color = ColorManagement.colorSpaceToWorking( new Color().fromArray( lightAttribute.Color.value ), SRGBColorSpace );
|
|
1289
|
+
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
let intensity = ( lightAttribute.Intensity === undefined ) ? 1 : lightAttribute.Intensity.value / 100;
|
|
1293
|
+
|
|
1294
|
+
// light disabled
|
|
1295
|
+
if ( lightAttribute.CastLightOnObject !== undefined && lightAttribute.CastLightOnObject.value === 0 ) {
|
|
1296
|
+
|
|
1297
|
+
intensity = 0;
|
|
1298
|
+
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
let distance = 0;
|
|
1302
|
+
if ( lightAttribute.FarAttenuationEnd !== undefined ) {
|
|
1303
|
+
|
|
1304
|
+
if ( lightAttribute.EnableFarAttenuation !== undefined && lightAttribute.EnableFarAttenuation.value === 0 ) {
|
|
1305
|
+
|
|
1306
|
+
distance = 0;
|
|
1307
|
+
|
|
1308
|
+
} else {
|
|
1309
|
+
|
|
1310
|
+
distance = lightAttribute.FarAttenuationEnd.value;
|
|
1311
|
+
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
// TODO: could this be calculated linearly from FarAttenuationStart to FarAttenuationEnd?
|
|
1317
|
+
const decay = 1;
|
|
1318
|
+
|
|
1319
|
+
switch ( type ) {
|
|
1320
|
+
|
|
1321
|
+
case 0: // Point
|
|
1322
|
+
model = new PointLight( color, intensity, distance, decay );
|
|
1323
|
+
break;
|
|
1324
|
+
|
|
1325
|
+
case 1: // Directional
|
|
1326
|
+
model = new DirectionalLight( color, intensity );
|
|
1327
|
+
break;
|
|
1328
|
+
|
|
1329
|
+
case 2: // Spot
|
|
1330
|
+
let angle = Math.PI / 3;
|
|
1331
|
+
let penumbra = 0;
|
|
1332
|
+
|
|
1333
|
+
if ( lightAttribute.OuterAngle !== undefined ) {
|
|
1334
|
+
|
|
1335
|
+
angle = MathUtils.degToRad( lightAttribute.OuterAngle.value );
|
|
1336
|
+
|
|
1337
|
+
if ( lightAttribute.InnerAngle !== undefined ) {
|
|
1338
|
+
|
|
1339
|
+
penumbra = 1 - ( lightAttribute.InnerAngle.value / lightAttribute.OuterAngle.value );
|
|
1340
|
+
penumbra = Math.max( 0, penumbra ); // penumbra must be in the range [0,1]
|
|
1341
|
+
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
} else if ( lightAttribute.InnerAngle !== undefined ) {
|
|
1345
|
+
|
|
1346
|
+
// fallback if only InnerAngle is defined
|
|
1347
|
+
|
|
1348
|
+
angle = MathUtils.degToRad( lightAttribute.InnerAngle.value );
|
|
1349
|
+
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
model = new SpotLight( color, intensity, distance, angle, penumbra, decay );
|
|
1353
|
+
break;
|
|
1354
|
+
|
|
1355
|
+
default:
|
|
1356
|
+
console.warn( 'THREE.FBXLoader: Unknown light type ' + lightAttribute.LightType.value + ', defaulting to a PointLight.' );
|
|
1357
|
+
model = new PointLight( color, intensity );
|
|
1358
|
+
break;
|
|
1359
|
+
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
if ( lightAttribute.CastShadows !== undefined && lightAttribute.CastShadows.value === 1 ) {
|
|
1363
|
+
|
|
1364
|
+
model.castShadow = true;
|
|
1365
|
+
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
return model;
|
|
1371
|
+
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
createMesh( relationships, geometryMap, materialMap ) {
|
|
1375
|
+
|
|
1376
|
+
let model;
|
|
1377
|
+
let geometry = null;
|
|
1378
|
+
let material = null;
|
|
1379
|
+
const materials = [];
|
|
1380
|
+
|
|
1381
|
+
// get geometry and materials(s) from connections
|
|
1382
|
+
relationships.children.forEach( function ( child ) {
|
|
1383
|
+
|
|
1384
|
+
if ( geometryMap.has( child.ID ) ) {
|
|
1385
|
+
|
|
1386
|
+
geometry = geometryMap.get( child.ID );
|
|
1387
|
+
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
if ( materialMap.has( child.ID ) ) {
|
|
1391
|
+
|
|
1392
|
+
materials.push( materialMap.get( child.ID ) );
|
|
1393
|
+
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
} );
|
|
1397
|
+
|
|
1398
|
+
if ( materials.length > 1 ) {
|
|
1399
|
+
|
|
1400
|
+
material = materials;
|
|
1401
|
+
|
|
1402
|
+
} else if ( materials.length > 0 ) {
|
|
1403
|
+
|
|
1404
|
+
material = materials[ 0 ];
|
|
1405
|
+
|
|
1406
|
+
} else {
|
|
1407
|
+
|
|
1408
|
+
material = new MeshPhongMaterial( {
|
|
1409
|
+
name: Loader.DEFAULT_MATERIAL_NAME,
|
|
1410
|
+
color: 0xcccccc
|
|
1411
|
+
} );
|
|
1412
|
+
materials.push( material );
|
|
1413
|
+
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
if ( 'color' in geometry.attributes ) {
|
|
1417
|
+
|
|
1418
|
+
materials.forEach( function ( material ) {
|
|
1419
|
+
|
|
1420
|
+
material.vertexColors = true;
|
|
1421
|
+
|
|
1422
|
+
} );
|
|
1423
|
+
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
// Sanitization: If geometry has groups, then it must match the provided material array.
|
|
1427
|
+
// If not, we need to clean up the `group.materialIndex` properties inside the groups and point at a (new) default material.
|
|
1428
|
+
// This isn't well defined; Unity creates default material, while Blender implicitly uses the previous material in the list.
|
|
1429
|
+
if ( geometry.groups.length > 0 ) {
|
|
1430
|
+
|
|
1431
|
+
let needsDefaultMaterial = false;
|
|
1432
|
+
|
|
1433
|
+
for ( let i = 0, il = geometry.groups.length; i < il; i ++ ) {
|
|
1434
|
+
|
|
1435
|
+
const group = geometry.groups[ i ];
|
|
1436
|
+
|
|
1437
|
+
if ( group.materialIndex < 0 || group.materialIndex >= materials.length ) {
|
|
1438
|
+
|
|
1439
|
+
group.materialIndex = materials.length;
|
|
1440
|
+
needsDefaultMaterial = true;
|
|
1441
|
+
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
if ( needsDefaultMaterial ) {
|
|
1447
|
+
|
|
1448
|
+
const defaultMaterial = new MeshPhongMaterial();
|
|
1449
|
+
materials.push( defaultMaterial );
|
|
1450
|
+
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
if ( geometry.FBX_Deformer ) {
|
|
1456
|
+
|
|
1457
|
+
model = new SkinnedMesh( geometry, material );
|
|
1458
|
+
model.normalizeSkinWeights();
|
|
1459
|
+
|
|
1460
|
+
} else {
|
|
1461
|
+
|
|
1462
|
+
model = new Mesh( geometry, material );
|
|
1463
|
+
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
return model;
|
|
1467
|
+
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
createCurve( relationships, geometryMap ) {
|
|
1471
|
+
|
|
1472
|
+
const geometry = relationships.children.reduce( function ( geo, child ) {
|
|
1473
|
+
|
|
1474
|
+
if ( geometryMap.has( child.ID ) ) geo = geometryMap.get( child.ID );
|
|
1475
|
+
|
|
1476
|
+
return geo;
|
|
1477
|
+
|
|
1478
|
+
}, null );
|
|
1479
|
+
|
|
1480
|
+
// FBX does not list materials for Nurbs lines, so we'll just put our own in here.
|
|
1481
|
+
const material = new LineBasicMaterial( {
|
|
1482
|
+
name: Loader.DEFAULT_MATERIAL_NAME,
|
|
1483
|
+
color: 0x3300ff,
|
|
1484
|
+
linewidth: 1
|
|
1485
|
+
} );
|
|
1486
|
+
return new Line( geometry, material );
|
|
1487
|
+
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
// parse the model node for transform data
|
|
1491
|
+
getTransformData( model, modelNode ) {
|
|
1492
|
+
|
|
1493
|
+
const transformData = {};
|
|
1494
|
+
|
|
1495
|
+
if ( 'InheritType' in modelNode ) transformData.inheritType = parseInt( modelNode.InheritType.value );
|
|
1496
|
+
|
|
1497
|
+
if ( 'RotationOrder' in modelNode ) transformData.eulerOrder = getEulerOrder( modelNode.RotationOrder.value );
|
|
1498
|
+
else transformData.eulerOrder = getEulerOrder( 0 );
|
|
1499
|
+
|
|
1500
|
+
if ( 'Lcl_Translation' in modelNode ) transformData.translation = modelNode.Lcl_Translation.value;
|
|
1501
|
+
|
|
1502
|
+
if ( 'PreRotation' in modelNode ) transformData.preRotation = modelNode.PreRotation.value;
|
|
1503
|
+
if ( 'Lcl_Rotation' in modelNode ) transformData.rotation = modelNode.Lcl_Rotation.value;
|
|
1504
|
+
if ( 'PostRotation' in modelNode ) transformData.postRotation = modelNode.PostRotation.value;
|
|
1505
|
+
|
|
1506
|
+
if ( 'Lcl_Scaling' in modelNode ) transformData.scale = modelNode.Lcl_Scaling.value;
|
|
1507
|
+
|
|
1508
|
+
if ( 'ScalingOffset' in modelNode ) transformData.scalingOffset = modelNode.ScalingOffset.value;
|
|
1509
|
+
if ( 'ScalingPivot' in modelNode ) transformData.scalingPivot = modelNode.ScalingPivot.value;
|
|
1510
|
+
|
|
1511
|
+
if ( 'RotationOffset' in modelNode ) transformData.rotationOffset = modelNode.RotationOffset.value;
|
|
1512
|
+
if ( 'RotationPivot' in modelNode ) transformData.rotationPivot = modelNode.RotationPivot.value;
|
|
1513
|
+
|
|
1514
|
+
model.userData.transformData = transformData;
|
|
1515
|
+
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
setLookAtProperties( model, modelNode ) {
|
|
1519
|
+
|
|
1520
|
+
if ( 'LookAtProperty' in modelNode ) {
|
|
1521
|
+
|
|
1522
|
+
const children = connections.get( model.ID ).children;
|
|
1523
|
+
|
|
1524
|
+
children.forEach( function ( child ) {
|
|
1525
|
+
|
|
1526
|
+
if ( child.relationship === 'LookAtProperty' ) {
|
|
1527
|
+
|
|
1528
|
+
const lookAtTarget = fbxTree.Objects.Model[ child.ID ];
|
|
1529
|
+
|
|
1530
|
+
if ( 'Lcl_Translation' in lookAtTarget ) {
|
|
1531
|
+
|
|
1532
|
+
const pos = lookAtTarget.Lcl_Translation.value;
|
|
1533
|
+
|
|
1534
|
+
// DirectionalLight, SpotLight
|
|
1535
|
+
if ( model.target !== undefined ) {
|
|
1536
|
+
|
|
1537
|
+
model.target.position.fromArray( pos );
|
|
1538
|
+
sceneGraph.add( model.target );
|
|
1539
|
+
|
|
1540
|
+
} else { // Cameras and other Object3Ds
|
|
1541
|
+
|
|
1542
|
+
model.lookAt( new Vector3().fromArray( pos ) );
|
|
1543
|
+
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
} );
|
|
1551
|
+
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
bindSkeleton( skeletons, geometryMap, modelMap ) {
|
|
1557
|
+
|
|
1558
|
+
for ( const ID in skeletons ) {
|
|
1559
|
+
|
|
1560
|
+
const skeleton = skeletons[ ID ];
|
|
1561
|
+
|
|
1562
|
+
// Compute bone inverses from TransformLink rather than from the
|
|
1563
|
+
// bones' current matrixWorld. The TransformLink matrices represent
|
|
1564
|
+
// each bone's global transform at the time the skin weights were
|
|
1565
|
+
// painted, which may differ from the scene-reconstructed transforms.
|
|
1566
|
+
const boneInverses = [];
|
|
1567
|
+
|
|
1568
|
+
for ( let i = 0, l = skeleton.bones.length; i < l; i ++ ) {
|
|
1569
|
+
|
|
1570
|
+
const inverse = new Matrix4();
|
|
1571
|
+
|
|
1572
|
+
if ( skeleton.bones[ i ] && skeleton.rawBones[ i ] ) {
|
|
1573
|
+
|
|
1574
|
+
inverse.copy( skeleton.rawBones[ i ].transformLink ).invert();
|
|
1575
|
+
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
boneInverses.push( inverse );
|
|
1579
|
+
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
const parents = connections.get( parseInt( skeleton.ID ) ).parents;
|
|
1583
|
+
|
|
1584
|
+
parents.forEach( function ( parent ) {
|
|
1585
|
+
|
|
1586
|
+
if ( geometryMap.has( parent.ID ) ) {
|
|
1587
|
+
|
|
1588
|
+
const geoID = parent.ID;
|
|
1589
|
+
const geoRelationships = connections.get( geoID );
|
|
1590
|
+
|
|
1591
|
+
geoRelationships.parents.forEach( function ( geoConnParent ) {
|
|
1592
|
+
|
|
1593
|
+
if ( modelMap.has( geoConnParent.ID ) ) {
|
|
1594
|
+
|
|
1595
|
+
const model = modelMap.get( geoConnParent.ID );
|
|
1596
|
+
|
|
1597
|
+
// Use the mesh's current matrixWorld as bind matrix.
|
|
1598
|
+
// The BindPose section is intentionally not used here
|
|
1599
|
+
// since it may contain scale/rotation from the model
|
|
1600
|
+
// hierarchy that is inconsistent with the TransformLink-
|
|
1601
|
+
// based bone inverses. Always provide a bind matrix to
|
|
1602
|
+
// prevent bind() from calling calculateInverses() which
|
|
1603
|
+
// would overwrite the bone inverses computed above.
|
|
1604
|
+
model.updateMatrixWorld( true );
|
|
1605
|
+
|
|
1606
|
+
model.bind( new Skeleton( skeleton.bones, boneInverses ), model.matrixWorld );
|
|
1607
|
+
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
} );
|
|
1611
|
+
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
} );
|
|
1615
|
+
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
// Parse BindPose nodes and return a map of node ID to bind matrix.
|
|
1621
|
+
parsePoseNodes() {
|
|
1622
|
+
|
|
1623
|
+
const bindMatrices = {};
|
|
1624
|
+
|
|
1625
|
+
if ( 'Pose' in fbxTree.Objects ) {
|
|
1626
|
+
|
|
1627
|
+
const BindPoseNode = fbxTree.Objects.Pose;
|
|
1628
|
+
|
|
1629
|
+
for ( const nodeID in BindPoseNode ) {
|
|
1630
|
+
|
|
1631
|
+
if ( BindPoseNode[ nodeID ].attrType === 'BindPose' && BindPoseNode[ nodeID ].NbPoseNodes > 0 ) {
|
|
1632
|
+
|
|
1633
|
+
const poseNodes = BindPoseNode[ nodeID ].PoseNode;
|
|
1634
|
+
|
|
1635
|
+
if ( Array.isArray( poseNodes ) ) {
|
|
1636
|
+
|
|
1637
|
+
poseNodes.forEach( function ( poseNode ) {
|
|
1638
|
+
|
|
1639
|
+
bindMatrices[ poseNode.Node ] = new Matrix4().fromArray( poseNode.Matrix.a );
|
|
1640
|
+
|
|
1641
|
+
} );
|
|
1642
|
+
|
|
1643
|
+
} else {
|
|
1644
|
+
|
|
1645
|
+
bindMatrices[ poseNodes.Node ] = new Matrix4().fromArray( poseNodes.Matrix.a );
|
|
1646
|
+
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
return bindMatrices;
|
|
1656
|
+
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
addGlobalSceneSettings() {
|
|
1660
|
+
|
|
1661
|
+
if ( 'GlobalSettings' in fbxTree ) {
|
|
1662
|
+
|
|
1663
|
+
if ( 'AmbientColor' in fbxTree.GlobalSettings ) {
|
|
1664
|
+
|
|
1665
|
+
// Parse ambient color - if it's not set to black (default), create an ambient light
|
|
1666
|
+
|
|
1667
|
+
const ambientColor = fbxTree.GlobalSettings.AmbientColor.value;
|
|
1668
|
+
const r = ambientColor[ 0 ];
|
|
1669
|
+
const g = ambientColor[ 1 ];
|
|
1670
|
+
const b = ambientColor[ 2 ];
|
|
1671
|
+
|
|
1672
|
+
if ( r !== 0 || g !== 0 || b !== 0 ) {
|
|
1673
|
+
|
|
1674
|
+
const color = new Color().setRGB( r, g, b, SRGBColorSpace );
|
|
1675
|
+
sceneGraph.add( new AmbientLight( color, 1 ) );
|
|
1676
|
+
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
if ( 'UnitScaleFactor' in fbxTree.GlobalSettings ) {
|
|
1682
|
+
|
|
1683
|
+
sceneGraph.userData.unitScaleFactor = fbxTree.GlobalSettings.UnitScaleFactor.value;
|
|
1684
|
+
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
// parse Geometry data from FBXTree and return map of BufferGeometries
|
|
1694
|
+
class GeometryParser {
|
|
1695
|
+
|
|
1696
|
+
constructor() {
|
|
1697
|
+
|
|
1698
|
+
this.negativeMaterialIndices = false;
|
|
1699
|
+
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
// Parse nodes in FBXTree.Objects.Geometry
|
|
1703
|
+
parse( deformers ) {
|
|
1704
|
+
|
|
1705
|
+
const geometryMap = new Map();
|
|
1706
|
+
|
|
1707
|
+
if ( 'Geometry' in fbxTree.Objects ) {
|
|
1708
|
+
|
|
1709
|
+
const geoNodes = fbxTree.Objects.Geometry;
|
|
1710
|
+
|
|
1711
|
+
for ( const nodeID in geoNodes ) {
|
|
1712
|
+
|
|
1713
|
+
const relationships = connections.get( parseInt( nodeID ) );
|
|
1714
|
+
const geo = this.parseGeometry( relationships, geoNodes[ nodeID ], deformers );
|
|
1715
|
+
|
|
1716
|
+
geometryMap.set( parseInt( nodeID ), geo );
|
|
1717
|
+
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
// report warnings
|
|
1723
|
+
|
|
1724
|
+
if ( this.negativeMaterialIndices === true ) {
|
|
1725
|
+
|
|
1726
|
+
console.warn( 'THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected.' );
|
|
1727
|
+
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
return geometryMap;
|
|
1731
|
+
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
// Parse single node in FBXTree.Objects.Geometry
|
|
1735
|
+
parseGeometry( relationships, geoNode, deformers ) {
|
|
1736
|
+
|
|
1737
|
+
switch ( geoNode.attrType ) {
|
|
1738
|
+
|
|
1739
|
+
case 'Mesh':
|
|
1740
|
+
return this.parseMeshGeometry( relationships, geoNode, deformers );
|
|
1741
|
+
|
|
1742
|
+
case 'NurbsCurve':
|
|
1743
|
+
return this.parseNurbsGeometry( geoNode );
|
|
1744
|
+
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1749
|
+
// Parse single node mesh geometry in FBXTree.Objects.Geometry
|
|
1750
|
+
parseMeshGeometry( relationships, geoNode, deformers ) {
|
|
1751
|
+
|
|
1752
|
+
const skeletons = deformers.skeletons;
|
|
1753
|
+
const morphTargets = [];
|
|
1754
|
+
|
|
1755
|
+
const modelNodes = relationships.parents.map( function ( parent ) {
|
|
1756
|
+
|
|
1757
|
+
return fbxTree.Objects.Model[ parent.ID ];
|
|
1758
|
+
|
|
1759
|
+
} );
|
|
1760
|
+
|
|
1761
|
+
// don't create geometry if it is not associated with any models
|
|
1762
|
+
if ( modelNodes.length === 0 ) return;
|
|
1763
|
+
|
|
1764
|
+
const skeleton = relationships.children.reduce( function ( skeleton, child ) {
|
|
1765
|
+
|
|
1766
|
+
if ( skeletons[ child.ID ] !== undefined ) skeleton = skeletons[ child.ID ];
|
|
1767
|
+
|
|
1768
|
+
return skeleton;
|
|
1769
|
+
|
|
1770
|
+
}, null );
|
|
1771
|
+
|
|
1772
|
+
relationships.children.forEach( function ( child ) {
|
|
1773
|
+
|
|
1774
|
+
if ( deformers.morphTargets[ child.ID ] !== undefined ) {
|
|
1775
|
+
|
|
1776
|
+
morphTargets.push( deformers.morphTargets[ child.ID ] );
|
|
1777
|
+
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
} );
|
|
1781
|
+
|
|
1782
|
+
// Assume one model and get the preRotation from that
|
|
1783
|
+
// if there is more than one model associated with the geometry this may cause problems
|
|
1784
|
+
const modelNode = modelNodes[ 0 ];
|
|
1785
|
+
|
|
1786
|
+
const transformData = {};
|
|
1787
|
+
|
|
1788
|
+
if ( 'RotationOrder' in modelNode ) transformData.eulerOrder = getEulerOrder( modelNode.RotationOrder.value );
|
|
1789
|
+
if ( 'InheritType' in modelNode ) transformData.inheritType = parseInt( modelNode.InheritType.value );
|
|
1790
|
+
|
|
1791
|
+
if ( 'GeometricTranslation' in modelNode ) transformData.translation = modelNode.GeometricTranslation.value;
|
|
1792
|
+
if ( 'GeometricRotation' in modelNode ) transformData.rotation = modelNode.GeometricRotation.value;
|
|
1793
|
+
if ( 'GeometricScaling' in modelNode ) transformData.scale = modelNode.GeometricScaling.value;
|
|
1794
|
+
|
|
1795
|
+
const transform = generateTransform( transformData );
|
|
1796
|
+
|
|
1797
|
+
return this.genGeometry( geoNode, skeleton, morphTargets, transform );
|
|
1798
|
+
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
// Generate a BufferGeometry from a node in FBXTree.Objects.Geometry
|
|
1802
|
+
genGeometry( geoNode, skeleton, morphTargets, preTransform ) {
|
|
1803
|
+
|
|
1804
|
+
const geo = new BufferGeometry();
|
|
1805
|
+
if ( geoNode.attrName ) geo.name = geoNode.attrName;
|
|
1806
|
+
|
|
1807
|
+
const geoInfo = this.parseGeoNode( geoNode, skeleton );
|
|
1808
|
+
const buffers = this.genBuffers( geoInfo );
|
|
1809
|
+
|
|
1810
|
+
const positionAttribute = new Float32BufferAttribute( buffers.vertex, 3 );
|
|
1811
|
+
|
|
1812
|
+
positionAttribute.applyMatrix4( preTransform );
|
|
1813
|
+
|
|
1814
|
+
geo.setAttribute( 'position', positionAttribute );
|
|
1815
|
+
|
|
1816
|
+
if ( buffers.colors.length > 0 ) {
|
|
1817
|
+
|
|
1818
|
+
geo.setAttribute( 'color', new Float32BufferAttribute( buffers.colors, 3 ) );
|
|
1819
|
+
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
if ( skeleton ) {
|
|
1823
|
+
|
|
1824
|
+
geo.setAttribute( 'skinIndex', new Uint16BufferAttribute( buffers.weightsIndices, 4 ) );
|
|
1825
|
+
|
|
1826
|
+
geo.setAttribute( 'skinWeight', new Float32BufferAttribute( buffers.vertexWeights, 4 ) );
|
|
1827
|
+
|
|
1828
|
+
// used later to bind the skeleton to the model
|
|
1829
|
+
geo.FBX_Deformer = skeleton;
|
|
1830
|
+
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
if ( buffers.normal.length > 0 ) {
|
|
1834
|
+
|
|
1835
|
+
const normalMatrix = new Matrix3().getNormalMatrix( preTransform );
|
|
1836
|
+
|
|
1837
|
+
const normalAttribute = new Float32BufferAttribute( buffers.normal, 3 );
|
|
1838
|
+
normalAttribute.applyNormalMatrix( normalMatrix );
|
|
1839
|
+
|
|
1840
|
+
geo.setAttribute( 'normal', normalAttribute );
|
|
1841
|
+
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
buffers.uvs.forEach( function ( uvBuffer, i ) {
|
|
1845
|
+
|
|
1846
|
+
const name = i === 0 ? 'uv' : `uv${ i }`;
|
|
1847
|
+
|
|
1848
|
+
geo.setAttribute( name, new Float32BufferAttribute( buffers.uvs[ i ], 2 ) );
|
|
1849
|
+
|
|
1850
|
+
} );
|
|
1851
|
+
|
|
1852
|
+
if ( geoInfo.material && geoInfo.material.mappingType !== 'AllSame' ) {
|
|
1853
|
+
|
|
1854
|
+
// Convert the material indices of each vertex into rendering groups on the geometry.
|
|
1855
|
+
let prevMaterialIndex = buffers.materialIndex[ 0 ];
|
|
1856
|
+
let startIndex = 0;
|
|
1857
|
+
|
|
1858
|
+
buffers.materialIndex.forEach( function ( currentIndex, i ) {
|
|
1859
|
+
|
|
1860
|
+
if ( currentIndex !== prevMaterialIndex ) {
|
|
1861
|
+
|
|
1862
|
+
geo.addGroup( startIndex, i - startIndex, prevMaterialIndex );
|
|
1863
|
+
|
|
1864
|
+
prevMaterialIndex = currentIndex;
|
|
1865
|
+
startIndex = i;
|
|
1866
|
+
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
} );
|
|
1870
|
+
|
|
1871
|
+
// the loop above doesn't add the last group, do that here.
|
|
1872
|
+
if ( geo.groups.length > 0 ) {
|
|
1873
|
+
|
|
1874
|
+
const lastGroup = geo.groups[ geo.groups.length - 1 ];
|
|
1875
|
+
const lastIndex = lastGroup.start + lastGroup.count;
|
|
1876
|
+
|
|
1877
|
+
if ( lastIndex !== buffers.materialIndex.length ) {
|
|
1878
|
+
|
|
1879
|
+
geo.addGroup( lastIndex, buffers.materialIndex.length - lastIndex, prevMaterialIndex );
|
|
1880
|
+
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
// case where there are multiple materials but the whole geometry is only
|
|
1886
|
+
// using one of them
|
|
1887
|
+
if ( geo.groups.length === 0 ) {
|
|
1888
|
+
|
|
1889
|
+
geo.addGroup( 0, buffers.materialIndex.length, buffers.materialIndex[ 0 ] );
|
|
1890
|
+
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
this.addMorphTargets( geo, geoNode, morphTargets, preTransform );
|
|
1896
|
+
|
|
1897
|
+
return geo;
|
|
1898
|
+
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
parseGeoNode( geoNode, skeleton ) {
|
|
1902
|
+
|
|
1903
|
+
const geoInfo = {};
|
|
1904
|
+
|
|
1905
|
+
geoInfo.vertexPositions = ( geoNode.Vertices !== undefined ) ? geoNode.Vertices.a : [];
|
|
1906
|
+
geoInfo.vertexIndices = ( geoNode.PolygonVertexIndex !== undefined ) ? geoNode.PolygonVertexIndex.a : [];
|
|
1907
|
+
|
|
1908
|
+
if ( geoNode.LayerElementColor && geoNode.LayerElementColor[ 0 ].Colors ) {
|
|
1909
|
+
|
|
1910
|
+
geoInfo.color = this.parseVertexColors( geoNode.LayerElementColor[ 0 ] );
|
|
1911
|
+
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
if ( geoNode.LayerElementMaterial ) {
|
|
1915
|
+
|
|
1916
|
+
geoInfo.material = this.parseMaterialIndices( geoNode.LayerElementMaterial[ 0 ] );
|
|
1917
|
+
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
if ( geoNode.LayerElementNormal ) {
|
|
1921
|
+
|
|
1922
|
+
geoInfo.normal = this.parseNormals( geoNode.LayerElementNormal[ 0 ] );
|
|
1923
|
+
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
if ( geoNode.LayerElementUV ) {
|
|
1927
|
+
|
|
1928
|
+
geoInfo.uv = [];
|
|
1929
|
+
|
|
1930
|
+
let i = 0;
|
|
1931
|
+
while ( geoNode.LayerElementUV[ i ] ) {
|
|
1932
|
+
|
|
1933
|
+
if ( geoNode.LayerElementUV[ i ].UV ) {
|
|
1934
|
+
|
|
1935
|
+
geoInfo.uv.push( this.parseUVs( geoNode.LayerElementUV[ i ] ) );
|
|
1936
|
+
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
i ++;
|
|
1940
|
+
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
geoInfo.weightTable = {};
|
|
1946
|
+
|
|
1947
|
+
if ( skeleton !== null ) {
|
|
1948
|
+
|
|
1949
|
+
geoInfo.skeleton = skeleton;
|
|
1950
|
+
|
|
1951
|
+
skeleton.rawBones.forEach( function ( rawBone, i ) {
|
|
1952
|
+
|
|
1953
|
+
// loop over the bone's vertex indices and weights
|
|
1954
|
+
rawBone.indices.forEach( function ( index, j ) {
|
|
1955
|
+
|
|
1956
|
+
if ( geoInfo.weightTable[ index ] === undefined ) geoInfo.weightTable[ index ] = [];
|
|
1957
|
+
|
|
1958
|
+
geoInfo.weightTable[ index ].push( {
|
|
1959
|
+
|
|
1960
|
+
id: i,
|
|
1961
|
+
weight: rawBone.weights[ j ],
|
|
1962
|
+
|
|
1963
|
+
} );
|
|
1964
|
+
|
|
1965
|
+
} );
|
|
1966
|
+
|
|
1967
|
+
} );
|
|
1968
|
+
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
return geoInfo;
|
|
1972
|
+
|
|
1973
|
+
}
|
|
1974
|
+
|
|
1975
|
+
genBuffers( geoInfo ) {
|
|
1976
|
+
|
|
1977
|
+
const buffers = {
|
|
1978
|
+
vertex: [],
|
|
1979
|
+
normal: [],
|
|
1980
|
+
colors: [],
|
|
1981
|
+
uvs: [],
|
|
1982
|
+
materialIndex: [],
|
|
1983
|
+
vertexWeights: [],
|
|
1984
|
+
weightsIndices: [],
|
|
1985
|
+
};
|
|
1986
|
+
|
|
1987
|
+
let polygonIndex = 0;
|
|
1988
|
+
let faceLength = 0;
|
|
1989
|
+
let displayedWeightsWarning = false;
|
|
1990
|
+
|
|
1991
|
+
// these will hold data for a single face
|
|
1992
|
+
let facePositionIndexes = [];
|
|
1993
|
+
let faceNormals = [];
|
|
1994
|
+
let faceColors = [];
|
|
1995
|
+
let faceUVs = [];
|
|
1996
|
+
let faceWeights = [];
|
|
1997
|
+
let faceWeightIndices = [];
|
|
1998
|
+
|
|
1999
|
+
const scope = this;
|
|
2000
|
+
geoInfo.vertexIndices.forEach( function ( vertexIndex, polygonVertexIndex ) {
|
|
2001
|
+
|
|
2002
|
+
let materialIndex;
|
|
2003
|
+
let endOfFace = false;
|
|
2004
|
+
|
|
2005
|
+
// Face index and vertex index arrays are combined in a single array
|
|
2006
|
+
// A cube with quad faces looks like this:
|
|
2007
|
+
// PolygonVertexIndex: *24 {
|
|
2008
|
+
// a: 0, 1, 3, -3, 2, 3, 5, -5, 4, 5, 7, -7, 6, 7, 1, -1, 1, 7, 5, -4, 6, 0, 2, -5
|
|
2009
|
+
// }
|
|
2010
|
+
// Negative numbers mark the end of a face - first face here is 0, 1, 3, -3
|
|
2011
|
+
// to find index of last vertex bit shift the index: ^ - 1
|
|
2012
|
+
if ( vertexIndex < 0 ) {
|
|
2013
|
+
|
|
2014
|
+
vertexIndex = vertexIndex ^ - 1; // equivalent to ( x * -1 ) - 1
|
|
2015
|
+
endOfFace = true;
|
|
2016
|
+
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
let weightIndices = [];
|
|
2020
|
+
let weights = [];
|
|
2021
|
+
|
|
2022
|
+
facePositionIndexes.push( vertexIndex * 3, vertexIndex * 3 + 1, vertexIndex * 3 + 2 );
|
|
2023
|
+
|
|
2024
|
+
if ( geoInfo.color ) {
|
|
2025
|
+
|
|
2026
|
+
const data = getData( polygonVertexIndex, polygonIndex, vertexIndex, geoInfo.color );
|
|
2027
|
+
|
|
2028
|
+
faceColors.push( data[ 0 ], data[ 1 ], data[ 2 ] );
|
|
2029
|
+
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
if ( geoInfo.skeleton ) {
|
|
2033
|
+
|
|
2034
|
+
if ( geoInfo.weightTable[ vertexIndex ] !== undefined ) {
|
|
2035
|
+
|
|
2036
|
+
geoInfo.weightTable[ vertexIndex ].forEach( function ( wt ) {
|
|
2037
|
+
|
|
2038
|
+
weights.push( wt.weight );
|
|
2039
|
+
weightIndices.push( wt.id );
|
|
2040
|
+
|
|
2041
|
+
} );
|
|
2042
|
+
|
|
2043
|
+
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
if ( weights.length > 4 ) {
|
|
2047
|
+
|
|
2048
|
+
if ( ! displayedWeightsWarning ) {
|
|
2049
|
+
|
|
2050
|
+
console.warn( 'THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights.' );
|
|
2051
|
+
displayedWeightsWarning = true;
|
|
2052
|
+
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
const wIndex = [ 0, 0, 0, 0 ];
|
|
2056
|
+
const Weight = [ 0, 0, 0, 0 ];
|
|
2057
|
+
|
|
2058
|
+
weights.forEach( function ( weight, weightIndex ) {
|
|
2059
|
+
|
|
2060
|
+
let currentWeight = weight;
|
|
2061
|
+
let currentIndex = weightIndices[ weightIndex ];
|
|
2062
|
+
|
|
2063
|
+
Weight.forEach( function ( comparedWeight, comparedWeightIndex, comparedWeightArray ) {
|
|
2064
|
+
|
|
2065
|
+
if ( currentWeight > comparedWeight ) {
|
|
2066
|
+
|
|
2067
|
+
comparedWeightArray[ comparedWeightIndex ] = currentWeight;
|
|
2068
|
+
currentWeight = comparedWeight;
|
|
2069
|
+
|
|
2070
|
+
const tmp = wIndex[ comparedWeightIndex ];
|
|
2071
|
+
wIndex[ comparedWeightIndex ] = currentIndex;
|
|
2072
|
+
currentIndex = tmp;
|
|
2073
|
+
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
} );
|
|
2077
|
+
|
|
2078
|
+
} );
|
|
2079
|
+
|
|
2080
|
+
weightIndices = wIndex;
|
|
2081
|
+
weights = Weight;
|
|
2082
|
+
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
// if the weight array is shorter than 4 pad with 0s
|
|
2086
|
+
while ( weights.length < 4 ) {
|
|
2087
|
+
|
|
2088
|
+
weights.push( 0 );
|
|
2089
|
+
weightIndices.push( 0 );
|
|
2090
|
+
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
for ( let i = 0; i < 4; ++ i ) {
|
|
2094
|
+
|
|
2095
|
+
faceWeights.push( weights[ i ] );
|
|
2096
|
+
faceWeightIndices.push( weightIndices[ i ] );
|
|
2097
|
+
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
if ( geoInfo.normal ) {
|
|
2103
|
+
|
|
2104
|
+
const data = getData( polygonVertexIndex, polygonIndex, vertexIndex, geoInfo.normal );
|
|
2105
|
+
|
|
2106
|
+
faceNormals.push( data[ 0 ], data[ 1 ], data[ 2 ] );
|
|
2107
|
+
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
if ( geoInfo.material && geoInfo.material.mappingType !== 'AllSame' ) {
|
|
2111
|
+
|
|
2112
|
+
materialIndex = getData( polygonVertexIndex, polygonIndex, vertexIndex, geoInfo.material )[ 0 ];
|
|
2113
|
+
|
|
2114
|
+
if ( materialIndex < 0 ) {
|
|
2115
|
+
|
|
2116
|
+
scope.negativeMaterialIndices = true;
|
|
2117
|
+
materialIndex = 0; // fallback
|
|
2118
|
+
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
}
|
|
2122
|
+
|
|
2123
|
+
if ( geoInfo.uv ) {
|
|
2124
|
+
|
|
2125
|
+
geoInfo.uv.forEach( function ( uv, i ) {
|
|
2126
|
+
|
|
2127
|
+
const data = getData( polygonVertexIndex, polygonIndex, vertexIndex, uv );
|
|
2128
|
+
|
|
2129
|
+
if ( faceUVs[ i ] === undefined ) {
|
|
2130
|
+
|
|
2131
|
+
faceUVs[ i ] = [];
|
|
2132
|
+
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
faceUVs[ i ].push( data[ 0 ] );
|
|
2136
|
+
faceUVs[ i ].push( data[ 1 ] );
|
|
2137
|
+
|
|
2138
|
+
} );
|
|
2139
|
+
|
|
2140
|
+
}
|
|
2141
|
+
|
|
2142
|
+
faceLength ++;
|
|
2143
|
+
|
|
2144
|
+
if ( endOfFace ) {
|
|
2145
|
+
|
|
2146
|
+
scope.genFace( buffers, geoInfo, facePositionIndexes, materialIndex, faceNormals, faceColors, faceUVs, faceWeights, faceWeightIndices, faceLength );
|
|
2147
|
+
|
|
2148
|
+
polygonIndex ++;
|
|
2149
|
+
faceLength = 0;
|
|
2150
|
+
|
|
2151
|
+
// reset arrays for the next face
|
|
2152
|
+
facePositionIndexes = [];
|
|
2153
|
+
faceNormals = [];
|
|
2154
|
+
faceColors = [];
|
|
2155
|
+
faceUVs = [];
|
|
2156
|
+
faceWeights = [];
|
|
2157
|
+
faceWeightIndices = [];
|
|
2158
|
+
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
} );
|
|
2162
|
+
|
|
2163
|
+
return buffers;
|
|
2164
|
+
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
// See https://www.khronos.org/opengl/wiki/Calculating_a_Surface_Normal
|
|
2168
|
+
getNormalNewell( vertices ) {
|
|
2169
|
+
|
|
2170
|
+
const normal = new Vector3( 0.0, 0.0, 0.0 );
|
|
2171
|
+
|
|
2172
|
+
for ( let i = 0; i < vertices.length; i ++ ) {
|
|
2173
|
+
|
|
2174
|
+
const current = vertices[ i ];
|
|
2175
|
+
const next = vertices[ ( i + 1 ) % vertices.length ];
|
|
2176
|
+
|
|
2177
|
+
normal.x += ( current.y - next.y ) * ( current.z + next.z );
|
|
2178
|
+
normal.y += ( current.z - next.z ) * ( current.x + next.x );
|
|
2179
|
+
normal.z += ( current.x - next.x ) * ( current.y + next.y );
|
|
2180
|
+
|
|
2181
|
+
}
|
|
2182
|
+
|
|
2183
|
+
normal.normalize();
|
|
2184
|
+
|
|
2185
|
+
return normal;
|
|
2186
|
+
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
getNormalTangentAndBitangent( vertices ) {
|
|
2190
|
+
|
|
2191
|
+
const normalVector = this.getNormalNewell( vertices );
|
|
2192
|
+
// Avoid up being equal or almost equal to normalVector
|
|
2193
|
+
const up = Math.abs( normalVector.z ) > 0.5 ? new Vector3( 0.0, 1.0, 0.0 ) : new Vector3( 0.0, 0.0, 1.0 );
|
|
2194
|
+
const tangent = up.cross( normalVector ).normalize();
|
|
2195
|
+
const bitangent = normalVector.clone().cross( tangent ).normalize();
|
|
2196
|
+
|
|
2197
|
+
return {
|
|
2198
|
+
normal: normalVector,
|
|
2199
|
+
tangent: tangent,
|
|
2200
|
+
bitangent: bitangent
|
|
2201
|
+
};
|
|
2202
|
+
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
flattenVertex( vertex, normalTangent, normalBitangent ) {
|
|
2206
|
+
|
|
2207
|
+
return new Vector2(
|
|
2208
|
+
vertex.dot( normalTangent ),
|
|
2209
|
+
vertex.dot( normalBitangent )
|
|
2210
|
+
);
|
|
2211
|
+
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
// Generate data for a single face in a geometry. If the face is a quad then split it into 2 tris
|
|
2215
|
+
genFace( buffers, geoInfo, facePositionIndexes, materialIndex, faceNormals, faceColors, faceUVs, faceWeights, faceWeightIndices, faceLength ) {
|
|
2216
|
+
|
|
2217
|
+
let triangles;
|
|
2218
|
+
|
|
2219
|
+
if ( faceLength > 3 ) {
|
|
2220
|
+
|
|
2221
|
+
// Triangulate n-gon using earcut
|
|
2222
|
+
|
|
2223
|
+
const vertices = [];
|
|
2224
|
+
// in morphing scenario vertexPositions represent morphPositions
|
|
2225
|
+
// while baseVertexPositions represent the original geometry's positions
|
|
2226
|
+
const positions = geoInfo.baseVertexPositions || geoInfo.vertexPositions;
|
|
2227
|
+
for ( let i = 0; i < facePositionIndexes.length; i += 3 ) {
|
|
2228
|
+
|
|
2229
|
+
vertices.push(
|
|
2230
|
+
new Vector3(
|
|
2231
|
+
positions[ facePositionIndexes[ i ] ],
|
|
2232
|
+
positions[ facePositionIndexes[ i + 1 ] ],
|
|
2233
|
+
positions[ facePositionIndexes[ i + 2 ] ]
|
|
2234
|
+
)
|
|
2235
|
+
);
|
|
2236
|
+
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
const { tangent, bitangent } = this.getNormalTangentAndBitangent( vertices );
|
|
2240
|
+
const triangulationInput = [];
|
|
2241
|
+
|
|
2242
|
+
for ( const vertex of vertices ) {
|
|
2243
|
+
|
|
2244
|
+
triangulationInput.push( this.flattenVertex( vertex, tangent, bitangent ) );
|
|
2245
|
+
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2248
|
+
// When vertices is an array of [0,0,0] elements (which is the case for vertices not participating in morph)
|
|
2249
|
+
// the triangulationInput will be an array of [0,0] elements
|
|
2250
|
+
// resulting in an array of 0 triangles being returned from ShapeUtils.triangulateShape
|
|
2251
|
+
// leading to not pushing into buffers.vertex the redundant vertices (the vertices that are not morphed).
|
|
2252
|
+
// That's why, in order to support morphing scenario, "positions" is looking first for baseVertexPositions,
|
|
2253
|
+
// so that we don't end up with an array of 0 triangles for the faces not participating in morph.
|
|
2254
|
+
triangles = ShapeUtils.triangulateShape( triangulationInput, [] );
|
|
2255
|
+
|
|
2256
|
+
} else {
|
|
2257
|
+
|
|
2258
|
+
// Regular triangle, skip earcut triangulation step
|
|
2259
|
+
triangles = [[ 0, 1, 2 ]];
|
|
2260
|
+
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
for ( const [ i0, i1, i2 ] of triangles ) {
|
|
2264
|
+
|
|
2265
|
+
buffers.vertex.push( geoInfo.vertexPositions[ facePositionIndexes[ i0 * 3 ] ] );
|
|
2266
|
+
buffers.vertex.push( geoInfo.vertexPositions[ facePositionIndexes[ i0 * 3 + 1 ] ] );
|
|
2267
|
+
buffers.vertex.push( geoInfo.vertexPositions[ facePositionIndexes[ i0 * 3 + 2 ] ] );
|
|
2268
|
+
|
|
2269
|
+
buffers.vertex.push( geoInfo.vertexPositions[ facePositionIndexes[ i1 * 3 ] ] );
|
|
2270
|
+
buffers.vertex.push( geoInfo.vertexPositions[ facePositionIndexes[ i1 * 3 + 1 ] ] );
|
|
2271
|
+
buffers.vertex.push( geoInfo.vertexPositions[ facePositionIndexes[ i1 * 3 + 2 ] ] );
|
|
2272
|
+
|
|
2273
|
+
buffers.vertex.push( geoInfo.vertexPositions[ facePositionIndexes[ i2 * 3 ] ] );
|
|
2274
|
+
buffers.vertex.push( geoInfo.vertexPositions[ facePositionIndexes[ i2 * 3 + 1 ] ] );
|
|
2275
|
+
buffers.vertex.push( geoInfo.vertexPositions[ facePositionIndexes[ i2 * 3 + 2 ] ] );
|
|
2276
|
+
|
|
2277
|
+
if ( geoInfo.skeleton ) {
|
|
2278
|
+
|
|
2279
|
+
buffers.vertexWeights.push( faceWeights[ i0 * 4 ] );
|
|
2280
|
+
buffers.vertexWeights.push( faceWeights[ i0 * 4 + 1 ] );
|
|
2281
|
+
buffers.vertexWeights.push( faceWeights[ i0 * 4 + 2 ] );
|
|
2282
|
+
buffers.vertexWeights.push( faceWeights[ i0 * 4 + 3 ] );
|
|
2283
|
+
|
|
2284
|
+
buffers.vertexWeights.push( faceWeights[ i1 * 4 ] );
|
|
2285
|
+
buffers.vertexWeights.push( faceWeights[ i1 * 4 + 1 ] );
|
|
2286
|
+
buffers.vertexWeights.push( faceWeights[ i1 * 4 + 2 ] );
|
|
2287
|
+
buffers.vertexWeights.push( faceWeights[ i1 * 4 + 3 ] );
|
|
2288
|
+
|
|
2289
|
+
buffers.vertexWeights.push( faceWeights[ i2 * 4 ] );
|
|
2290
|
+
buffers.vertexWeights.push( faceWeights[ i2 * 4 + 1 ] );
|
|
2291
|
+
buffers.vertexWeights.push( faceWeights[ i2 * 4 + 2 ] );
|
|
2292
|
+
buffers.vertexWeights.push( faceWeights[ i2 * 4 + 3 ] );
|
|
2293
|
+
|
|
2294
|
+
buffers.weightsIndices.push( faceWeightIndices[ i0 * 4 ] );
|
|
2295
|
+
buffers.weightsIndices.push( faceWeightIndices[ i0 * 4 + 1 ] );
|
|
2296
|
+
buffers.weightsIndices.push( faceWeightIndices[ i0 * 4 + 2 ] );
|
|
2297
|
+
buffers.weightsIndices.push( faceWeightIndices[ i0 * 4 + 3 ] );
|
|
2298
|
+
|
|
2299
|
+
buffers.weightsIndices.push( faceWeightIndices[ i1 * 4 ] );
|
|
2300
|
+
buffers.weightsIndices.push( faceWeightIndices[ i1 * 4 + 1 ] );
|
|
2301
|
+
buffers.weightsIndices.push( faceWeightIndices[ i1 * 4 + 2 ] );
|
|
2302
|
+
buffers.weightsIndices.push( faceWeightIndices[ i1 * 4 + 3 ] );
|
|
2303
|
+
|
|
2304
|
+
buffers.weightsIndices.push( faceWeightIndices[ i2 * 4 ] );
|
|
2305
|
+
buffers.weightsIndices.push( faceWeightIndices[ i2 * 4 + 1 ] );
|
|
2306
|
+
buffers.weightsIndices.push( faceWeightIndices[ i2 * 4 + 2 ] );
|
|
2307
|
+
buffers.weightsIndices.push( faceWeightIndices[ i2 * 4 + 3 ] );
|
|
2308
|
+
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
if ( geoInfo.color ) {
|
|
2312
|
+
|
|
2313
|
+
buffers.colors.push( faceColors[ i0 * 3 ] );
|
|
2314
|
+
buffers.colors.push( faceColors[ i0 * 3 + 1 ] );
|
|
2315
|
+
buffers.colors.push( faceColors[ i0 * 3 + 2 ] );
|
|
2316
|
+
|
|
2317
|
+
buffers.colors.push( faceColors[ i1 * 3 ] );
|
|
2318
|
+
buffers.colors.push( faceColors[ i1 * 3 + 1 ] );
|
|
2319
|
+
buffers.colors.push( faceColors[ i1 * 3 + 2 ] );
|
|
2320
|
+
|
|
2321
|
+
buffers.colors.push( faceColors[ i2 * 3 ] );
|
|
2322
|
+
buffers.colors.push( faceColors[ i2 * 3 + 1 ] );
|
|
2323
|
+
buffers.colors.push( faceColors[ i2 * 3 + 2 ] );
|
|
2324
|
+
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2327
|
+
if ( geoInfo.material && geoInfo.material.mappingType !== 'AllSame' ) {
|
|
2328
|
+
|
|
2329
|
+
buffers.materialIndex.push( materialIndex );
|
|
2330
|
+
buffers.materialIndex.push( materialIndex );
|
|
2331
|
+
buffers.materialIndex.push( materialIndex );
|
|
2332
|
+
|
|
2333
|
+
}
|
|
2334
|
+
|
|
2335
|
+
if ( geoInfo.normal ) {
|
|
2336
|
+
|
|
2337
|
+
buffers.normal.push( faceNormals[ i0 * 3 ] );
|
|
2338
|
+
buffers.normal.push( faceNormals[ i0 * 3 + 1 ] );
|
|
2339
|
+
buffers.normal.push( faceNormals[ i0 * 3 + 2 ] );
|
|
2340
|
+
|
|
2341
|
+
buffers.normal.push( faceNormals[ i1 * 3 ] );
|
|
2342
|
+
buffers.normal.push( faceNormals[ i1 * 3 + 1 ] );
|
|
2343
|
+
buffers.normal.push( faceNormals[ i1 * 3 + 2 ] );
|
|
2344
|
+
|
|
2345
|
+
buffers.normal.push( faceNormals[ i2 * 3 ] );
|
|
2346
|
+
buffers.normal.push( faceNormals[ i2 * 3 + 1 ] );
|
|
2347
|
+
buffers.normal.push( faceNormals[ i2 * 3 + 2 ] );
|
|
2348
|
+
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2351
|
+
if ( geoInfo.uv ) {
|
|
2352
|
+
|
|
2353
|
+
geoInfo.uv.forEach( function ( uv, j ) {
|
|
2354
|
+
|
|
2355
|
+
if ( buffers.uvs[ j ] === undefined ) buffers.uvs[ j ] = [];
|
|
2356
|
+
|
|
2357
|
+
buffers.uvs[ j ].push( faceUVs[ j ][ i0 * 2 ] );
|
|
2358
|
+
buffers.uvs[ j ].push( faceUVs[ j ][ i0 * 2 + 1 ] );
|
|
2359
|
+
|
|
2360
|
+
buffers.uvs[ j ].push( faceUVs[ j ][ i1 * 2 ] );
|
|
2361
|
+
buffers.uvs[ j ].push( faceUVs[ j ][ i1 * 2 + 1 ] );
|
|
2362
|
+
|
|
2363
|
+
buffers.uvs[ j ].push( faceUVs[ j ][ i2 * 2 ] );
|
|
2364
|
+
buffers.uvs[ j ].push( faceUVs[ j ][ i2 * 2 + 1 ] );
|
|
2365
|
+
|
|
2366
|
+
} );
|
|
2367
|
+
|
|
2368
|
+
}
|
|
2369
|
+
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
}
|
|
2373
|
+
|
|
2374
|
+
addMorphTargets( parentGeo, parentGeoNode, morphTargets, preTransform ) {
|
|
2375
|
+
|
|
2376
|
+
if ( morphTargets.length === 0 ) return;
|
|
2377
|
+
|
|
2378
|
+
parentGeo.morphTargetsRelative = true;
|
|
2379
|
+
|
|
2380
|
+
parentGeo.morphAttributes.position = [];
|
|
2381
|
+
// parentGeo.morphAttributes.normal = []; // not implemented
|
|
2382
|
+
|
|
2383
|
+
// Morph attribute positions are stored as deltas (morphTargetsRelative = true), so the
|
|
2384
|
+
// translation component of the geometric transform must not be applied to them — only the
|
|
2385
|
+
// rotation/scale part. Otherwise every delta gets the geometric translation added, which
|
|
2386
|
+
// shifts morphed vertices away from their intended position by `weight * translation` as
|
|
2387
|
+
// the influence increases.
|
|
2388
|
+
const morphPreTransform = preTransform.clone().setPosition( 0, 0, 0 );
|
|
2389
|
+
|
|
2390
|
+
const scope = this;
|
|
2391
|
+
morphTargets.forEach( function ( morphTarget ) {
|
|
2392
|
+
|
|
2393
|
+
morphTarget.rawTargets.forEach( function ( rawTarget ) {
|
|
2394
|
+
|
|
2395
|
+
const morphGeoNode = fbxTree.Objects.Geometry[ rawTarget.geoID ];
|
|
2396
|
+
|
|
2397
|
+
if ( morphGeoNode !== undefined ) {
|
|
2398
|
+
|
|
2399
|
+
scope.genMorphGeometry( parentGeo, parentGeoNode, morphGeoNode, morphPreTransform, rawTarget.name );
|
|
2400
|
+
|
|
2401
|
+
}
|
|
2402
|
+
|
|
2403
|
+
} );
|
|
2404
|
+
|
|
2405
|
+
} );
|
|
2406
|
+
|
|
2407
|
+
}
|
|
2408
|
+
|
|
2409
|
+
// a morph geometry node is similar to a standard node, and the node is also contained
|
|
2410
|
+
// in FBXTree.Objects.Geometry, however it can only have attributes for position, normal
|
|
2411
|
+
// and a special attribute Index defining which vertices of the original geometry are affected
|
|
2412
|
+
// Normal and position attributes only have data for the vertices that are affected by the morph
|
|
2413
|
+
genMorphGeometry( parentGeo, parentGeoNode, morphGeoNode, preTransform, name ) {
|
|
2414
|
+
|
|
2415
|
+
const basePositions = parentGeoNode.Vertices !== undefined ? parentGeoNode.Vertices.a : [];
|
|
2416
|
+
const baseIndices = parentGeoNode.PolygonVertexIndex !== undefined ? parentGeoNode.PolygonVertexIndex.a : [];
|
|
2417
|
+
|
|
2418
|
+
const morphPositionsSparse = morphGeoNode.Vertices !== undefined ? morphGeoNode.Vertices.a : [];
|
|
2419
|
+
const morphIndices = morphGeoNode.Indexes !== undefined ? morphGeoNode.Indexes.a : [];
|
|
2420
|
+
|
|
2421
|
+
const length = parentGeo.attributes.position.count * 3;
|
|
2422
|
+
const morphPositions = new Float32Array( length );
|
|
2423
|
+
|
|
2424
|
+
for ( let i = 0; i < morphIndices.length; i ++ ) {
|
|
2425
|
+
|
|
2426
|
+
const morphIndex = morphIndices[ i ] * 3;
|
|
2427
|
+
|
|
2428
|
+
morphPositions[ morphIndex ] = morphPositionsSparse[ i * 3 ];
|
|
2429
|
+
morphPositions[ morphIndex + 1 ] = morphPositionsSparse[ i * 3 + 1 ];
|
|
2430
|
+
morphPositions[ morphIndex + 2 ] = morphPositionsSparse[ i * 3 + 2 ];
|
|
2431
|
+
|
|
2432
|
+
}
|
|
2433
|
+
|
|
2434
|
+
// TODO: add morph normal support
|
|
2435
|
+
const morphGeoInfo = {
|
|
2436
|
+
vertexIndices: baseIndices,
|
|
2437
|
+
vertexPositions: morphPositions,
|
|
2438
|
+
baseVertexPositions: basePositions
|
|
2439
|
+
};
|
|
2440
|
+
|
|
2441
|
+
const morphBuffers = this.genBuffers( morphGeoInfo );
|
|
2442
|
+
|
|
2443
|
+
const positionAttribute = new Float32BufferAttribute( morphBuffers.vertex, 3 );
|
|
2444
|
+
positionAttribute.name = name || morphGeoNode.attrName;
|
|
2445
|
+
|
|
2446
|
+
positionAttribute.applyMatrix4( preTransform );
|
|
2447
|
+
|
|
2448
|
+
parentGeo.morphAttributes.position.push( positionAttribute );
|
|
2449
|
+
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
// Parse normal from FBXTree.Objects.Geometry.LayerElementNormal if it exists
|
|
2453
|
+
parseNormals( NormalNode ) {
|
|
2454
|
+
|
|
2455
|
+
const mappingType = NormalNode.MappingInformationType;
|
|
2456
|
+
const referenceType = NormalNode.ReferenceInformationType;
|
|
2457
|
+
const buffer = NormalNode.Normals.a;
|
|
2458
|
+
let indexBuffer = [];
|
|
2459
|
+
if ( referenceType === 'IndexToDirect' ) {
|
|
2460
|
+
|
|
2461
|
+
if ( 'NormalIndex' in NormalNode ) {
|
|
2462
|
+
|
|
2463
|
+
indexBuffer = NormalNode.NormalIndex.a;
|
|
2464
|
+
|
|
2465
|
+
} else if ( 'NormalsIndex' in NormalNode ) {
|
|
2466
|
+
|
|
2467
|
+
indexBuffer = NormalNode.NormalsIndex.a;
|
|
2468
|
+
|
|
2469
|
+
}
|
|
2470
|
+
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
return {
|
|
2474
|
+
dataSize: 3,
|
|
2475
|
+
buffer: buffer,
|
|
2476
|
+
indices: indexBuffer,
|
|
2477
|
+
mappingType: mappingType,
|
|
2478
|
+
referenceType: referenceType
|
|
2479
|
+
};
|
|
2480
|
+
|
|
2481
|
+
}
|
|
2482
|
+
|
|
2483
|
+
// Parse UVs from FBXTree.Objects.Geometry.LayerElementUV if it exists
|
|
2484
|
+
parseUVs( UVNode ) {
|
|
2485
|
+
|
|
2486
|
+
const mappingType = UVNode.MappingInformationType;
|
|
2487
|
+
const referenceType = UVNode.ReferenceInformationType;
|
|
2488
|
+
const buffer = UVNode.UV.a;
|
|
2489
|
+
let indexBuffer = [];
|
|
2490
|
+
if ( referenceType === 'IndexToDirect' ) {
|
|
2491
|
+
|
|
2492
|
+
indexBuffer = UVNode.UVIndex.a;
|
|
2493
|
+
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2496
|
+
return {
|
|
2497
|
+
dataSize: 2,
|
|
2498
|
+
buffer: buffer,
|
|
2499
|
+
indices: indexBuffer,
|
|
2500
|
+
mappingType: mappingType,
|
|
2501
|
+
referenceType: referenceType
|
|
2502
|
+
};
|
|
2503
|
+
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
// Parse Vertex Colors from FBXTree.Objects.Geometry.LayerElementColor if it exists
|
|
2507
|
+
parseVertexColors( ColorNode ) {
|
|
2508
|
+
|
|
2509
|
+
const mappingType = ColorNode.MappingInformationType;
|
|
2510
|
+
const referenceType = ColorNode.ReferenceInformationType;
|
|
2511
|
+
const buffer = ColorNode.Colors.a;
|
|
2512
|
+
let indexBuffer = [];
|
|
2513
|
+
if ( referenceType === 'IndexToDirect' ) {
|
|
2514
|
+
|
|
2515
|
+
indexBuffer = ColorNode.ColorIndex.a;
|
|
2516
|
+
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2519
|
+
for ( let i = 0, c = new Color(); i < buffer.length; i += 4 ) {
|
|
2520
|
+
|
|
2521
|
+
c.fromArray( buffer, i );
|
|
2522
|
+
ColorManagement.colorSpaceToWorking( c, SRGBColorSpace );
|
|
2523
|
+
c.toArray( buffer, i );
|
|
2524
|
+
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
return {
|
|
2528
|
+
dataSize: 4,
|
|
2529
|
+
buffer: buffer,
|
|
2530
|
+
indices: indexBuffer,
|
|
2531
|
+
mappingType: mappingType,
|
|
2532
|
+
referenceType: referenceType
|
|
2533
|
+
};
|
|
2534
|
+
|
|
2535
|
+
}
|
|
2536
|
+
|
|
2537
|
+
// Parse mapping and material data in FBXTree.Objects.Geometry.LayerElementMaterial if it exists
|
|
2538
|
+
parseMaterialIndices( MaterialNode ) {
|
|
2539
|
+
|
|
2540
|
+
const mappingType = MaterialNode.MappingInformationType;
|
|
2541
|
+
const referenceType = MaterialNode.ReferenceInformationType;
|
|
2542
|
+
|
|
2543
|
+
if ( mappingType === 'NoMappingInformation' ) {
|
|
2544
|
+
|
|
2545
|
+
return {
|
|
2546
|
+
dataSize: 1,
|
|
2547
|
+
buffer: [ 0 ],
|
|
2548
|
+
indices: [ 0 ],
|
|
2549
|
+
mappingType: 'AllSame',
|
|
2550
|
+
referenceType: referenceType
|
|
2551
|
+
};
|
|
2552
|
+
|
|
2553
|
+
}
|
|
2554
|
+
|
|
2555
|
+
const materialIndexBuffer = MaterialNode.Materials.a;
|
|
2556
|
+
|
|
2557
|
+
// Since materials are stored as indices, there's a bit of a mismatch between FBX and what
|
|
2558
|
+
// we expect.So we create an intermediate buffer that points to the index in the buffer,
|
|
2559
|
+
// for conforming with the other functions we've written for other data.
|
|
2560
|
+
const materialIndices = [];
|
|
2561
|
+
|
|
2562
|
+
for ( let i = 0; i < materialIndexBuffer.length; ++ i ) {
|
|
2563
|
+
|
|
2564
|
+
materialIndices.push( i );
|
|
2565
|
+
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
return {
|
|
2569
|
+
dataSize: 1,
|
|
2570
|
+
buffer: materialIndexBuffer,
|
|
2571
|
+
indices: materialIndices,
|
|
2572
|
+
mappingType: mappingType,
|
|
2573
|
+
referenceType: referenceType
|
|
2574
|
+
};
|
|
2575
|
+
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
// Generate a NurbGeometry from a node in FBXTree.Objects.Geometry
|
|
2579
|
+
parseNurbsGeometry( geoNode ) {
|
|
2580
|
+
|
|
2581
|
+
const order = parseInt( geoNode.Order );
|
|
2582
|
+
|
|
2583
|
+
if ( isNaN( order ) ) {
|
|
2584
|
+
|
|
2585
|
+
console.error( 'THREE.FBXLoader: Invalid Order %s given for geometry ID: %s', geoNode.Order, geoNode.id );
|
|
2586
|
+
return new BufferGeometry();
|
|
2587
|
+
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
const degree = order - 1;
|
|
2591
|
+
|
|
2592
|
+
const knots = geoNode.KnotVector.a;
|
|
2593
|
+
const controlPoints = [];
|
|
2594
|
+
const pointsValues = geoNode.Points.a;
|
|
2595
|
+
|
|
2596
|
+
for ( let i = 0, l = pointsValues.length; i < l; i += 4 ) {
|
|
2597
|
+
|
|
2598
|
+
controlPoints.push( new Vector4().fromArray( pointsValues, i ) );
|
|
2599
|
+
|
|
2600
|
+
}
|
|
2601
|
+
|
|
2602
|
+
let startKnot, endKnot;
|
|
2603
|
+
|
|
2604
|
+
if ( geoNode.Form === 'Closed' ) {
|
|
2605
|
+
|
|
2606
|
+
controlPoints.push( controlPoints[ 0 ] );
|
|
2607
|
+
|
|
2608
|
+
} else if ( geoNode.Form === 'Periodic' ) {
|
|
2609
|
+
|
|
2610
|
+
startKnot = degree;
|
|
2611
|
+
endKnot = knots.length - 1 - startKnot;
|
|
2612
|
+
|
|
2613
|
+
for ( let i = 0; i < degree; ++ i ) {
|
|
2614
|
+
|
|
2615
|
+
controlPoints.push( controlPoints[ i ] );
|
|
2616
|
+
|
|
2617
|
+
}
|
|
2618
|
+
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2621
|
+
const curve = new NURBSCurve( degree, knots, controlPoints, startKnot, endKnot );
|
|
2622
|
+
const points = curve.getPoints( controlPoints.length * 12 );
|
|
2623
|
+
|
|
2624
|
+
return new BufferGeometry().setFromPoints( points );
|
|
2625
|
+
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2628
|
+
}
|
|
2629
|
+
|
|
2630
|
+
// parse animation data from FBXTree
|
|
2631
|
+
class AnimationParser {
|
|
2632
|
+
|
|
2633
|
+
constructor( trimAnimationClips ) {
|
|
2634
|
+
|
|
2635
|
+
this.trimAnimationClips = trimAnimationClips;
|
|
2636
|
+
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
// take raw animation clips and turn them into three.js animation clips
|
|
2640
|
+
parse() {
|
|
2641
|
+
|
|
2642
|
+
const animationClips = [];
|
|
2643
|
+
|
|
2644
|
+
const rawClips = this.parseClips();
|
|
2645
|
+
|
|
2646
|
+
if ( rawClips !== undefined ) {
|
|
2647
|
+
|
|
2648
|
+
for ( const key in rawClips ) {
|
|
2649
|
+
|
|
2650
|
+
const rawClip = rawClips[ key ];
|
|
2651
|
+
|
|
2652
|
+
const clip = this.addClip( rawClip );
|
|
2653
|
+
|
|
2654
|
+
animationClips.push( clip );
|
|
2655
|
+
|
|
2656
|
+
}
|
|
2657
|
+
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
return animationClips;
|
|
2661
|
+
|
|
2662
|
+
}
|
|
2663
|
+
|
|
2664
|
+
parseClips() {
|
|
2665
|
+
|
|
2666
|
+
// since the actual transformation data is stored in FBXTree.Objects.AnimationCurve,
|
|
2667
|
+
// if this is undefined we can safely assume there are no animations
|
|
2668
|
+
if ( fbxTree.Objects.AnimationCurve === undefined ) return undefined;
|
|
2669
|
+
|
|
2670
|
+
const curveNodesMap = this.parseAnimationCurveNodes();
|
|
2671
|
+
|
|
2672
|
+
this.parseAnimationCurves( curveNodesMap );
|
|
2673
|
+
|
|
2674
|
+
const layersMap = this.parseAnimationLayers( curveNodesMap );
|
|
2675
|
+
const rawClips = this.parseAnimStacks( layersMap );
|
|
2676
|
+
|
|
2677
|
+
return rawClips;
|
|
2678
|
+
|
|
2679
|
+
}
|
|
2680
|
+
|
|
2681
|
+
// parse nodes in FBXTree.Objects.AnimationCurveNode
|
|
2682
|
+
// each AnimationCurveNode holds data for an animation transform for a model (e.g. left arm rotation )
|
|
2683
|
+
// and is referenced by an AnimationLayer
|
|
2684
|
+
parseAnimationCurveNodes() {
|
|
2685
|
+
|
|
2686
|
+
const rawCurveNodes = fbxTree.Objects.AnimationCurveNode;
|
|
2687
|
+
|
|
2688
|
+
const curveNodesMap = new Map();
|
|
2689
|
+
|
|
2690
|
+
for ( const nodeID in rawCurveNodes ) {
|
|
2691
|
+
|
|
2692
|
+
const rawCurveNode = rawCurveNodes[ nodeID ];
|
|
2693
|
+
|
|
2694
|
+
if ( rawCurveNode.attrName.match( /S|R|T|DeformPercent/ ) !== null ) {
|
|
2695
|
+
|
|
2696
|
+
const curveNode = {
|
|
2697
|
+
|
|
2698
|
+
id: rawCurveNode.id,
|
|
2699
|
+
attr: rawCurveNode.attrName,
|
|
2700
|
+
curves: {},
|
|
2701
|
+
|
|
2702
|
+
};
|
|
2703
|
+
|
|
2704
|
+
curveNodesMap.set( curveNode.id, curveNode );
|
|
2705
|
+
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2708
|
+
}
|
|
2709
|
+
|
|
2710
|
+
return curveNodesMap;
|
|
2711
|
+
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2714
|
+
// parse nodes in FBXTree.Objects.AnimationCurve and connect them up to
|
|
2715
|
+
// previously parsed AnimationCurveNodes. Each AnimationCurve holds data for a single animated
|
|
2716
|
+
// axis ( e.g. times and values of x rotation)
|
|
2717
|
+
parseAnimationCurves( curveNodesMap ) {
|
|
2718
|
+
|
|
2719
|
+
const rawCurves = fbxTree.Objects.AnimationCurve;
|
|
2720
|
+
|
|
2721
|
+
// TODO: Many values are identical up to roundoff error, but won't be optimised
|
|
2722
|
+
// e.g. position times: [0, 0.4, 0. 8]
|
|
2723
|
+
// position values: [7.23538335023477e-7, 93.67518615722656, -0.9982695579528809, 7.23538335023477e-7, 93.67518615722656, -0.9982695579528809, 7.235384487103147e-7, 93.67520904541016, -0.9982695579528809]
|
|
2724
|
+
// clearly, this should be optimised to
|
|
2725
|
+
// times: [0], positions [7.23538335023477e-7, 93.67518615722656, -0.9982695579528809]
|
|
2726
|
+
// this shows up in nearly every FBX file, and generally time array is length > 100
|
|
2727
|
+
|
|
2728
|
+
for ( const nodeID in rawCurves ) {
|
|
2729
|
+
|
|
2730
|
+
const animationCurve = {
|
|
2731
|
+
|
|
2732
|
+
id: rawCurves[ nodeID ].id,
|
|
2733
|
+
times: rawCurves[ nodeID ].KeyTime.a.map( convertFBXTimeToSeconds ),
|
|
2734
|
+
values: rawCurves[ nodeID ].KeyValueFloat.a,
|
|
2735
|
+
|
|
2736
|
+
};
|
|
2737
|
+
|
|
2738
|
+
const relationships = connections.get( animationCurve.id );
|
|
2739
|
+
|
|
2740
|
+
if ( relationships !== undefined ) {
|
|
2741
|
+
|
|
2742
|
+
const animationCurveID = relationships.parents[ 0 ].ID;
|
|
2743
|
+
const animationCurveRelationship = relationships.parents[ 0 ].relationship;
|
|
2744
|
+
|
|
2745
|
+
if ( animationCurveRelationship.match( /X/ ) ) {
|
|
2746
|
+
|
|
2747
|
+
curveNodesMap.get( animationCurveID ).curves[ 'x' ] = animationCurve;
|
|
2748
|
+
|
|
2749
|
+
} else if ( animationCurveRelationship.match( /Y/ ) ) {
|
|
2750
|
+
|
|
2751
|
+
curveNodesMap.get( animationCurveID ).curves[ 'y' ] = animationCurve;
|
|
2752
|
+
|
|
2753
|
+
} else if ( animationCurveRelationship.match( /Z/ ) ) {
|
|
2754
|
+
|
|
2755
|
+
curveNodesMap.get( animationCurveID ).curves[ 'z' ] = animationCurve;
|
|
2756
|
+
|
|
2757
|
+
} else if ( animationCurveRelationship.match( /DeformPercent/ ) && curveNodesMap.has( animationCurveID ) ) {
|
|
2758
|
+
|
|
2759
|
+
curveNodesMap.get( animationCurveID ).curves[ 'morph' ] = animationCurve;
|
|
2760
|
+
|
|
2761
|
+
}
|
|
2762
|
+
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
}
|
|
2768
|
+
|
|
2769
|
+
// parse nodes in FBXTree.Objects.AnimationLayer. Each layers holds references
|
|
2770
|
+
// to various AnimationCurveNodes and is referenced by an AnimationStack node
|
|
2771
|
+
// note: theoretically a stack can have multiple layers, however in practice there always seems to be one per stack
|
|
2772
|
+
parseAnimationLayers( curveNodesMap ) {
|
|
2773
|
+
|
|
2774
|
+
const rawLayers = fbxTree.Objects.AnimationLayer;
|
|
2775
|
+
|
|
2776
|
+
const layersMap = new Map();
|
|
2777
|
+
|
|
2778
|
+
for ( const nodeID in rawLayers ) {
|
|
2779
|
+
|
|
2780
|
+
const layerCurveNodes = [];
|
|
2781
|
+
|
|
2782
|
+
const connection = connections.get( parseInt( nodeID ) );
|
|
2783
|
+
|
|
2784
|
+
if ( connection !== undefined ) {
|
|
2785
|
+
|
|
2786
|
+
// all the animationCurveNodes used in the layer
|
|
2787
|
+
const children = connection.children;
|
|
2788
|
+
|
|
2789
|
+
children.forEach( function ( child, i ) {
|
|
2790
|
+
|
|
2791
|
+
if ( curveNodesMap.has( child.ID ) ) {
|
|
2792
|
+
|
|
2793
|
+
const curveNode = curveNodesMap.get( child.ID );
|
|
2794
|
+
|
|
2795
|
+
// check that the curves are defined for at least one axis, otherwise ignore the curveNode
|
|
2796
|
+
if ( curveNode.curves.x !== undefined || curveNode.curves.y !== undefined || curveNode.curves.z !== undefined ) {
|
|
2797
|
+
|
|
2798
|
+
if ( layerCurveNodes[ i ] === undefined ) {
|
|
2799
|
+
|
|
2800
|
+
const filteredParents = connections.get( child.ID ).parents.filter( function ( parent ) {
|
|
2801
|
+
|
|
2802
|
+
return parent.relationship !== undefined;
|
|
2803
|
+
|
|
2804
|
+
} );
|
|
2805
|
+
|
|
2806
|
+
if ( filteredParents.length === 0 ) return;
|
|
2807
|
+
|
|
2808
|
+
const modelID = filteredParents[ 0 ].ID;
|
|
2809
|
+
|
|
2810
|
+
if ( modelID !== undefined ) {
|
|
2811
|
+
|
|
2812
|
+
const rawModel = fbxTree.Objects.Model[ modelID.toString() ];
|
|
2813
|
+
|
|
2814
|
+
if ( rawModel === undefined ) {
|
|
2815
|
+
|
|
2816
|
+
console.warn( 'THREE.FBXLoader: Encountered a unused curve.', child );
|
|
2817
|
+
return;
|
|
2818
|
+
|
|
2819
|
+
}
|
|
2820
|
+
|
|
2821
|
+
const node = {
|
|
2822
|
+
|
|
2823
|
+
modelName: rawModel.attrName ? PropertyBinding.sanitizeNodeName( rawModel.attrName ) : '',
|
|
2824
|
+
ID: rawModel.id,
|
|
2825
|
+
initialPosition: [ 0, 0, 0 ],
|
|
2826
|
+
initialRotation: [ 0, 0, 0 ],
|
|
2827
|
+
initialScale: [ 1, 1, 1 ],
|
|
2828
|
+
|
|
2829
|
+
};
|
|
2830
|
+
|
|
2831
|
+
sceneGraph.traverse( function ( child ) {
|
|
2832
|
+
|
|
2833
|
+
if ( child.ID === rawModel.id ) {
|
|
2834
|
+
|
|
2835
|
+
node.transform = child.matrix;
|
|
2836
|
+
|
|
2837
|
+
if ( child.userData.transformData ) {
|
|
2838
|
+
|
|
2839
|
+
node.eulerOrder = child.userData.transformData.eulerOrder;
|
|
2840
|
+
|
|
2841
|
+
if ( child.userData.transformData.rotation ) node.initialRotation = child.userData.transformData.rotation;
|
|
2842
|
+
|
|
2843
|
+
}
|
|
2844
|
+
|
|
2845
|
+
}
|
|
2846
|
+
|
|
2847
|
+
} );
|
|
2848
|
+
|
|
2849
|
+
if ( ! node.transform ) node.transform = new Matrix4();
|
|
2850
|
+
|
|
2851
|
+
// if the animated model is pre rotated, we'll have to apply the pre rotations to every
|
|
2852
|
+
// animation value as well
|
|
2853
|
+
if ( 'PreRotation' in rawModel ) node.preRotation = rawModel.PreRotation.value;
|
|
2854
|
+
if ( 'PostRotation' in rawModel ) node.postRotation = rawModel.PostRotation.value;
|
|
2855
|
+
|
|
2856
|
+
layerCurveNodes[ i ] = node;
|
|
2857
|
+
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2860
|
+
}
|
|
2861
|
+
|
|
2862
|
+
if ( layerCurveNodes[ i ] ) layerCurveNodes[ i ][ curveNode.attr ] = curveNode;
|
|
2863
|
+
|
|
2864
|
+
} else if ( curveNode.curves.morph !== undefined ) {
|
|
2865
|
+
|
|
2866
|
+
if ( layerCurveNodes[ i ] === undefined ) {
|
|
2867
|
+
|
|
2868
|
+
const filteredParents = connections.get( child.ID ).parents.filter( function ( parent ) {
|
|
2869
|
+
|
|
2870
|
+
return parent.relationship !== undefined;
|
|
2871
|
+
|
|
2872
|
+
} );
|
|
2873
|
+
|
|
2874
|
+
if ( filteredParents.length === 0 ) return;
|
|
2875
|
+
|
|
2876
|
+
const deformerID = filteredParents[ 0 ].ID;
|
|
2877
|
+
|
|
2878
|
+
const morpherID = connections.get( deformerID ).parents[ 0 ].ID;
|
|
2879
|
+
const geoID = connections.get( morpherID ).parents[ 0 ].ID;
|
|
2880
|
+
|
|
2881
|
+
// assuming geometry is not used in more than one model
|
|
2882
|
+
const modelID = connections.get( geoID ).parents[ 0 ].ID;
|
|
2883
|
+
|
|
2884
|
+
const rawModel = fbxTree.Objects.Model[ modelID ];
|
|
2885
|
+
|
|
2886
|
+
const node = {
|
|
2887
|
+
|
|
2888
|
+
modelName: rawModel.attrName ? PropertyBinding.sanitizeNodeName( rawModel.attrName ) : '',
|
|
2889
|
+
morphName: fbxTree.Objects.Deformer[ deformerID ].attrName,
|
|
2890
|
+
|
|
2891
|
+
};
|
|
2892
|
+
|
|
2893
|
+
layerCurveNodes[ i ] = node;
|
|
2894
|
+
|
|
2895
|
+
}
|
|
2896
|
+
|
|
2897
|
+
layerCurveNodes[ i ][ curveNode.attr ] = curveNode;
|
|
2898
|
+
|
|
2899
|
+
}
|
|
2900
|
+
|
|
2901
|
+
}
|
|
2902
|
+
|
|
2903
|
+
} );
|
|
2904
|
+
|
|
2905
|
+
layersMap.set( parseInt( nodeID ), layerCurveNodes );
|
|
2906
|
+
|
|
2907
|
+
}
|
|
2908
|
+
|
|
2909
|
+
}
|
|
2910
|
+
|
|
2911
|
+
return layersMap;
|
|
2912
|
+
|
|
2913
|
+
}
|
|
2914
|
+
|
|
2915
|
+
// parse nodes in FBXTree.Objects.AnimationStack. These are the top level node in the animation
|
|
2916
|
+
// hierarchy. Each Stack node will be used to create an AnimationClip
|
|
2917
|
+
parseAnimStacks( layersMap ) {
|
|
2918
|
+
|
|
2919
|
+
const rawStacks = fbxTree.Objects.AnimationStack;
|
|
2920
|
+
|
|
2921
|
+
// connect the stacks (clips) up to the layers
|
|
2922
|
+
const rawClips = {};
|
|
2923
|
+
|
|
2924
|
+
for ( const nodeID in rawStacks ) {
|
|
2925
|
+
|
|
2926
|
+
const children = connections.get( parseInt( nodeID ) ).children;
|
|
2927
|
+
|
|
2928
|
+
if ( children.length > 1 ) {
|
|
2929
|
+
|
|
2930
|
+
// it seems like stacks will always be associated with a single layer. But just in case there are files
|
|
2931
|
+
// where there are multiple layers per stack, we'll display a warning
|
|
2932
|
+
console.warn( 'THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.' );
|
|
2933
|
+
|
|
2934
|
+
}
|
|
2935
|
+
|
|
2936
|
+
const layer = layersMap.get( children[ 0 ].ID );
|
|
2937
|
+
const rawStack = rawStacks[ nodeID ];
|
|
2938
|
+
|
|
2939
|
+
rawClips[ nodeID ] = {
|
|
2940
|
+
|
|
2941
|
+
name: rawStack.attrName,
|
|
2942
|
+
layer: layer,
|
|
2943
|
+
localStart: rawStack.LocalStart !== undefined ? convertFBXTimeToSeconds( Number( rawStack.LocalStart.value ) ) : 0,
|
|
2944
|
+
localStop: rawStack.LocalStop !== undefined ? convertFBXTimeToSeconds( Number( rawStack.LocalStop.value ) ) : 0,
|
|
2945
|
+
|
|
2946
|
+
};
|
|
2947
|
+
|
|
2948
|
+
}
|
|
2949
|
+
|
|
2950
|
+
return rawClips;
|
|
2951
|
+
|
|
2952
|
+
}
|
|
2953
|
+
|
|
2954
|
+
addClip( rawClip ) {
|
|
2955
|
+
|
|
2956
|
+
let tracks = [];
|
|
2957
|
+
|
|
2958
|
+
const scope = this;
|
|
2959
|
+
rawClip.layer.forEach( function ( rawTracks ) {
|
|
2960
|
+
|
|
2961
|
+
tracks = tracks.concat( scope.generateTracks( rawTracks ) );
|
|
2962
|
+
|
|
2963
|
+
} );
|
|
2964
|
+
|
|
2965
|
+
if ( this.trimAnimationClips === true && rawClip.localStop > rawClip.localStart ) {
|
|
2966
|
+
|
|
2967
|
+
tracks = this.trimTracks( tracks, rawClip.localStart, rawClip.localStop );
|
|
2968
|
+
|
|
2969
|
+
}
|
|
2970
|
+
|
|
2971
|
+
return new AnimationClip( rawClip.name, - 1, tracks );
|
|
2972
|
+
|
|
2973
|
+
}
|
|
2974
|
+
|
|
2975
|
+
// trims the given tracks to the time range [ startTime, endTime ] and shifts
|
|
2976
|
+
// them so they start at time zero. tracks without keyframes in the range are discarded
|
|
2977
|
+
trimTracks( tracks, startTime, endTime ) {
|
|
2978
|
+
|
|
2979
|
+
// track times are stored as float32 so compare against float32 boundaries
|
|
2980
|
+
// to keep keyframes lying exactly on the range limits
|
|
2981
|
+
|
|
2982
|
+
const start = Math.fround( startTime );
|
|
2983
|
+
const end = Math.fround( endTime );
|
|
2984
|
+
|
|
2985
|
+
const trimmedTracks = [];
|
|
2986
|
+
|
|
2987
|
+
for ( let i = 0; i < tracks.length; i ++ ) {
|
|
2988
|
+
|
|
2989
|
+
const track = tracks[ i ];
|
|
2990
|
+
const stride = track.getValueSize();
|
|
2991
|
+
|
|
2992
|
+
const times = [];
|
|
2993
|
+
const values = [];
|
|
2994
|
+
|
|
2995
|
+
for ( let j = 0; j < track.times.length; j ++ ) {
|
|
2996
|
+
|
|
2997
|
+
const time = track.times[ j ];
|
|
2998
|
+
|
|
2999
|
+
if ( time < start || time > end ) continue;
|
|
3000
|
+
|
|
3001
|
+
times.push( time - start );
|
|
3002
|
+
|
|
3003
|
+
for ( let k = 0; k < stride; k ++ ) {
|
|
3004
|
+
|
|
3005
|
+
values.push( track.values[ j * stride + k ] );
|
|
3006
|
+
|
|
3007
|
+
}
|
|
3008
|
+
|
|
3009
|
+
}
|
|
3010
|
+
|
|
3011
|
+
if ( times.length === 0 ) continue;
|
|
3012
|
+
|
|
3013
|
+
track.times = new Float32Array( times );
|
|
3014
|
+
track.values = new Float32Array( values );
|
|
3015
|
+
|
|
3016
|
+
trimmedTracks.push( track );
|
|
3017
|
+
|
|
3018
|
+
}
|
|
3019
|
+
|
|
3020
|
+
return trimmedTracks;
|
|
3021
|
+
|
|
3022
|
+
}
|
|
3023
|
+
|
|
3024
|
+
generateTracks( rawTracks ) {
|
|
3025
|
+
|
|
3026
|
+
const tracks = [];
|
|
3027
|
+
|
|
3028
|
+
let initialPosition = new Vector3();
|
|
3029
|
+
let initialScale = new Vector3();
|
|
3030
|
+
|
|
3031
|
+
if ( rawTracks.transform ) rawTracks.transform.decompose( initialPosition, new Quaternion(), initialScale );
|
|
3032
|
+
|
|
3033
|
+
initialPosition = initialPosition.toArray();
|
|
3034
|
+
initialScale = initialScale.toArray();
|
|
3035
|
+
|
|
3036
|
+
if ( rawTracks.T !== undefined && Object.keys( rawTracks.T.curves ).length > 0 ) {
|
|
3037
|
+
|
|
3038
|
+
const positionTrack = this.generateVectorTrack( rawTracks.modelName, rawTracks.T.curves, initialPosition, 'position' );
|
|
3039
|
+
if ( positionTrack !== undefined ) tracks.push( positionTrack );
|
|
3040
|
+
|
|
3041
|
+
}
|
|
3042
|
+
|
|
3043
|
+
if ( rawTracks.R !== undefined && Object.keys( rawTracks.R.curves ).length > 0 ) {
|
|
3044
|
+
|
|
3045
|
+
const rotationTrack = this.generateRotationTrack( rawTracks.modelName, rawTracks.R.curves, rawTracks.preRotation, rawTracks.postRotation, rawTracks.eulerOrder, rawTracks.initialRotation );
|
|
3046
|
+
if ( rotationTrack !== undefined ) tracks.push( rotationTrack );
|
|
3047
|
+
|
|
3048
|
+
}
|
|
3049
|
+
|
|
3050
|
+
if ( rawTracks.S !== undefined && Object.keys( rawTracks.S.curves ).length > 0 ) {
|
|
3051
|
+
|
|
3052
|
+
const scaleTrack = this.generateVectorTrack( rawTracks.modelName, rawTracks.S.curves, initialScale, 'scale' );
|
|
3053
|
+
if ( scaleTrack !== undefined ) tracks.push( scaleTrack );
|
|
3054
|
+
|
|
3055
|
+
}
|
|
3056
|
+
|
|
3057
|
+
if ( rawTracks.DeformPercent !== undefined ) {
|
|
3058
|
+
|
|
3059
|
+
const morphTrack = this.generateMorphTrack( rawTracks );
|
|
3060
|
+
if ( morphTrack !== undefined ) tracks.push( morphTrack );
|
|
3061
|
+
|
|
3062
|
+
}
|
|
3063
|
+
|
|
3064
|
+
return tracks;
|
|
3065
|
+
|
|
3066
|
+
}
|
|
3067
|
+
|
|
3068
|
+
generateVectorTrack( modelName, curves, initialValue, type ) {
|
|
3069
|
+
|
|
3070
|
+
const times = this.getTimesForAllAxes( curves );
|
|
3071
|
+
const values = this.getKeyframeTrackValues( times, curves, initialValue );
|
|
3072
|
+
|
|
3073
|
+
return new VectorKeyframeTrack( modelName + '.' + type, times, values );
|
|
3074
|
+
|
|
3075
|
+
}
|
|
3076
|
+
|
|
3077
|
+
generateRotationTrack( modelName, curves, preRotation, postRotation, eulerOrder, initialRotation ) {
|
|
3078
|
+
|
|
3079
|
+
let times;
|
|
3080
|
+
let values;
|
|
3081
|
+
|
|
3082
|
+
if ( curves.x !== undefined || curves.y !== undefined || curves.z !== undefined ) {
|
|
3083
|
+
|
|
3084
|
+
// Get merged, sorted, unique times from all available curves
|
|
3085
|
+
const mergedTimes = this.getTimesForAllAxes( curves );
|
|
3086
|
+
|
|
3087
|
+
if ( mergedTimes.length > 0 ) {
|
|
3088
|
+
|
|
3089
|
+
const initialRot = initialRotation || [ 0, 0, 0 ];
|
|
3090
|
+
|
|
3091
|
+
// Synchronize all curves to the merged time array.
|
|
3092
|
+
// Missing axes are filled with constant values from the initial rotation (Lcl Rotation).
|
|
3093
|
+
// Existing curves at different times are linearly interpolated.
|
|
3094
|
+
const syncX = this.synchronizeCurve( curves.x, mergedTimes, initialRot[ 0 ] );
|
|
3095
|
+
const syncY = this.synchronizeCurve( curves.y, mergedTimes, initialRot[ 1 ] );
|
|
3096
|
+
const syncZ = this.synchronizeCurve( curves.z, mergedTimes, initialRot[ 2 ] );
|
|
3097
|
+
|
|
3098
|
+
const result = this.interpolateRotations( syncX, syncY, syncZ, eulerOrder );
|
|
3099
|
+
|
|
3100
|
+
times = result[ 0 ];
|
|
3101
|
+
values = result[ 1 ];
|
|
3102
|
+
|
|
3103
|
+
}
|
|
3104
|
+
|
|
3105
|
+
}
|
|
3106
|
+
|
|
3107
|
+
// For Maya models using "Joint Orient", Euler order only applies to rotation, not pre/post-rotations
|
|
3108
|
+
const defaultEulerOrder = getEulerOrder( 0 );
|
|
3109
|
+
|
|
3110
|
+
if ( preRotation !== undefined ) {
|
|
3111
|
+
|
|
3112
|
+
preRotation = preRotation.map( MathUtils.degToRad );
|
|
3113
|
+
preRotation.push( defaultEulerOrder );
|
|
3114
|
+
|
|
3115
|
+
preRotation = new Euler().fromArray( preRotation );
|
|
3116
|
+
preRotation = new Quaternion().setFromEuler( preRotation );
|
|
3117
|
+
|
|
3118
|
+
}
|
|
3119
|
+
|
|
3120
|
+
if ( postRotation !== undefined ) {
|
|
3121
|
+
|
|
3122
|
+
postRotation = postRotation.map( MathUtils.degToRad );
|
|
3123
|
+
postRotation.push( defaultEulerOrder );
|
|
3124
|
+
|
|
3125
|
+
postRotation = new Euler().fromArray( postRotation );
|
|
3126
|
+
postRotation = new Quaternion().setFromEuler( postRotation ).invert();
|
|
3127
|
+
|
|
3128
|
+
}
|
|
3129
|
+
|
|
3130
|
+
const quaternion = new Quaternion();
|
|
3131
|
+
const euler = new Euler();
|
|
3132
|
+
|
|
3133
|
+
const quaternionValues = [];
|
|
3134
|
+
|
|
3135
|
+
if ( ! values || ! times ) return undefined;
|
|
3136
|
+
|
|
3137
|
+
for ( let i = 0; i < values.length; i += 3 ) {
|
|
3138
|
+
|
|
3139
|
+
euler.set( values[ i ], values[ i + 1 ], values[ i + 2 ], eulerOrder );
|
|
3140
|
+
quaternion.setFromEuler( euler );
|
|
3141
|
+
|
|
3142
|
+
if ( preRotation !== undefined ) quaternion.premultiply( preRotation );
|
|
3143
|
+
if ( postRotation !== undefined ) quaternion.multiply( postRotation );
|
|
3144
|
+
|
|
3145
|
+
// Check unroll
|
|
3146
|
+
if ( i > 2 ) {
|
|
3147
|
+
|
|
3148
|
+
const prevQuat = new Quaternion().fromArray(
|
|
3149
|
+
quaternionValues,
|
|
3150
|
+
( ( i - 3 ) / 3 ) * 4
|
|
3151
|
+
);
|
|
3152
|
+
|
|
3153
|
+
if ( prevQuat.dot( quaternion ) < 0 ) {
|
|
3154
|
+
|
|
3155
|
+
quaternion.set( - quaternion.x, - quaternion.y, - quaternion.z, - quaternion.w );
|
|
3156
|
+
|
|
3157
|
+
}
|
|
3158
|
+
|
|
3159
|
+
}
|
|
3160
|
+
|
|
3161
|
+
quaternion.toArray( quaternionValues, ( i / 3 ) * 4 );
|
|
3162
|
+
|
|
3163
|
+
}
|
|
3164
|
+
|
|
3165
|
+
return new QuaternionKeyframeTrack( modelName + '.quaternion', times, quaternionValues );
|
|
3166
|
+
|
|
3167
|
+
}
|
|
3168
|
+
|
|
3169
|
+
generateMorphTrack( rawTracks ) {
|
|
3170
|
+
|
|
3171
|
+
const curves = rawTracks.DeformPercent.curves.morph;
|
|
3172
|
+
const values = curves.values.map( function ( val ) {
|
|
3173
|
+
|
|
3174
|
+
return val / 100;
|
|
3175
|
+
|
|
3176
|
+
} );
|
|
3177
|
+
|
|
3178
|
+
const morphNum = sceneGraph.getObjectByName( rawTracks.modelName ).morphTargetDictionary[ rawTracks.morphName ];
|
|
3179
|
+
|
|
3180
|
+
return new NumberKeyframeTrack( rawTracks.modelName + '.morphTargetInfluences[' + morphNum + ']', curves.times, values );
|
|
3181
|
+
|
|
3182
|
+
}
|
|
3183
|
+
|
|
3184
|
+
// For all animated objects, times are defined separately for each axis
|
|
3185
|
+
// Here we'll combine the times into one sorted array without duplicates
|
|
3186
|
+
getTimesForAllAxes( curves ) {
|
|
3187
|
+
|
|
3188
|
+
let times = [];
|
|
3189
|
+
|
|
3190
|
+
// first join together the times for each axis, if defined
|
|
3191
|
+
if ( curves.x !== undefined ) times = times.concat( curves.x.times );
|
|
3192
|
+
if ( curves.y !== undefined ) times = times.concat( curves.y.times );
|
|
3193
|
+
if ( curves.z !== undefined ) times = times.concat( curves.z.times );
|
|
3194
|
+
|
|
3195
|
+
// then sort them
|
|
3196
|
+
times = times.sort( function ( a, b ) {
|
|
3197
|
+
|
|
3198
|
+
return a - b;
|
|
3199
|
+
|
|
3200
|
+
} );
|
|
3201
|
+
|
|
3202
|
+
// and remove duplicates
|
|
3203
|
+
if ( times.length > 1 ) {
|
|
3204
|
+
|
|
3205
|
+
let targetIndex = 1;
|
|
3206
|
+
let lastValue = times[ 0 ];
|
|
3207
|
+
for ( let i = 1; i < times.length; i ++ ) {
|
|
3208
|
+
|
|
3209
|
+
const currentValue = times[ i ];
|
|
3210
|
+
if ( currentValue !== lastValue ) {
|
|
3211
|
+
|
|
3212
|
+
times[ targetIndex ] = currentValue;
|
|
3213
|
+
lastValue = currentValue;
|
|
3214
|
+
targetIndex ++;
|
|
3215
|
+
|
|
3216
|
+
}
|
|
3217
|
+
|
|
3218
|
+
}
|
|
3219
|
+
|
|
3220
|
+
times = times.slice( 0, targetIndex );
|
|
3221
|
+
|
|
3222
|
+
}
|
|
3223
|
+
|
|
3224
|
+
return times;
|
|
3225
|
+
|
|
3226
|
+
}
|
|
3227
|
+
|
|
3228
|
+
getKeyframeTrackValues( times, curves, initialValue ) {
|
|
3229
|
+
|
|
3230
|
+
const prevValue = initialValue;
|
|
3231
|
+
|
|
3232
|
+
const values = [];
|
|
3233
|
+
|
|
3234
|
+
let xIndex = - 1;
|
|
3235
|
+
let yIndex = - 1;
|
|
3236
|
+
let zIndex = - 1;
|
|
3237
|
+
|
|
3238
|
+
times.forEach( function ( time ) {
|
|
3239
|
+
|
|
3240
|
+
if ( curves.x ) xIndex = curves.x.times.indexOf( time );
|
|
3241
|
+
if ( curves.y ) yIndex = curves.y.times.indexOf( time );
|
|
3242
|
+
if ( curves.z ) zIndex = curves.z.times.indexOf( time );
|
|
3243
|
+
|
|
3244
|
+
// if there is an x value defined for this frame, use that
|
|
3245
|
+
if ( xIndex !== - 1 ) {
|
|
3246
|
+
|
|
3247
|
+
const xValue = curves.x.values[ xIndex ];
|
|
3248
|
+
values.push( xValue );
|
|
3249
|
+
prevValue[ 0 ] = xValue;
|
|
3250
|
+
|
|
3251
|
+
} else {
|
|
3252
|
+
|
|
3253
|
+
// otherwise use the x value from the previous frame
|
|
3254
|
+
values.push( prevValue[ 0 ] );
|
|
3255
|
+
|
|
3256
|
+
}
|
|
3257
|
+
|
|
3258
|
+
if ( yIndex !== - 1 ) {
|
|
3259
|
+
|
|
3260
|
+
const yValue = curves.y.values[ yIndex ];
|
|
3261
|
+
values.push( yValue );
|
|
3262
|
+
prevValue[ 1 ] = yValue;
|
|
3263
|
+
|
|
3264
|
+
} else {
|
|
3265
|
+
|
|
3266
|
+
values.push( prevValue[ 1 ] );
|
|
3267
|
+
|
|
3268
|
+
}
|
|
3269
|
+
|
|
3270
|
+
if ( zIndex !== - 1 ) {
|
|
3271
|
+
|
|
3272
|
+
const zValue = curves.z.values[ zIndex ];
|
|
3273
|
+
values.push( zValue );
|
|
3274
|
+
prevValue[ 2 ] = zValue;
|
|
3275
|
+
|
|
3276
|
+
} else {
|
|
3277
|
+
|
|
3278
|
+
values.push( prevValue[ 2 ] );
|
|
3279
|
+
|
|
3280
|
+
}
|
|
3281
|
+
|
|
3282
|
+
} );
|
|
3283
|
+
|
|
3284
|
+
return values;
|
|
3285
|
+
|
|
3286
|
+
}
|
|
3287
|
+
|
|
3288
|
+
// Synchronize a curve to a target time array using linear interpolation.
|
|
3289
|
+
// If the curve is undefined (axis not animated), returns constant values from initialValue.
|
|
3290
|
+
synchronizeCurve( curve, targetTimes, initialValue ) {
|
|
3291
|
+
|
|
3292
|
+
if ( curve === undefined ) {
|
|
3293
|
+
|
|
3294
|
+
return { times: targetTimes, values: targetTimes.map( () => initialValue ) };
|
|
3295
|
+
|
|
3296
|
+
}
|
|
3297
|
+
|
|
3298
|
+
// If the curve already has the same number of keyframes as the target, assume times match
|
|
3299
|
+
if ( curve.times.length === targetTimes.length ) return curve;
|
|
3300
|
+
|
|
3301
|
+
// Linearly interpolate curve values at each target time
|
|
3302
|
+
const values = [];
|
|
3303
|
+
|
|
3304
|
+
for ( let i = 0; i < targetTimes.length; i ++ ) {
|
|
3305
|
+
|
|
3306
|
+
values.push( this.sampleCurveValue( curve, targetTimes[ i ], initialValue ) );
|
|
3307
|
+
|
|
3308
|
+
}
|
|
3309
|
+
|
|
3310
|
+
return { times: targetTimes, values: values };
|
|
3311
|
+
|
|
3312
|
+
}
|
|
3313
|
+
|
|
3314
|
+
// Sample a single value from a curve at a given time using linear interpolation
|
|
3315
|
+
sampleCurveValue( curve, time, initialValue ) {
|
|
3316
|
+
|
|
3317
|
+
const times = curve.times;
|
|
3318
|
+
const values = curve.values;
|
|
3319
|
+
|
|
3320
|
+
// Before first keyframe
|
|
3321
|
+
if ( time <= times[ 0 ] ) return values[ 0 ];
|
|
3322
|
+
|
|
3323
|
+
// After last keyframe
|
|
3324
|
+
if ( time >= times[ times.length - 1 ] ) return values[ values.length - 1 ];
|
|
3325
|
+
|
|
3326
|
+
// Find surrounding keyframes and linearly interpolate
|
|
3327
|
+
for ( let i = 0; i < times.length - 1; i ++ ) {
|
|
3328
|
+
|
|
3329
|
+
if ( time >= times[ i ] && time <= times[ i + 1 ] ) {
|
|
3330
|
+
|
|
3331
|
+
if ( times[ i ] === time ) return values[ i ];
|
|
3332
|
+
|
|
3333
|
+
const alpha = ( time - times[ i ] ) / ( times[ i + 1 ] - times[ i ] );
|
|
3334
|
+
return values[ i ] * ( 1 - alpha ) + values[ i + 1 ] * alpha;
|
|
3335
|
+
|
|
3336
|
+
}
|
|
3337
|
+
|
|
3338
|
+
}
|
|
3339
|
+
|
|
3340
|
+
return initialValue;
|
|
3341
|
+
|
|
3342
|
+
}
|
|
3343
|
+
|
|
3344
|
+
// Rotations are defined as Euler angles which can have values of any size
|
|
3345
|
+
// These will be converted to quaternions which don't support values greater than
|
|
3346
|
+
// PI, so we'll interpolate large rotations
|
|
3347
|
+
interpolateRotations( curvex, curvey, curvez, eulerOrder ) {
|
|
3348
|
+
|
|
3349
|
+
const times = [];
|
|
3350
|
+
const values = [];
|
|
3351
|
+
|
|
3352
|
+
// Add first frame
|
|
3353
|
+
times.push( curvex.times[ 0 ] );
|
|
3354
|
+
values.push( MathUtils.degToRad( curvex.values[ 0 ] ) );
|
|
3355
|
+
values.push( MathUtils.degToRad( curvey.values[ 0 ] ) );
|
|
3356
|
+
values.push( MathUtils.degToRad( curvez.values[ 0 ] ) );
|
|
3357
|
+
|
|
3358
|
+
for ( let i = 1; i < curvex.values.length; i ++ ) {
|
|
3359
|
+
|
|
3360
|
+
const initialValue = [
|
|
3361
|
+
curvex.values[ i - 1 ],
|
|
3362
|
+
curvey.values[ i - 1 ],
|
|
3363
|
+
curvez.values[ i - 1 ],
|
|
3364
|
+
];
|
|
3365
|
+
|
|
3366
|
+
if ( isNaN( initialValue[ 0 ] ) || isNaN( initialValue[ 1 ] ) || isNaN( initialValue[ 2 ] ) ) {
|
|
3367
|
+
|
|
3368
|
+
continue;
|
|
3369
|
+
|
|
3370
|
+
}
|
|
3371
|
+
|
|
3372
|
+
const initialValueRad = initialValue.map( MathUtils.degToRad );
|
|
3373
|
+
|
|
3374
|
+
const currentValue = [
|
|
3375
|
+
curvex.values[ i ],
|
|
3376
|
+
curvey.values[ i ],
|
|
3377
|
+
curvez.values[ i ],
|
|
3378
|
+
];
|
|
3379
|
+
|
|
3380
|
+
if ( isNaN( currentValue[ 0 ] ) || isNaN( currentValue[ 1 ] ) || isNaN( currentValue[ 2 ] ) ) {
|
|
3381
|
+
|
|
3382
|
+
continue;
|
|
3383
|
+
|
|
3384
|
+
}
|
|
3385
|
+
|
|
3386
|
+
const currentValueRad = currentValue.map( MathUtils.degToRad );
|
|
3387
|
+
|
|
3388
|
+
const valuesSpan = [
|
|
3389
|
+
currentValue[ 0 ] - initialValue[ 0 ],
|
|
3390
|
+
currentValue[ 1 ] - initialValue[ 1 ],
|
|
3391
|
+
currentValue[ 2 ] - initialValue[ 2 ],
|
|
3392
|
+
];
|
|
3393
|
+
|
|
3394
|
+
const absoluteSpan = [
|
|
3395
|
+
Math.abs( valuesSpan[ 0 ] ),
|
|
3396
|
+
Math.abs( valuesSpan[ 1 ] ),
|
|
3397
|
+
Math.abs( valuesSpan[ 2 ] ),
|
|
3398
|
+
];
|
|
3399
|
+
|
|
3400
|
+
if ( absoluteSpan[ 0 ] >= 180 || absoluteSpan[ 1 ] >= 180 || absoluteSpan[ 2 ] >= 180 ) {
|
|
3401
|
+
|
|
3402
|
+
const maxAbsSpan = Math.max( ...absoluteSpan );
|
|
3403
|
+
|
|
3404
|
+
const numSubIntervals = maxAbsSpan / 180;
|
|
3405
|
+
|
|
3406
|
+
const E1 = new Euler( ...initialValueRad, eulerOrder );
|
|
3407
|
+
const E2 = new Euler( ...currentValueRad, eulerOrder );
|
|
3408
|
+
|
|
3409
|
+
const Q1 = new Quaternion().setFromEuler( E1 );
|
|
3410
|
+
const Q2 = new Quaternion().setFromEuler( E2 );
|
|
3411
|
+
|
|
3412
|
+
// Check unroll
|
|
3413
|
+
if ( Q1.dot( Q2 ) < 0 ) {
|
|
3414
|
+
|
|
3415
|
+
Q2.set( - Q2.x, - Q2.y, - Q2.z, - Q2.w );
|
|
3416
|
+
|
|
3417
|
+
}
|
|
3418
|
+
|
|
3419
|
+
// Interpolate
|
|
3420
|
+
const initialTime = curvex.times[ i - 1 ];
|
|
3421
|
+
const timeSpan = curvex.times[ i ] - initialTime;
|
|
3422
|
+
|
|
3423
|
+
const Q = new Quaternion();
|
|
3424
|
+
const E = new Euler();
|
|
3425
|
+
for ( let t = 0; t < 1; t += 1 / numSubIntervals ) {
|
|
3426
|
+
|
|
3427
|
+
Q.copy( Q1.clone().slerp( Q2.clone(), t ) );
|
|
3428
|
+
|
|
3429
|
+
times.push( initialTime + t * timeSpan );
|
|
3430
|
+
E.setFromQuaternion( Q, eulerOrder );
|
|
3431
|
+
|
|
3432
|
+
values.push( E.x );
|
|
3433
|
+
values.push( E.y );
|
|
3434
|
+
values.push( E.z );
|
|
3435
|
+
|
|
3436
|
+
}
|
|
3437
|
+
|
|
3438
|
+
} else {
|
|
3439
|
+
|
|
3440
|
+
times.push( curvex.times[ i ] );
|
|
3441
|
+
values.push( MathUtils.degToRad( curvex.values[ i ] ) );
|
|
3442
|
+
values.push( MathUtils.degToRad( curvey.values[ i ] ) );
|
|
3443
|
+
values.push( MathUtils.degToRad( curvez.values[ i ] ) );
|
|
3444
|
+
|
|
3445
|
+
}
|
|
3446
|
+
|
|
3447
|
+
}
|
|
3448
|
+
|
|
3449
|
+
return [ times, values ];
|
|
3450
|
+
|
|
3451
|
+
}
|
|
3452
|
+
|
|
3453
|
+
}
|
|
3454
|
+
|
|
3455
|
+
// parse an FBX file in ASCII format
|
|
3456
|
+
class TextParser {
|
|
3457
|
+
|
|
3458
|
+
getPrevNode() {
|
|
3459
|
+
|
|
3460
|
+
return this.nodeStack[ this.currentIndent - 2 ];
|
|
3461
|
+
|
|
3462
|
+
}
|
|
3463
|
+
|
|
3464
|
+
getCurrentNode() {
|
|
3465
|
+
|
|
3466
|
+
return this.nodeStack[ this.currentIndent - 1 ];
|
|
3467
|
+
|
|
3468
|
+
}
|
|
3469
|
+
|
|
3470
|
+
getCurrentProp() {
|
|
3471
|
+
|
|
3472
|
+
return this.currentProp;
|
|
3473
|
+
|
|
3474
|
+
}
|
|
3475
|
+
|
|
3476
|
+
pushStack( node ) {
|
|
3477
|
+
|
|
3478
|
+
this.nodeStack.push( node );
|
|
3479
|
+
this.currentIndent += 1;
|
|
3480
|
+
|
|
3481
|
+
}
|
|
3482
|
+
|
|
3483
|
+
popStack() {
|
|
3484
|
+
|
|
3485
|
+
this.nodeStack.pop();
|
|
3486
|
+
this.currentIndent -= 1;
|
|
3487
|
+
|
|
3488
|
+
}
|
|
3489
|
+
|
|
3490
|
+
setCurrentProp( val, name ) {
|
|
3491
|
+
|
|
3492
|
+
this.currentProp = val;
|
|
3493
|
+
this.currentPropName = name;
|
|
3494
|
+
|
|
3495
|
+
}
|
|
3496
|
+
|
|
3497
|
+
parse( text ) {
|
|
3498
|
+
|
|
3499
|
+
this.currentIndent = 0;
|
|
3500
|
+
|
|
3501
|
+
this.allNodes = new FBXTree();
|
|
3502
|
+
this.nodeStack = [];
|
|
3503
|
+
this.currentProp = [];
|
|
3504
|
+
this.currentPropName = '';
|
|
3505
|
+
|
|
3506
|
+
const scope = this;
|
|
3507
|
+
|
|
3508
|
+
const split = text.split( /[\r\n]+/ );
|
|
3509
|
+
|
|
3510
|
+
split.forEach( function ( line, i ) {
|
|
3511
|
+
|
|
3512
|
+
const matchComment = line.match( /^[\s\t]*;/ );
|
|
3513
|
+
const matchEmpty = line.match( /^[\s\t]*$/ );
|
|
3514
|
+
|
|
3515
|
+
if ( matchComment || matchEmpty ) return;
|
|
3516
|
+
|
|
3517
|
+
const matchBeginning = line.match( '^\\t{' + scope.currentIndent + '}(\\w+):(.*){', '' );
|
|
3518
|
+
const matchProperty = line.match( '^\\t{' + ( scope.currentIndent ) + '}(\\w+):[\\s\\t\\r\\n](.*)' );
|
|
3519
|
+
const matchEnd = line.match( '^\\t{' + ( scope.currentIndent - 1 ) + '}}' );
|
|
3520
|
+
|
|
3521
|
+
if ( matchBeginning ) {
|
|
3522
|
+
|
|
3523
|
+
scope.parseNodeBegin( line, matchBeginning );
|
|
3524
|
+
|
|
3525
|
+
} else if ( matchProperty ) {
|
|
3526
|
+
|
|
3527
|
+
scope.parseNodeProperty( line, matchProperty, split[ ++ i ] );
|
|
3528
|
+
|
|
3529
|
+
} else if ( matchEnd ) {
|
|
3530
|
+
|
|
3531
|
+
scope.popStack();
|
|
3532
|
+
|
|
3533
|
+
} else if ( line.match( /^[^\s\t}]/ ) ) {
|
|
3534
|
+
|
|
3535
|
+
// large arrays are split over multiple lines terminated with a ',' character
|
|
3536
|
+
// if this is encountered the line needs to be joined to the previous line
|
|
3537
|
+
scope.parseNodePropertyContinued( line );
|
|
3538
|
+
|
|
3539
|
+
}
|
|
3540
|
+
|
|
3541
|
+
} );
|
|
3542
|
+
|
|
3543
|
+
return this.allNodes;
|
|
3544
|
+
|
|
3545
|
+
}
|
|
3546
|
+
|
|
3547
|
+
parseNodeBegin( line, property ) {
|
|
3548
|
+
|
|
3549
|
+
const nodeName = property[ 1 ].trim().replace( /^"/, '' ).replace( /"$/, '' );
|
|
3550
|
+
|
|
3551
|
+
const nodeAttrs = property[ 2 ].split( ',' ).map( function ( attr ) {
|
|
3552
|
+
|
|
3553
|
+
return attr.trim().replace( /^"/, '' ).replace( /"$/, '' );
|
|
3554
|
+
|
|
3555
|
+
} );
|
|
3556
|
+
|
|
3557
|
+
const node = { name: nodeName };
|
|
3558
|
+
const attrs = this.parseNodeAttr( nodeAttrs );
|
|
3559
|
+
|
|
3560
|
+
const currentNode = this.getCurrentNode();
|
|
3561
|
+
|
|
3562
|
+
// a top node
|
|
3563
|
+
if ( this.currentIndent === 0 ) {
|
|
3564
|
+
|
|
3565
|
+
this.allNodes.add( nodeName, node );
|
|
3566
|
+
|
|
3567
|
+
} else { // a subnode
|
|
3568
|
+
|
|
3569
|
+
// if the subnode already exists, append it
|
|
3570
|
+
if ( nodeName in currentNode ) {
|
|
3571
|
+
|
|
3572
|
+
// special case Pose needs PoseNodes as an array
|
|
3573
|
+
if ( nodeName === 'PoseNode' ) {
|
|
3574
|
+
|
|
3575
|
+
currentNode.PoseNode.push( node );
|
|
3576
|
+
|
|
3577
|
+
} else if ( currentNode[ nodeName ].id !== undefined ) {
|
|
3578
|
+
|
|
3579
|
+
currentNode[ nodeName ] = {};
|
|
3580
|
+
currentNode[ nodeName ][ currentNode[ nodeName ].id ] = currentNode[ nodeName ];
|
|
3581
|
+
|
|
3582
|
+
}
|
|
3583
|
+
|
|
3584
|
+
if ( attrs.id !== '' ) currentNode[ nodeName ][ attrs.id ] = node;
|
|
3585
|
+
|
|
3586
|
+
} else if ( typeof attrs.id === 'number' ) {
|
|
3587
|
+
|
|
3588
|
+
currentNode[ nodeName ] = {};
|
|
3589
|
+
currentNode[ nodeName ][ attrs.id ] = node;
|
|
3590
|
+
|
|
3591
|
+
} else if ( nodeName !== 'Properties70' ) {
|
|
3592
|
+
|
|
3593
|
+
if ( nodeName === 'PoseNode' ) currentNode[ nodeName ] = [ node ];
|
|
3594
|
+
else currentNode[ nodeName ] = node;
|
|
3595
|
+
|
|
3596
|
+
}
|
|
3597
|
+
|
|
3598
|
+
}
|
|
3599
|
+
|
|
3600
|
+
if ( typeof attrs.id === 'number' ) node.id = attrs.id;
|
|
3601
|
+
if ( attrs.name !== '' ) node.attrName = attrs.name;
|
|
3602
|
+
if ( attrs.type !== '' ) node.attrType = attrs.type;
|
|
3603
|
+
|
|
3604
|
+
this.pushStack( node );
|
|
3605
|
+
|
|
3606
|
+
}
|
|
3607
|
+
|
|
3608
|
+
parseNodeAttr( attrs ) {
|
|
3609
|
+
|
|
3610
|
+
let id = attrs[ 0 ];
|
|
3611
|
+
|
|
3612
|
+
if ( attrs[ 0 ] !== '' ) {
|
|
3613
|
+
|
|
3614
|
+
id = parseInt( attrs[ 0 ] );
|
|
3615
|
+
|
|
3616
|
+
if ( isNaN( id ) ) {
|
|
3617
|
+
|
|
3618
|
+
id = attrs[ 0 ];
|
|
3619
|
+
|
|
3620
|
+
}
|
|
3621
|
+
|
|
3622
|
+
}
|
|
3623
|
+
|
|
3624
|
+
let name = '', type = '';
|
|
3625
|
+
|
|
3626
|
+
if ( attrs.length > 1 ) {
|
|
3627
|
+
|
|
3628
|
+
name = attrs[ 1 ].replace( /^(\w+)::/, '' );
|
|
3629
|
+
type = attrs[ 2 ];
|
|
3630
|
+
|
|
3631
|
+
}
|
|
3632
|
+
|
|
3633
|
+
return { id: id, name: name, type: type };
|
|
3634
|
+
|
|
3635
|
+
}
|
|
3636
|
+
|
|
3637
|
+
parseNodeProperty( line, property, contentLine ) {
|
|
3638
|
+
|
|
3639
|
+
let propName = property[ 1 ].replace( /^"/, '' ).replace( /"$/, '' ).trim();
|
|
3640
|
+
let propValue = property[ 2 ].replace( /^"/, '' ).replace( /"$/, '' ).trim();
|
|
3641
|
+
|
|
3642
|
+
// for special case: base64 image data follows "Content: ," line
|
|
3643
|
+
// Content: ,
|
|
3644
|
+
// "/9j/4RDaRXhpZgAATU0A..."
|
|
3645
|
+
if ( propName === 'Content' && propValue === ',' ) {
|
|
3646
|
+
|
|
3647
|
+
propValue = contentLine.replace( /"/g, '' ).replace( /,$/, '' ).trim();
|
|
3648
|
+
|
|
3649
|
+
}
|
|
3650
|
+
|
|
3651
|
+
const currentNode = this.getCurrentNode();
|
|
3652
|
+
const parentName = currentNode.name;
|
|
3653
|
+
|
|
3654
|
+
if ( parentName === 'Properties70' ) {
|
|
3655
|
+
|
|
3656
|
+
this.parseNodeSpecialProperty( line, propName, propValue );
|
|
3657
|
+
return;
|
|
3658
|
+
|
|
3659
|
+
}
|
|
3660
|
+
|
|
3661
|
+
// Connections
|
|
3662
|
+
if ( propName === 'C' ) {
|
|
3663
|
+
|
|
3664
|
+
const connProps = propValue.split( ',' ).slice( 1 );
|
|
3665
|
+
const from = parseInt( connProps[ 0 ] );
|
|
3666
|
+
const to = parseInt( connProps[ 1 ] );
|
|
3667
|
+
|
|
3668
|
+
let rest = propValue.split( ',' ).slice( 3 );
|
|
3669
|
+
|
|
3670
|
+
rest = rest.map( function ( elem ) {
|
|
3671
|
+
|
|
3672
|
+
return elem.trim().replace( /^"/, '' );
|
|
3673
|
+
|
|
3674
|
+
} );
|
|
3675
|
+
|
|
3676
|
+
propName = 'connections';
|
|
3677
|
+
propValue = [ from, to ];
|
|
3678
|
+
append( propValue, rest );
|
|
3679
|
+
|
|
3680
|
+
if ( currentNode[ propName ] === undefined ) {
|
|
3681
|
+
|
|
3682
|
+
currentNode[ propName ] = [];
|
|
3683
|
+
|
|
3684
|
+
}
|
|
3685
|
+
|
|
3686
|
+
}
|
|
3687
|
+
|
|
3688
|
+
// Node
|
|
3689
|
+
if ( propName === 'Node' ) currentNode.id = propValue;
|
|
3690
|
+
|
|
3691
|
+
// connections
|
|
3692
|
+
if ( propName in currentNode && Array.isArray( currentNode[ propName ] ) ) {
|
|
3693
|
+
|
|
3694
|
+
currentNode[ propName ].push( propValue );
|
|
3695
|
+
|
|
3696
|
+
} else {
|
|
3697
|
+
|
|
3698
|
+
if ( propName !== 'a' ) currentNode[ propName ] = propValue;
|
|
3699
|
+
else currentNode.a = propValue;
|
|
3700
|
+
|
|
3701
|
+
}
|
|
3702
|
+
|
|
3703
|
+
this.setCurrentProp( currentNode, propName );
|
|
3704
|
+
|
|
3705
|
+
// convert string to array, unless it ends in ',' in which case more will be added to it
|
|
3706
|
+
if ( propName === 'a' && propValue.slice( - 1 ) !== ',' ) {
|
|
3707
|
+
|
|
3708
|
+
currentNode.a = parseNumberArray( propValue );
|
|
3709
|
+
|
|
3710
|
+
}
|
|
3711
|
+
|
|
3712
|
+
}
|
|
3713
|
+
|
|
3714
|
+
parseNodePropertyContinued( line ) {
|
|
3715
|
+
|
|
3716
|
+
const currentNode = this.getCurrentNode();
|
|
3717
|
+
|
|
3718
|
+
currentNode.a += line;
|
|
3719
|
+
|
|
3720
|
+
// if the line doesn't end in ',' we have reached the end of the property value
|
|
3721
|
+
// so convert the string to an array
|
|
3722
|
+
if ( line.slice( - 1 ) !== ',' ) {
|
|
3723
|
+
|
|
3724
|
+
currentNode.a = parseNumberArray( currentNode.a );
|
|
3725
|
+
|
|
3726
|
+
}
|
|
3727
|
+
|
|
3728
|
+
}
|
|
3729
|
+
|
|
3730
|
+
// parse "Property70"
|
|
3731
|
+
parseNodeSpecialProperty( line, propName, propValue ) {
|
|
3732
|
+
|
|
3733
|
+
// split this
|
|
3734
|
+
// P: "Lcl Scaling", "Lcl Scaling", "", "A",1,1,1
|
|
3735
|
+
// into array like below
|
|
3736
|
+
// ["Lcl Scaling", "Lcl Scaling", "", "A", "1,1,1" ]
|
|
3737
|
+
const props = propValue.split( '",' ).map( function ( prop ) {
|
|
3738
|
+
|
|
3739
|
+
return prop.trim().replace( /^\"/, '' ).replace( /\s/, '_' );
|
|
3740
|
+
|
|
3741
|
+
} );
|
|
3742
|
+
|
|
3743
|
+
const innerPropName = props[ 0 ];
|
|
3744
|
+
const innerPropType1 = props[ 1 ];
|
|
3745
|
+
const innerPropType2 = props[ 2 ];
|
|
3746
|
+
const innerPropFlag = props[ 3 ];
|
|
3747
|
+
let innerPropValue = props[ 4 ];
|
|
3748
|
+
|
|
3749
|
+
// cast values where needed, otherwise leave as strings
|
|
3750
|
+
switch ( innerPropType1 ) {
|
|
3751
|
+
|
|
3752
|
+
case 'int':
|
|
3753
|
+
case 'enum':
|
|
3754
|
+
case 'bool':
|
|
3755
|
+
case 'ULongLong':
|
|
3756
|
+
case 'double':
|
|
3757
|
+
case 'Number':
|
|
3758
|
+
case 'FieldOfView':
|
|
3759
|
+
innerPropValue = parseFloat( innerPropValue );
|
|
3760
|
+
break;
|
|
3761
|
+
|
|
3762
|
+
case 'Color':
|
|
3763
|
+
case 'ColorRGB':
|
|
3764
|
+
case 'Vector3D':
|
|
3765
|
+
case 'Lcl_Translation':
|
|
3766
|
+
case 'Lcl_Rotation':
|
|
3767
|
+
case 'Lcl_Scaling':
|
|
3768
|
+
innerPropValue = parseNumberArray( innerPropValue );
|
|
3769
|
+
break;
|
|
3770
|
+
|
|
3771
|
+
}
|
|
3772
|
+
|
|
3773
|
+
// CAUTION: these props must append to parent's parent
|
|
3774
|
+
this.getPrevNode()[ innerPropName ] = {
|
|
3775
|
+
|
|
3776
|
+
'type': innerPropType1,
|
|
3777
|
+
'type2': innerPropType2,
|
|
3778
|
+
'flag': innerPropFlag,
|
|
3779
|
+
'value': innerPropValue
|
|
3780
|
+
|
|
3781
|
+
};
|
|
3782
|
+
|
|
3783
|
+
this.setCurrentProp( this.getPrevNode(), innerPropName );
|
|
3784
|
+
|
|
3785
|
+
}
|
|
3786
|
+
|
|
3787
|
+
}
|
|
3788
|
+
|
|
3789
|
+
// Parse an FBX file in Binary format
|
|
3790
|
+
class BinaryParser {
|
|
3791
|
+
|
|
3792
|
+
parse( buffer ) {
|
|
3793
|
+
|
|
3794
|
+
const reader = new BinaryReader( buffer );
|
|
3795
|
+
reader.skip( 23 ); // skip magic 23 bytes
|
|
3796
|
+
|
|
3797
|
+
const version = reader.getUint32();
|
|
3798
|
+
|
|
3799
|
+
if ( version < 6400 ) {
|
|
3800
|
+
|
|
3801
|
+
throw new Error( 'THREE.FBXLoader: FBX version not supported, FileVersion: ' + version );
|
|
3802
|
+
|
|
3803
|
+
}
|
|
3804
|
+
|
|
3805
|
+
const allNodes = new FBXTree();
|
|
3806
|
+
|
|
3807
|
+
while ( ! this.endOfContent( reader ) ) {
|
|
3808
|
+
|
|
3809
|
+
const node = this.parseNode( reader, version );
|
|
3810
|
+
if ( node !== null ) allNodes.add( node.name, node );
|
|
3811
|
+
|
|
3812
|
+
}
|
|
3813
|
+
|
|
3814
|
+
return allNodes;
|
|
3815
|
+
|
|
3816
|
+
}
|
|
3817
|
+
|
|
3818
|
+
// Check if reader has reached the end of content.
|
|
3819
|
+
endOfContent( reader ) {
|
|
3820
|
+
|
|
3821
|
+
// footer size: 160bytes + 16-byte alignment padding
|
|
3822
|
+
// - 16bytes: magic
|
|
3823
|
+
// - padding til 16-byte alignment (at least 1byte?)
|
|
3824
|
+
// (seems like some exporters embed fixed 15 or 16bytes?)
|
|
3825
|
+
// - 4bytes: magic
|
|
3826
|
+
// - 4bytes: version
|
|
3827
|
+
// - 120bytes: zero
|
|
3828
|
+
// - 16bytes: magic
|
|
3829
|
+
if ( reader.size() % 16 === 0 ) {
|
|
3830
|
+
|
|
3831
|
+
return ( ( reader.getOffset() + 160 + 16 ) & ~ 0xf ) >= reader.size();
|
|
3832
|
+
|
|
3833
|
+
} else {
|
|
3834
|
+
|
|
3835
|
+
return reader.getOffset() + 160 + 16 >= reader.size();
|
|
3836
|
+
|
|
3837
|
+
}
|
|
3838
|
+
|
|
3839
|
+
}
|
|
3840
|
+
|
|
3841
|
+
// recursively parse nodes until the end of the file is reached
|
|
3842
|
+
parseNode( reader, version ) {
|
|
3843
|
+
|
|
3844
|
+
const node = {};
|
|
3845
|
+
|
|
3846
|
+
// The first three data sizes depends on version.
|
|
3847
|
+
const endOffset = ( version >= 7500 ) ? reader.getUint64() : reader.getUint32();
|
|
3848
|
+
const numProperties = ( version >= 7500 ) ? reader.getUint64() : reader.getUint32();
|
|
3849
|
+
|
|
3850
|
+
( version >= 7500 ) ? reader.getUint64() : reader.getUint32(); // the returned propertyListLen is not used
|
|
3851
|
+
|
|
3852
|
+
const nameLen = reader.getUint8();
|
|
3853
|
+
const name = reader.getString( nameLen );
|
|
3854
|
+
|
|
3855
|
+
// Regards this node as NULL-record if endOffset is zero
|
|
3856
|
+
if ( endOffset === 0 ) return null;
|
|
3857
|
+
|
|
3858
|
+
const propertyList = [];
|
|
3859
|
+
|
|
3860
|
+
for ( let i = 0; i < numProperties; i ++ ) {
|
|
3861
|
+
|
|
3862
|
+
propertyList.push( this.parseProperty( reader ) );
|
|
3863
|
+
|
|
3864
|
+
}
|
|
3865
|
+
|
|
3866
|
+
// Regards the first three elements in propertyList as id, attrName, and attrType
|
|
3867
|
+
const id = propertyList.length > 0 ? propertyList[ 0 ] : '';
|
|
3868
|
+
const attrName = propertyList.length > 1 ? propertyList[ 1 ] : '';
|
|
3869
|
+
const attrType = propertyList.length > 2 ? propertyList[ 2 ] : '';
|
|
3870
|
+
|
|
3871
|
+
// check if this node represents just a single property
|
|
3872
|
+
// like (name, 0) set or (name2, [0, 1, 2]) set of {name: 0, name2: [0, 1, 2]}
|
|
3873
|
+
node.singleProperty = ( numProperties === 1 && reader.getOffset() === endOffset ) ? true : false;
|
|
3874
|
+
|
|
3875
|
+
while ( endOffset > reader.getOffset() ) {
|
|
3876
|
+
|
|
3877
|
+
const subNode = this.parseNode( reader, version );
|
|
3878
|
+
|
|
3879
|
+
if ( subNode !== null ) this.parseSubNode( name, node, subNode );
|
|
3880
|
+
|
|
3881
|
+
}
|
|
3882
|
+
|
|
3883
|
+
node.propertyList = propertyList; // raw property list used by parent
|
|
3884
|
+
|
|
3885
|
+
if ( typeof id === 'number' ) node.id = id;
|
|
3886
|
+
if ( attrName !== '' ) node.attrName = attrName;
|
|
3887
|
+
if ( attrType !== '' ) node.attrType = attrType;
|
|
3888
|
+
if ( name !== '' ) node.name = name;
|
|
3889
|
+
|
|
3890
|
+
return node;
|
|
3891
|
+
|
|
3892
|
+
}
|
|
3893
|
+
|
|
3894
|
+
parseSubNode( name, node, subNode ) {
|
|
3895
|
+
|
|
3896
|
+
// special case: child node is single property
|
|
3897
|
+
if ( subNode.singleProperty === true ) {
|
|
3898
|
+
|
|
3899
|
+
const value = subNode.propertyList[ 0 ];
|
|
3900
|
+
|
|
3901
|
+
if ( Array.isArray( value ) ) {
|
|
3902
|
+
|
|
3903
|
+
node[ subNode.name ] = subNode;
|
|
3904
|
+
|
|
3905
|
+
subNode.a = value;
|
|
3906
|
+
|
|
3907
|
+
} else {
|
|
3908
|
+
|
|
3909
|
+
node[ subNode.name ] = value;
|
|
3910
|
+
|
|
3911
|
+
}
|
|
3912
|
+
|
|
3913
|
+
} else if ( name === 'Connections' && subNode.name === 'C' ) {
|
|
3914
|
+
|
|
3915
|
+
const array = [];
|
|
3916
|
+
|
|
3917
|
+
subNode.propertyList.forEach( function ( property, i ) {
|
|
3918
|
+
|
|
3919
|
+
// first Connection is FBX type (OO, OP, etc.). We'll discard these
|
|
3920
|
+
if ( i !== 0 ) array.push( property );
|
|
3921
|
+
|
|
3922
|
+
} );
|
|
3923
|
+
|
|
3924
|
+
if ( node.connections === undefined ) {
|
|
3925
|
+
|
|
3926
|
+
node.connections = [];
|
|
3927
|
+
|
|
3928
|
+
}
|
|
3929
|
+
|
|
3930
|
+
node.connections.push( array );
|
|
3931
|
+
|
|
3932
|
+
} else if ( subNode.name === 'Properties70' ) {
|
|
3933
|
+
|
|
3934
|
+
const keys = Object.keys( subNode );
|
|
3935
|
+
|
|
3936
|
+
keys.forEach( function ( key ) {
|
|
3937
|
+
|
|
3938
|
+
node[ key ] = subNode[ key ];
|
|
3939
|
+
|
|
3940
|
+
} );
|
|
3941
|
+
|
|
3942
|
+
} else if ( name === 'Properties70' && subNode.name === 'P' ) {
|
|
3943
|
+
|
|
3944
|
+
let innerPropName = subNode.propertyList[ 0 ];
|
|
3945
|
+
let innerPropType1 = subNode.propertyList[ 1 ];
|
|
3946
|
+
const innerPropType2 = subNode.propertyList[ 2 ];
|
|
3947
|
+
const innerPropFlag = subNode.propertyList[ 3 ];
|
|
3948
|
+
let innerPropValue;
|
|
3949
|
+
|
|
3950
|
+
if ( innerPropName.indexOf( 'Lcl ' ) === 0 ) innerPropName = innerPropName.replace( 'Lcl ', 'Lcl_' );
|
|
3951
|
+
if ( innerPropType1.indexOf( 'Lcl ' ) === 0 ) innerPropType1 = innerPropType1.replace( 'Lcl ', 'Lcl_' );
|
|
3952
|
+
|
|
3953
|
+
if ( innerPropType1 === 'Color' || innerPropType1 === 'ColorRGB' || innerPropType1 === 'Vector' || innerPropType1 === 'Vector3D' || innerPropType1.indexOf( 'Lcl_' ) === 0 ) {
|
|
3954
|
+
|
|
3955
|
+
innerPropValue = [
|
|
3956
|
+
subNode.propertyList[ 4 ],
|
|
3957
|
+
subNode.propertyList[ 5 ],
|
|
3958
|
+
subNode.propertyList[ 6 ]
|
|
3959
|
+
];
|
|
3960
|
+
|
|
3961
|
+
} else {
|
|
3962
|
+
|
|
3963
|
+
innerPropValue = subNode.propertyList[ 4 ];
|
|
3964
|
+
|
|
3965
|
+
}
|
|
3966
|
+
|
|
3967
|
+
// this will be copied to parent, see above
|
|
3968
|
+
node[ innerPropName ] = {
|
|
3969
|
+
|
|
3970
|
+
'type': innerPropType1,
|
|
3971
|
+
'type2': innerPropType2,
|
|
3972
|
+
'flag': innerPropFlag,
|
|
3973
|
+
'value': innerPropValue
|
|
3974
|
+
|
|
3975
|
+
};
|
|
3976
|
+
|
|
3977
|
+
} else if ( node[ subNode.name ] === undefined ) {
|
|
3978
|
+
|
|
3979
|
+
if ( typeof subNode.id === 'number' ) {
|
|
3980
|
+
|
|
3981
|
+
node[ subNode.name ] = {};
|
|
3982
|
+
node[ subNode.name ][ subNode.id ] = subNode;
|
|
3983
|
+
|
|
3984
|
+
} else {
|
|
3985
|
+
|
|
3986
|
+
node[ subNode.name ] = subNode;
|
|
3987
|
+
|
|
3988
|
+
}
|
|
3989
|
+
|
|
3990
|
+
} else {
|
|
3991
|
+
|
|
3992
|
+
if ( subNode.name === 'PoseNode' ) {
|
|
3993
|
+
|
|
3994
|
+
if ( ! Array.isArray( node[ subNode.name ] ) ) {
|
|
3995
|
+
|
|
3996
|
+
node[ subNode.name ] = [ node[ subNode.name ] ];
|
|
3997
|
+
|
|
3998
|
+
}
|
|
3999
|
+
|
|
4000
|
+
node[ subNode.name ].push( subNode );
|
|
4001
|
+
|
|
4002
|
+
} else if ( node[ subNode.name ][ subNode.id ] === undefined ) {
|
|
4003
|
+
|
|
4004
|
+
node[ subNode.name ][ subNode.id ] = subNode;
|
|
4005
|
+
|
|
4006
|
+
}
|
|
4007
|
+
|
|
4008
|
+
}
|
|
4009
|
+
|
|
4010
|
+
}
|
|
4011
|
+
|
|
4012
|
+
parseProperty( reader ) {
|
|
4013
|
+
|
|
4014
|
+
const type = reader.getString( 1 );
|
|
4015
|
+
let length;
|
|
4016
|
+
|
|
4017
|
+
switch ( type ) {
|
|
4018
|
+
|
|
4019
|
+
case 'C':
|
|
4020
|
+
return reader.getBoolean();
|
|
4021
|
+
|
|
4022
|
+
case 'D':
|
|
4023
|
+
return reader.getFloat64();
|
|
4024
|
+
|
|
4025
|
+
case 'F':
|
|
4026
|
+
return reader.getFloat32();
|
|
4027
|
+
|
|
4028
|
+
case 'I':
|
|
4029
|
+
return reader.getInt32();
|
|
4030
|
+
|
|
4031
|
+
case 'L':
|
|
4032
|
+
return reader.getInt64();
|
|
4033
|
+
|
|
4034
|
+
case 'R':
|
|
4035
|
+
length = reader.getUint32();
|
|
4036
|
+
return reader.getArrayBuffer( length );
|
|
4037
|
+
|
|
4038
|
+
case 'S':
|
|
4039
|
+
length = reader.getUint32();
|
|
4040
|
+
return reader.getString( length );
|
|
4041
|
+
|
|
4042
|
+
case 'Y':
|
|
4043
|
+
return reader.getInt16();
|
|
4044
|
+
|
|
4045
|
+
case 'b':
|
|
4046
|
+
case 'c':
|
|
4047
|
+
case 'd':
|
|
4048
|
+
case 'f':
|
|
4049
|
+
case 'i':
|
|
4050
|
+
case 'l':
|
|
4051
|
+
|
|
4052
|
+
const arrayLength = reader.getUint32();
|
|
4053
|
+
const encoding = reader.getUint32(); // 0: non-compressed, 1: compressed
|
|
4054
|
+
const compressedLength = reader.getUint32();
|
|
4055
|
+
|
|
4056
|
+
if ( encoding === 0 ) {
|
|
4057
|
+
|
|
4058
|
+
switch ( type ) {
|
|
4059
|
+
|
|
4060
|
+
case 'b':
|
|
4061
|
+
case 'c':
|
|
4062
|
+
return reader.getBooleanArray( arrayLength );
|
|
4063
|
+
|
|
4064
|
+
case 'd':
|
|
4065
|
+
return reader.getFloat64Array( arrayLength );
|
|
4066
|
+
|
|
4067
|
+
case 'f':
|
|
4068
|
+
return reader.getFloat32Array( arrayLength );
|
|
4069
|
+
|
|
4070
|
+
case 'i':
|
|
4071
|
+
return reader.getInt32Array( arrayLength );
|
|
4072
|
+
|
|
4073
|
+
case 'l':
|
|
4074
|
+
return reader.getInt64Array( arrayLength );
|
|
4075
|
+
|
|
4076
|
+
}
|
|
4077
|
+
|
|
4078
|
+
}
|
|
4079
|
+
|
|
4080
|
+
const data = unzlibSync( new Uint8Array( reader.getArrayBuffer( compressedLength ) ) );
|
|
4081
|
+
const reader2 = new BinaryReader( data.buffer );
|
|
4082
|
+
|
|
4083
|
+
switch ( type ) {
|
|
4084
|
+
|
|
4085
|
+
case 'b':
|
|
4086
|
+
case 'c':
|
|
4087
|
+
return reader2.getBooleanArray( arrayLength );
|
|
4088
|
+
|
|
4089
|
+
case 'd':
|
|
4090
|
+
return reader2.getFloat64Array( arrayLength );
|
|
4091
|
+
|
|
4092
|
+
case 'f':
|
|
4093
|
+
return reader2.getFloat32Array( arrayLength );
|
|
4094
|
+
|
|
4095
|
+
case 'i':
|
|
4096
|
+
return reader2.getInt32Array( arrayLength );
|
|
4097
|
+
|
|
4098
|
+
case 'l':
|
|
4099
|
+
return reader2.getInt64Array( arrayLength );
|
|
4100
|
+
|
|
4101
|
+
}
|
|
4102
|
+
|
|
4103
|
+
break; // cannot happen but is required by the DeepScan
|
|
4104
|
+
|
|
4105
|
+
default:
|
|
4106
|
+
throw new Error( 'THREE.FBXLoader: Unknown property type ' + type );
|
|
4107
|
+
|
|
4108
|
+
}
|
|
4109
|
+
|
|
4110
|
+
}
|
|
4111
|
+
|
|
4112
|
+
}
|
|
4113
|
+
|
|
4114
|
+
class BinaryReader {
|
|
4115
|
+
|
|
4116
|
+
constructor( buffer, littleEndian ) {
|
|
4117
|
+
|
|
4118
|
+
this.dv = new DataView( buffer );
|
|
4119
|
+
this.offset = 0;
|
|
4120
|
+
this.littleEndian = ( littleEndian !== undefined ) ? littleEndian : true;
|
|
4121
|
+
this._textDecoder = new TextDecoder();
|
|
4122
|
+
|
|
4123
|
+
}
|
|
4124
|
+
|
|
4125
|
+
getOffset() {
|
|
4126
|
+
|
|
4127
|
+
return this.offset;
|
|
4128
|
+
|
|
4129
|
+
}
|
|
4130
|
+
|
|
4131
|
+
size() {
|
|
4132
|
+
|
|
4133
|
+
return this.dv.buffer.byteLength;
|
|
4134
|
+
|
|
4135
|
+
}
|
|
4136
|
+
|
|
4137
|
+
skip( length ) {
|
|
4138
|
+
|
|
4139
|
+
this.offset += length;
|
|
4140
|
+
|
|
4141
|
+
}
|
|
4142
|
+
|
|
4143
|
+
// seems like true/false representation depends on exporter.
|
|
4144
|
+
// true: 1 or 'Y'(=0x59), false: 0 or 'T'(=0x54)
|
|
4145
|
+
// then sees LSB.
|
|
4146
|
+
getBoolean() {
|
|
4147
|
+
|
|
4148
|
+
return ( this.getUint8() & 1 ) === 1;
|
|
4149
|
+
|
|
4150
|
+
}
|
|
4151
|
+
|
|
4152
|
+
getBooleanArray( size ) {
|
|
4153
|
+
|
|
4154
|
+
const a = [];
|
|
4155
|
+
|
|
4156
|
+
for ( let i = 0; i < size; i ++ ) {
|
|
4157
|
+
|
|
4158
|
+
a.push( this.getBoolean() );
|
|
4159
|
+
|
|
4160
|
+
}
|
|
4161
|
+
|
|
4162
|
+
return a;
|
|
4163
|
+
|
|
4164
|
+
}
|
|
4165
|
+
|
|
4166
|
+
getUint8() {
|
|
4167
|
+
|
|
4168
|
+
const value = this.dv.getUint8( this.offset );
|
|
4169
|
+
this.offset += 1;
|
|
4170
|
+
return value;
|
|
4171
|
+
|
|
4172
|
+
}
|
|
4173
|
+
|
|
4174
|
+
getInt16() {
|
|
4175
|
+
|
|
4176
|
+
const value = this.dv.getInt16( this.offset, this.littleEndian );
|
|
4177
|
+
this.offset += 2;
|
|
4178
|
+
return value;
|
|
4179
|
+
|
|
4180
|
+
}
|
|
4181
|
+
|
|
4182
|
+
getInt32() {
|
|
4183
|
+
|
|
4184
|
+
const value = this.dv.getInt32( this.offset, this.littleEndian );
|
|
4185
|
+
this.offset += 4;
|
|
4186
|
+
return value;
|
|
4187
|
+
|
|
4188
|
+
}
|
|
4189
|
+
|
|
4190
|
+
getInt32Array( size ) {
|
|
4191
|
+
|
|
4192
|
+
const a = [];
|
|
4193
|
+
|
|
4194
|
+
for ( let i = 0; i < size; i ++ ) {
|
|
4195
|
+
|
|
4196
|
+
a.push( this.getInt32() );
|
|
4197
|
+
|
|
4198
|
+
}
|
|
4199
|
+
|
|
4200
|
+
return a;
|
|
4201
|
+
|
|
4202
|
+
}
|
|
4203
|
+
|
|
4204
|
+
getUint32() {
|
|
4205
|
+
|
|
4206
|
+
const value = this.dv.getUint32( this.offset, this.littleEndian );
|
|
4207
|
+
this.offset += 4;
|
|
4208
|
+
return value;
|
|
4209
|
+
|
|
4210
|
+
}
|
|
4211
|
+
|
|
4212
|
+
// JavaScript doesn't support 64-bit integer so calculate this here
|
|
4213
|
+
// 1 << 32 will return 1 so using multiply operation instead here.
|
|
4214
|
+
// There's a possibility that this method returns wrong value if the value
|
|
4215
|
+
// is out of the range between Number.MAX_SAFE_INTEGER and Number.MIN_SAFE_INTEGER.
|
|
4216
|
+
// TODO: safely handle 64-bit integer
|
|
4217
|
+
getInt64() {
|
|
4218
|
+
|
|
4219
|
+
let low, high;
|
|
4220
|
+
|
|
4221
|
+
if ( this.littleEndian ) {
|
|
4222
|
+
|
|
4223
|
+
low = this.getUint32();
|
|
4224
|
+
high = this.getUint32();
|
|
4225
|
+
|
|
4226
|
+
} else {
|
|
4227
|
+
|
|
4228
|
+
high = this.getUint32();
|
|
4229
|
+
low = this.getUint32();
|
|
4230
|
+
|
|
4231
|
+
}
|
|
4232
|
+
|
|
4233
|
+
// calculate negative value
|
|
4234
|
+
if ( high & 0x80000000 ) {
|
|
4235
|
+
|
|
4236
|
+
high = ~ high & 0xFFFFFFFF;
|
|
4237
|
+
low = ~ low & 0xFFFFFFFF;
|
|
4238
|
+
|
|
4239
|
+
if ( low === 0xFFFFFFFF ) high = ( high + 1 ) & 0xFFFFFFFF;
|
|
4240
|
+
|
|
4241
|
+
low = ( low + 1 ) & 0xFFFFFFFF;
|
|
4242
|
+
|
|
4243
|
+
return - ( high * 0x100000000 + low );
|
|
4244
|
+
|
|
4245
|
+
}
|
|
4246
|
+
|
|
4247
|
+
return high * 0x100000000 + low;
|
|
4248
|
+
|
|
4249
|
+
}
|
|
4250
|
+
|
|
4251
|
+
getInt64Array( size ) {
|
|
4252
|
+
|
|
4253
|
+
const a = [];
|
|
4254
|
+
|
|
4255
|
+
for ( let i = 0; i < size; i ++ ) {
|
|
4256
|
+
|
|
4257
|
+
a.push( this.getInt64() );
|
|
4258
|
+
|
|
4259
|
+
}
|
|
4260
|
+
|
|
4261
|
+
return a;
|
|
4262
|
+
|
|
4263
|
+
}
|
|
4264
|
+
|
|
4265
|
+
// Note: see getInt64() comment
|
|
4266
|
+
getUint64() {
|
|
4267
|
+
|
|
4268
|
+
let low, high;
|
|
4269
|
+
|
|
4270
|
+
if ( this.littleEndian ) {
|
|
4271
|
+
|
|
4272
|
+
low = this.getUint32();
|
|
4273
|
+
high = this.getUint32();
|
|
4274
|
+
|
|
4275
|
+
} else {
|
|
4276
|
+
|
|
4277
|
+
high = this.getUint32();
|
|
4278
|
+
low = this.getUint32();
|
|
4279
|
+
|
|
4280
|
+
}
|
|
4281
|
+
|
|
4282
|
+
return high * 0x100000000 + low;
|
|
4283
|
+
|
|
4284
|
+
}
|
|
4285
|
+
|
|
4286
|
+
getFloat32() {
|
|
4287
|
+
|
|
4288
|
+
const value = this.dv.getFloat32( this.offset, this.littleEndian );
|
|
4289
|
+
this.offset += 4;
|
|
4290
|
+
return value;
|
|
4291
|
+
|
|
4292
|
+
}
|
|
4293
|
+
|
|
4294
|
+
getFloat32Array( size ) {
|
|
4295
|
+
|
|
4296
|
+
const a = [];
|
|
4297
|
+
|
|
4298
|
+
for ( let i = 0; i < size; i ++ ) {
|
|
4299
|
+
|
|
4300
|
+
a.push( this.getFloat32() );
|
|
4301
|
+
|
|
4302
|
+
}
|
|
4303
|
+
|
|
4304
|
+
return a;
|
|
4305
|
+
|
|
4306
|
+
}
|
|
4307
|
+
|
|
4308
|
+
getFloat64() {
|
|
4309
|
+
|
|
4310
|
+
const value = this.dv.getFloat64( this.offset, this.littleEndian );
|
|
4311
|
+
this.offset += 8;
|
|
4312
|
+
return value;
|
|
4313
|
+
|
|
4314
|
+
}
|
|
4315
|
+
|
|
4316
|
+
getFloat64Array( size ) {
|
|
4317
|
+
|
|
4318
|
+
const a = [];
|
|
4319
|
+
|
|
4320
|
+
for ( let i = 0; i < size; i ++ ) {
|
|
4321
|
+
|
|
4322
|
+
a.push( this.getFloat64() );
|
|
4323
|
+
|
|
4324
|
+
}
|
|
4325
|
+
|
|
4326
|
+
return a;
|
|
4327
|
+
|
|
4328
|
+
}
|
|
4329
|
+
|
|
4330
|
+
getArrayBuffer( size ) {
|
|
4331
|
+
|
|
4332
|
+
const value = this.dv.buffer.slice( this.offset, this.offset + size );
|
|
4333
|
+
this.offset += size;
|
|
4334
|
+
return value;
|
|
4335
|
+
|
|
4336
|
+
}
|
|
4337
|
+
|
|
4338
|
+
getString( size ) {
|
|
4339
|
+
|
|
4340
|
+
const start = this.offset;
|
|
4341
|
+
let a = new Uint8Array( this.dv.buffer, start, size );
|
|
4342
|
+
|
|
4343
|
+
this.skip( size );
|
|
4344
|
+
|
|
4345
|
+
const nullByte = a.indexOf( 0 );
|
|
4346
|
+
if ( nullByte >= 0 ) a = new Uint8Array( this.dv.buffer, start, nullByte );
|
|
4347
|
+
|
|
4348
|
+
return this._textDecoder.decode( a );
|
|
4349
|
+
|
|
4350
|
+
}
|
|
4351
|
+
|
|
4352
|
+
}
|
|
4353
|
+
|
|
4354
|
+
// FBXTree holds a representation of the FBX data, returned by the TextParser ( FBX ASCII format)
|
|
4355
|
+
// and BinaryParser( FBX Binary format)
|
|
4356
|
+
class FBXTree {
|
|
4357
|
+
|
|
4358
|
+
add( key, val ) {
|
|
4359
|
+
|
|
4360
|
+
this[ key ] = val;
|
|
4361
|
+
|
|
4362
|
+
}
|
|
4363
|
+
|
|
4364
|
+
}
|
|
4365
|
+
|
|
4366
|
+
// ************** UTILITY FUNCTIONS **************
|
|
4367
|
+
|
|
4368
|
+
function isFbxFormatBinary( buffer ) {
|
|
4369
|
+
|
|
4370
|
+
const CORRECT = 'Kaydara\u0020FBX\u0020Binary\u0020\u0020\0';
|
|
4371
|
+
|
|
4372
|
+
return buffer.byteLength >= CORRECT.length && CORRECT === convertArrayBufferToString( buffer, 0, CORRECT.length );
|
|
4373
|
+
|
|
4374
|
+
}
|
|
4375
|
+
|
|
4376
|
+
function isFbxFormatASCII( text ) {
|
|
4377
|
+
|
|
4378
|
+
const CORRECT = [ 'K', 'a', 'y', 'd', 'a', 'r', 'a', '\\', 'F', 'B', 'X', '\\', 'B', 'i', 'n', 'a', 'r', 'y', '\\', '\\' ];
|
|
4379
|
+
|
|
4380
|
+
let cursor = 0;
|
|
4381
|
+
|
|
4382
|
+
function read( offset ) {
|
|
4383
|
+
|
|
4384
|
+
const result = text[ offset - 1 ];
|
|
4385
|
+
text = text.slice( cursor + offset );
|
|
4386
|
+
cursor ++;
|
|
4387
|
+
return result;
|
|
4388
|
+
|
|
4389
|
+
}
|
|
4390
|
+
|
|
4391
|
+
for ( let i = 0; i < CORRECT.length; ++ i ) {
|
|
4392
|
+
|
|
4393
|
+
const num = read( 1 );
|
|
4394
|
+
if ( num === CORRECT[ i ] ) {
|
|
4395
|
+
|
|
4396
|
+
return false;
|
|
4397
|
+
|
|
4398
|
+
}
|
|
4399
|
+
|
|
4400
|
+
}
|
|
4401
|
+
|
|
4402
|
+
return true;
|
|
4403
|
+
|
|
4404
|
+
}
|
|
4405
|
+
|
|
4406
|
+
function getFbxVersion( text ) {
|
|
4407
|
+
|
|
4408
|
+
const versionRegExp = /FBXVersion: (\d+)/;
|
|
4409
|
+
const match = text.match( versionRegExp );
|
|
4410
|
+
|
|
4411
|
+
if ( match ) {
|
|
4412
|
+
|
|
4413
|
+
const version = parseInt( match[ 1 ] );
|
|
4414
|
+
return version;
|
|
4415
|
+
|
|
4416
|
+
}
|
|
4417
|
+
|
|
4418
|
+
throw new Error( 'THREE.FBXLoader: Cannot find the version number for the file given.' );
|
|
4419
|
+
|
|
4420
|
+
}
|
|
4421
|
+
|
|
4422
|
+
// Converts FBX ticks into real time seconds.
|
|
4423
|
+
function convertFBXTimeToSeconds( time ) {
|
|
4424
|
+
|
|
4425
|
+
return time / 46186158000;
|
|
4426
|
+
|
|
4427
|
+
}
|
|
4428
|
+
|
|
4429
|
+
const dataArray = [];
|
|
4430
|
+
|
|
4431
|
+
// extracts the data from the correct position in the FBX array based on indexing type
|
|
4432
|
+
function getData( polygonVertexIndex, polygonIndex, vertexIndex, infoObject ) {
|
|
4433
|
+
|
|
4434
|
+
let index;
|
|
4435
|
+
|
|
4436
|
+
switch ( infoObject.mappingType ) {
|
|
4437
|
+
|
|
4438
|
+
case 'ByPolygonVertex' :
|
|
4439
|
+
index = polygonVertexIndex;
|
|
4440
|
+
break;
|
|
4441
|
+
case 'ByPolygon' :
|
|
4442
|
+
index = polygonIndex;
|
|
4443
|
+
break;
|
|
4444
|
+
case 'ByVertice' :
|
|
4445
|
+
index = vertexIndex;
|
|
4446
|
+
break;
|
|
4447
|
+
case 'AllSame' :
|
|
4448
|
+
index = infoObject.indices[ 0 ];
|
|
4449
|
+
break;
|
|
4450
|
+
default :
|
|
4451
|
+
console.warn( 'THREE.FBXLoader: unknown attribute mapping type ' + infoObject.mappingType );
|
|
4452
|
+
|
|
4453
|
+
}
|
|
4454
|
+
|
|
4455
|
+
if ( infoObject.referenceType === 'IndexToDirect' ) index = infoObject.indices[ index ];
|
|
4456
|
+
|
|
4457
|
+
const from = index * infoObject.dataSize;
|
|
4458
|
+
const to = from + infoObject.dataSize;
|
|
4459
|
+
|
|
4460
|
+
return slice( dataArray, infoObject.buffer, from, to );
|
|
4461
|
+
|
|
4462
|
+
}
|
|
4463
|
+
|
|
4464
|
+
const tempEuler = new Euler();
|
|
4465
|
+
const tempVec = new Vector3();
|
|
4466
|
+
|
|
4467
|
+
// generate transformation from FBX transform data
|
|
4468
|
+
// ref: https://help.autodesk.com/view/FBX/2017/ENU/?guid=__files_GUID_10CDD63C_79C1_4F2D_BB28_AD2BE65A02ED_htm
|
|
4469
|
+
// ref: http://docs.autodesk.com/FBX/2014/ENU/FBX-SDK-Documentation/index.html?url=cpp_ref/_transformations_2main_8cxx-example.html,topicNumber=cpp_ref__transformations_2main_8cxx_example_htmlfc10a1e1-b18d-4e72-9dc0-70d0f1959f5e
|
|
4470
|
+
function generateTransform( transformData ) {
|
|
4471
|
+
|
|
4472
|
+
const lTranslationM = new Matrix4();
|
|
4473
|
+
const lPreRotationM = new Matrix4();
|
|
4474
|
+
const lRotationM = new Matrix4();
|
|
4475
|
+
const lPostRotationM = new Matrix4();
|
|
4476
|
+
|
|
4477
|
+
const lScalingM = new Matrix4();
|
|
4478
|
+
const lScalingPivotM = new Matrix4();
|
|
4479
|
+
const lScalingOffsetM = new Matrix4();
|
|
4480
|
+
const lRotationOffsetM = new Matrix4();
|
|
4481
|
+
const lRotationPivotM = new Matrix4();
|
|
4482
|
+
|
|
4483
|
+
const lParentGX = new Matrix4();
|
|
4484
|
+
const lParentLX = new Matrix4();
|
|
4485
|
+
const lGlobalT = new Matrix4();
|
|
4486
|
+
|
|
4487
|
+
const inheritType = ( transformData.inheritType ) ? transformData.inheritType : 0;
|
|
4488
|
+
|
|
4489
|
+
if ( transformData.translation ) lTranslationM.setPosition( tempVec.fromArray( transformData.translation ) );
|
|
4490
|
+
|
|
4491
|
+
// For Maya models using "Joint Orient", Euler order only applies to rotation, not pre/post-rotations
|
|
4492
|
+
const defaultEulerOrder = getEulerOrder( 0 );
|
|
4493
|
+
|
|
4494
|
+
if ( transformData.preRotation ) {
|
|
4495
|
+
|
|
4496
|
+
const array = transformData.preRotation.map( MathUtils.degToRad );
|
|
4497
|
+
array.push( defaultEulerOrder );
|
|
4498
|
+
lPreRotationM.makeRotationFromEuler( tempEuler.fromArray( array ) );
|
|
4499
|
+
|
|
4500
|
+
}
|
|
4501
|
+
|
|
4502
|
+
if ( transformData.rotation ) {
|
|
4503
|
+
|
|
4504
|
+
const array = transformData.rotation.map( MathUtils.degToRad );
|
|
4505
|
+
array.push( transformData.eulerOrder || defaultEulerOrder );
|
|
4506
|
+
lRotationM.makeRotationFromEuler( tempEuler.fromArray( array ) );
|
|
4507
|
+
|
|
4508
|
+
}
|
|
4509
|
+
|
|
4510
|
+
if ( transformData.postRotation ) {
|
|
4511
|
+
|
|
4512
|
+
const array = transformData.postRotation.map( MathUtils.degToRad );
|
|
4513
|
+
array.push( defaultEulerOrder );
|
|
4514
|
+
lPostRotationM.makeRotationFromEuler( tempEuler.fromArray( array ) );
|
|
4515
|
+
lPostRotationM.invert();
|
|
4516
|
+
|
|
4517
|
+
}
|
|
4518
|
+
|
|
4519
|
+
if ( transformData.scale ) lScalingM.scale( tempVec.fromArray( transformData.scale ) );
|
|
4520
|
+
|
|
4521
|
+
// Pivots and offsets
|
|
4522
|
+
if ( transformData.scalingOffset ) lScalingOffsetM.setPosition( tempVec.fromArray( transformData.scalingOffset ) );
|
|
4523
|
+
if ( transformData.scalingPivot ) lScalingPivotM.setPosition( tempVec.fromArray( transformData.scalingPivot ) );
|
|
4524
|
+
if ( transformData.rotationOffset ) lRotationOffsetM.setPosition( tempVec.fromArray( transformData.rotationOffset ) );
|
|
4525
|
+
if ( transformData.rotationPivot ) lRotationPivotM.setPosition( tempVec.fromArray( transformData.rotationPivot ) );
|
|
4526
|
+
|
|
4527
|
+
// parent transform
|
|
4528
|
+
if ( transformData.parentMatrixWorld ) {
|
|
4529
|
+
|
|
4530
|
+
lParentLX.copy( transformData.parentMatrix );
|
|
4531
|
+
lParentGX.copy( transformData.parentMatrixWorld );
|
|
4532
|
+
|
|
4533
|
+
}
|
|
4534
|
+
|
|
4535
|
+
const lLRM = lPreRotationM.clone().multiply( lRotationM ).multiply( lPostRotationM );
|
|
4536
|
+
// Global Rotation
|
|
4537
|
+
const lParentGRM = new Matrix4();
|
|
4538
|
+
lParentGRM.extractRotation( lParentGX );
|
|
4539
|
+
|
|
4540
|
+
// Global Shear*Scaling
|
|
4541
|
+
const lParentTM = new Matrix4();
|
|
4542
|
+
lParentTM.copyPosition( lParentGX );
|
|
4543
|
+
|
|
4544
|
+
const lParentGRSM = lParentTM.clone().invert().multiply( lParentGX );
|
|
4545
|
+
const lParentGSM = lParentGRM.clone().invert().multiply( lParentGRSM );
|
|
4546
|
+
const lLSM = lScalingM;
|
|
4547
|
+
|
|
4548
|
+
const lGlobalRS = new Matrix4();
|
|
4549
|
+
|
|
4550
|
+
if ( inheritType === 0 ) {
|
|
4551
|
+
|
|
4552
|
+
lGlobalRS.copy( lParentGRM ).multiply( lLRM ).multiply( lParentGSM ).multiply( lLSM );
|
|
4553
|
+
|
|
4554
|
+
} else if ( inheritType === 1 ) {
|
|
4555
|
+
|
|
4556
|
+
lGlobalRS.copy( lParentGRM ).multiply( lParentGSM ).multiply( lLRM ).multiply( lLSM );
|
|
4557
|
+
|
|
4558
|
+
} else {
|
|
4559
|
+
|
|
4560
|
+
const lParentLSM = new Matrix4().scale( new Vector3().setFromMatrixScale( lParentLX ) );
|
|
4561
|
+
const lParentLSM_inv = lParentLSM.clone().invert();
|
|
4562
|
+
const lParentGSM_noLocal = lParentGSM.clone().multiply( lParentLSM_inv );
|
|
4563
|
+
|
|
4564
|
+
lGlobalRS.copy( lParentGRM ).multiply( lLRM ).multiply( lParentGSM_noLocal ).multiply( lLSM );
|
|
4565
|
+
|
|
4566
|
+
}
|
|
4567
|
+
|
|
4568
|
+
const lRotationPivotM_inv = lRotationPivotM.clone().invert();
|
|
4569
|
+
const lScalingPivotM_inv = lScalingPivotM.clone().invert();
|
|
4570
|
+
// Calculate the local transform matrix
|
|
4571
|
+
let lTransform = lTranslationM.clone().multiply( lRotationOffsetM ).multiply( lRotationPivotM ).multiply( lPreRotationM ).multiply( lRotationM ).multiply( lPostRotationM ).multiply( lRotationPivotM_inv ).multiply( lScalingOffsetM ).multiply( lScalingPivotM ).multiply( lScalingM ).multiply( lScalingPivotM_inv );
|
|
4572
|
+
|
|
4573
|
+
const lLocalTWithAllPivotAndOffsetInfo = new Matrix4().copyPosition( lTransform );
|
|
4574
|
+
|
|
4575
|
+
const lGlobalTranslation = lParentGX.clone().multiply( lLocalTWithAllPivotAndOffsetInfo );
|
|
4576
|
+
lGlobalT.copyPosition( lGlobalTranslation );
|
|
4577
|
+
|
|
4578
|
+
lTransform = lGlobalT.clone().multiply( lGlobalRS );
|
|
4579
|
+
|
|
4580
|
+
// from global to local
|
|
4581
|
+
lTransform.premultiply( lParentGX.invert() );
|
|
4582
|
+
|
|
4583
|
+
return lTransform;
|
|
4584
|
+
|
|
4585
|
+
}
|
|
4586
|
+
|
|
4587
|
+
// Returns the three.js intrinsic Euler order corresponding to FBX extrinsic Euler order
|
|
4588
|
+
// ref: http://help.autodesk.com/view/FBX/2017/ENU/?guid=__cpp_ref_class_fbx_euler_html
|
|
4589
|
+
function getEulerOrder( order ) {
|
|
4590
|
+
|
|
4591
|
+
order = order || 0;
|
|
4592
|
+
|
|
4593
|
+
const enums = [
|
|
4594
|
+
'ZYX', // -> XYZ extrinsic
|
|
4595
|
+
'YZX', // -> XZY extrinsic
|
|
4596
|
+
'XZY', // -> YZX extrinsic
|
|
4597
|
+
'ZXY', // -> YXZ extrinsic
|
|
4598
|
+
'YXZ', // -> ZXY extrinsic
|
|
4599
|
+
'XYZ', // -> ZYX extrinsic
|
|
4600
|
+
//'SphericXYZ', // not possible to support
|
|
4601
|
+
];
|
|
4602
|
+
|
|
4603
|
+
if ( order === 6 ) {
|
|
4604
|
+
|
|
4605
|
+
console.warn( 'THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect.' );
|
|
4606
|
+
return enums[ 0 ];
|
|
4607
|
+
|
|
4608
|
+
}
|
|
4609
|
+
|
|
4610
|
+
return enums[ order ];
|
|
4611
|
+
|
|
4612
|
+
}
|
|
4613
|
+
|
|
4614
|
+
// Parses comma separated list of numbers and returns them an array.
|
|
4615
|
+
// Used internally by the TextParser
|
|
4616
|
+
function parseNumberArray( value ) {
|
|
4617
|
+
|
|
4618
|
+
const array = value.split( ',' ).map( function ( val ) {
|
|
4619
|
+
|
|
4620
|
+
return parseFloat( val );
|
|
4621
|
+
|
|
4622
|
+
} );
|
|
4623
|
+
|
|
4624
|
+
return array;
|
|
4625
|
+
|
|
4626
|
+
}
|
|
4627
|
+
|
|
4628
|
+
function convertArrayBufferToString( buffer, from, to ) {
|
|
4629
|
+
|
|
4630
|
+
if ( from === undefined ) from = 0;
|
|
4631
|
+
if ( to === undefined ) to = buffer.byteLength;
|
|
4632
|
+
|
|
4633
|
+
return new TextDecoder().decode( new Uint8Array( buffer, from, to ) );
|
|
4634
|
+
|
|
4635
|
+
}
|
|
4636
|
+
|
|
4637
|
+
function append( a, b ) {
|
|
4638
|
+
|
|
4639
|
+
for ( let i = 0, j = a.length, l = b.length; i < l; i ++, j ++ ) {
|
|
4640
|
+
|
|
4641
|
+
a[ j ] = b[ i ];
|
|
4642
|
+
|
|
4643
|
+
}
|
|
4644
|
+
|
|
4645
|
+
}
|
|
4646
|
+
|
|
4647
|
+
function slice( a, b, from, to ) {
|
|
4648
|
+
|
|
4649
|
+
for ( let i = from, j = 0; i < to; i ++, j ++ ) {
|
|
4650
|
+
|
|
4651
|
+
a[ j ] = b[ i ];
|
|
4652
|
+
|
|
4653
|
+
}
|
|
4654
|
+
|
|
4655
|
+
return a;
|
|
4656
|
+
|
|
4657
|
+
}
|
|
4658
|
+
|
|
4659
|
+
|
|
4660
|
+
export { FBXLoader };
|