@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
|
+
AnimationClip,
|
|
3
|
+
BoxGeometry,
|
|
4
|
+
BufferAttribute,
|
|
5
|
+
BufferGeometry,
|
|
6
|
+
CapsuleGeometry,
|
|
7
|
+
ClampToEdgeWrapping,
|
|
8
|
+
Color,
|
|
9
|
+
ConeGeometry,
|
|
10
|
+
CylinderGeometry,
|
|
11
|
+
DirectionalLight,
|
|
12
|
+
Euler,
|
|
13
|
+
Group,
|
|
14
|
+
ImageLoader,
|
|
15
|
+
LoaderUtils,
|
|
16
|
+
LinearSRGBColorSpace,
|
|
17
|
+
Matrix4,
|
|
18
|
+
Mesh,
|
|
19
|
+
MeshPhysicalMaterial,
|
|
20
|
+
MirroredRepeatWrapping,
|
|
21
|
+
NoColorSpace,
|
|
22
|
+
Object3D,
|
|
23
|
+
OrthographicCamera,
|
|
24
|
+
PerspectiveCamera,
|
|
25
|
+
PointLight,
|
|
26
|
+
Quaternion,
|
|
27
|
+
QuaternionKeyframeTrack,
|
|
28
|
+
RectAreaLight,
|
|
29
|
+
RepeatWrapping,
|
|
30
|
+
ShapeUtils,
|
|
31
|
+
SkinnedMesh,
|
|
32
|
+
Skeleton,
|
|
33
|
+
Bone,
|
|
34
|
+
SphereGeometry,
|
|
35
|
+
SpotLight,
|
|
36
|
+
SRGBColorSpace,
|
|
37
|
+
Texture,
|
|
38
|
+
Vector2,
|
|
39
|
+
Vector3,
|
|
40
|
+
VectorKeyframeTrack
|
|
41
|
+
} from 'three';
|
|
42
|
+
|
|
43
|
+
// Pre-compiled regex patterns for performance
|
|
44
|
+
const VARIANT_PATH_REGEX = /^(.+?)\/\{(\w+)=(\w+)\}\/(.+)$/;
|
|
45
|
+
|
|
46
|
+
// Spec types (must match USDCParser)
|
|
47
|
+
const SpecType = {
|
|
48
|
+
Unknown: 0,
|
|
49
|
+
Attribute: 1,
|
|
50
|
+
Connection: 2,
|
|
51
|
+
Expression: 3,
|
|
52
|
+
Mapper: 4,
|
|
53
|
+
MapperArg: 5,
|
|
54
|
+
Prim: 6,
|
|
55
|
+
PseudoRoot: 7,
|
|
56
|
+
Relationship: 8,
|
|
57
|
+
RelationshipTarget: 9,
|
|
58
|
+
Variant: 10,
|
|
59
|
+
VariantSet: 11
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// UsdGeomCamera fallback values (OpenUSD schema)
|
|
63
|
+
const USD_CAMERA_DEFAULTS = {
|
|
64
|
+
projection: 'perspective',
|
|
65
|
+
clippingRange: [ 1, 1000000 ],
|
|
66
|
+
horizontalAperture: 20.955,
|
|
67
|
+
verticalAperture: 15.2908,
|
|
68
|
+
horizontalApertureOffset: 0,
|
|
69
|
+
verticalApertureOffset: 0,
|
|
70
|
+
focalLength: 50,
|
|
71
|
+
focusDistance: 0,
|
|
72
|
+
fStop: 0
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* USDComposer handles scene composition from parsed USD data.
|
|
77
|
+
* This includes reference resolution, variant selection, transform handling,
|
|
78
|
+
* and building the Three.js scene graph.
|
|
79
|
+
*
|
|
80
|
+
* Works with specsByPath format from USDCParser.
|
|
81
|
+
*/
|
|
82
|
+
class USDComposer {
|
|
83
|
+
|
|
84
|
+
constructor( manager ) {
|
|
85
|
+
|
|
86
|
+
this.textureCache = {};
|
|
87
|
+
this.skinnedMeshes = [];
|
|
88
|
+
this.manager = manager;
|
|
89
|
+
this.imageLoader = new ImageLoader( manager );
|
|
90
|
+
this.texturePromises = [];
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Compose a Three.js scene from parsed USD data.
|
|
96
|
+
* @param {Object} parsedData - Data from USDCParser or USDAParser
|
|
97
|
+
* @param {Object} assets - Dictionary of referenced assets (specsByPath or blob URLs)
|
|
98
|
+
* @param {Object} variantSelections - External variant selections
|
|
99
|
+
* @param {string} basePath - Base path for resolving relative references
|
|
100
|
+
* @returns {Group} Three.js scene graph
|
|
101
|
+
*/
|
|
102
|
+
compose( parsedData, assets = {}, variantSelections = {}, basePath = '' ) {
|
|
103
|
+
|
|
104
|
+
this.specsByPath = parsedData.specsByPath;
|
|
105
|
+
this.assets = assets;
|
|
106
|
+
this.externalVariantSelections = variantSelections;
|
|
107
|
+
this.basePath = basePath;
|
|
108
|
+
this.skinnedMeshes = [];
|
|
109
|
+
this.skeletons = {};
|
|
110
|
+
this.texturePromises = [];
|
|
111
|
+
|
|
112
|
+
// Build indexes for O(1) lookups
|
|
113
|
+
this._buildIndexes();
|
|
114
|
+
|
|
115
|
+
// Get FPS from root spec
|
|
116
|
+
const rootSpec = this.specsByPath[ '/' ];
|
|
117
|
+
const rootFields = rootSpec ? rootSpec.fields : {};
|
|
118
|
+
this.fps = rootFields.timeCodesPerSecond || rootFields.framesPerSecond || 24;
|
|
119
|
+
|
|
120
|
+
const group = new Group();
|
|
121
|
+
this._buildHierarchy( group, '/' );
|
|
122
|
+
|
|
123
|
+
// Bind skeletons to skinned meshes
|
|
124
|
+
this._bindSkeletons();
|
|
125
|
+
|
|
126
|
+
// Expose skeleton on the root group so that AnimationMixer's
|
|
127
|
+
// PropertyBinding.findNode resolves bone names before scene objects.
|
|
128
|
+
// Without this, Xform prims that share a name with a skeleton joint
|
|
129
|
+
// would be animated instead of the bone.
|
|
130
|
+
const skeletonPaths = Object.keys( this.skeletons );
|
|
131
|
+
if ( skeletonPaths.length === 1 ) {
|
|
132
|
+
|
|
133
|
+
group.skeleton = this.skeletons[ skeletonPaths[ 0 ] ].skeleton;
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Build animations
|
|
138
|
+
group.animations = this._buildAnimations();
|
|
139
|
+
|
|
140
|
+
// Handle metersPerUnit scaling
|
|
141
|
+
const metersPerUnit = rootFields.metersPerUnit;
|
|
142
|
+
|
|
143
|
+
if ( metersPerUnit !== undefined && metersPerUnit !== 1 ) {
|
|
144
|
+
|
|
145
|
+
group.scale.setScalar( metersPerUnit );
|
|
146
|
+
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Handle Z-up to Y-up conversion
|
|
150
|
+
if ( rootSpec && rootSpec.fields && rootSpec.fields.upAxis === 'Z' ) {
|
|
151
|
+
|
|
152
|
+
group.rotation.x = - Math.PI / 2;
|
|
153
|
+
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return group;
|
|
157
|
+
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Apply USD transforms to a Three.js object.
|
|
162
|
+
* Handles xformOpOrder with proper matrix composition.
|
|
163
|
+
* USD uses row-vector convention, Three.js uses column-vector.
|
|
164
|
+
*/
|
|
165
|
+
applyTransform( obj, fields, attrs = {} ) {
|
|
166
|
+
|
|
167
|
+
const data = { ...fields, ...attrs };
|
|
168
|
+
const xformOpOrder = data[ 'xformOpOrder' ];
|
|
169
|
+
|
|
170
|
+
// If we have xformOpOrder, apply transforms using matrices
|
|
171
|
+
if ( xformOpOrder && xformOpOrder.length > 0 ) {
|
|
172
|
+
|
|
173
|
+
const matrix = new Matrix4();
|
|
174
|
+
const tempMatrix = new Matrix4();
|
|
175
|
+
|
|
176
|
+
// Track scale for handling negative scale with rotation
|
|
177
|
+
let scaleValues = null;
|
|
178
|
+
|
|
179
|
+
// Iterate FORWARD for Three.js column-vector convention
|
|
180
|
+
for ( let i = 0; i < xformOpOrder.length; i ++ ) {
|
|
181
|
+
|
|
182
|
+
const op = xformOpOrder[ i ];
|
|
183
|
+
const isInverse = op.startsWith( '!invert!' );
|
|
184
|
+
const opName = isInverse ? op.slice( 8 ) : op;
|
|
185
|
+
|
|
186
|
+
if ( opName === 'xformOp:transform' ) {
|
|
187
|
+
|
|
188
|
+
const m = data[ 'xformOp:transform' ];
|
|
189
|
+
if ( m && m.length === 16 ) {
|
|
190
|
+
|
|
191
|
+
tempMatrix.set(
|
|
192
|
+
m[ 0 ], m[ 4 ], m[ 8 ], m[ 12 ],
|
|
193
|
+
m[ 1 ], m[ 5 ], m[ 9 ], m[ 13 ],
|
|
194
|
+
m[ 2 ], m[ 6 ], m[ 10 ], m[ 14 ],
|
|
195
|
+
m[ 3 ], m[ 7 ], m[ 11 ], m[ 15 ]
|
|
196
|
+
);
|
|
197
|
+
if ( isInverse ) tempMatrix.invert();
|
|
198
|
+
matrix.multiply( tempMatrix );
|
|
199
|
+
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
} else if ( opName === 'xformOp:translate' ) {
|
|
203
|
+
|
|
204
|
+
const t = data[ 'xformOp:translate' ];
|
|
205
|
+
if ( t ) {
|
|
206
|
+
|
|
207
|
+
tempMatrix.makeTranslation( t[ 0 ], t[ 1 ], t[ 2 ] );
|
|
208
|
+
if ( isInverse ) tempMatrix.invert();
|
|
209
|
+
matrix.multiply( tempMatrix );
|
|
210
|
+
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
} else if ( opName === 'xformOp:translate:pivot' ) {
|
|
214
|
+
|
|
215
|
+
const t = data[ 'xformOp:translate:pivot' ];
|
|
216
|
+
if ( t ) {
|
|
217
|
+
|
|
218
|
+
tempMatrix.makeTranslation( t[ 0 ], t[ 1 ], t[ 2 ] );
|
|
219
|
+
if ( isInverse ) tempMatrix.invert();
|
|
220
|
+
matrix.multiply( tempMatrix );
|
|
221
|
+
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
} else if ( opName === 'xformOp:scale' ) {
|
|
225
|
+
|
|
226
|
+
const s = data[ 'xformOp:scale' ];
|
|
227
|
+
if ( s ) {
|
|
228
|
+
|
|
229
|
+
if ( Array.isArray( s ) ) {
|
|
230
|
+
|
|
231
|
+
tempMatrix.makeScale( s[ 0 ], s[ 1 ], s[ 2 ] );
|
|
232
|
+
scaleValues = [ s[ 0 ], s[ 1 ], s[ 2 ] ];
|
|
233
|
+
|
|
234
|
+
} else {
|
|
235
|
+
|
|
236
|
+
tempMatrix.makeScale( s, s, s );
|
|
237
|
+
scaleValues = [ s, s, s ];
|
|
238
|
+
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if ( isInverse ) tempMatrix.invert();
|
|
242
|
+
matrix.multiply( tempMatrix );
|
|
243
|
+
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
} else if ( opName === 'xformOp:rotateXYZ' ) {
|
|
247
|
+
|
|
248
|
+
const r = data[ 'xformOp:rotateXYZ' ];
|
|
249
|
+
if ( r ) {
|
|
250
|
+
|
|
251
|
+
// USD rotateXYZ: matrix = Rx * Ry * Rz
|
|
252
|
+
// Three.js Euler 'ZYX' order produces same result
|
|
253
|
+
const euler = new Euler(
|
|
254
|
+
r[ 0 ] * Math.PI / 180,
|
|
255
|
+
r[ 1 ] * Math.PI / 180,
|
|
256
|
+
r[ 2 ] * Math.PI / 180,
|
|
257
|
+
'ZYX'
|
|
258
|
+
);
|
|
259
|
+
tempMatrix.makeRotationFromEuler( euler );
|
|
260
|
+
if ( isInverse ) tempMatrix.invert();
|
|
261
|
+
matrix.multiply( tempMatrix );
|
|
262
|
+
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
} else if ( opName === 'xformOp:rotateX' ) {
|
|
266
|
+
|
|
267
|
+
const r = data[ 'xformOp:rotateX' ];
|
|
268
|
+
if ( r !== undefined ) {
|
|
269
|
+
|
|
270
|
+
tempMatrix.makeRotationX( r * Math.PI / 180 );
|
|
271
|
+
if ( isInverse ) tempMatrix.invert();
|
|
272
|
+
matrix.multiply( tempMatrix );
|
|
273
|
+
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
} else if ( opName === 'xformOp:rotateY' ) {
|
|
277
|
+
|
|
278
|
+
const r = data[ 'xformOp:rotateY' ];
|
|
279
|
+
if ( r !== undefined ) {
|
|
280
|
+
|
|
281
|
+
tempMatrix.makeRotationY( r * Math.PI / 180 );
|
|
282
|
+
if ( isInverse ) tempMatrix.invert();
|
|
283
|
+
matrix.multiply( tempMatrix );
|
|
284
|
+
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
} else if ( opName === 'xformOp:rotateZ' ) {
|
|
288
|
+
|
|
289
|
+
const r = data[ 'xformOp:rotateZ' ];
|
|
290
|
+
if ( r !== undefined ) {
|
|
291
|
+
|
|
292
|
+
tempMatrix.makeRotationZ( r * Math.PI / 180 );
|
|
293
|
+
if ( isInverse ) tempMatrix.invert();
|
|
294
|
+
matrix.multiply( tempMatrix );
|
|
295
|
+
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
} else if ( opName === 'xformOp:orient' ) {
|
|
299
|
+
|
|
300
|
+
const q = data[ 'xformOp:orient' ];
|
|
301
|
+
if ( q && q.length === 4 ) {
|
|
302
|
+
|
|
303
|
+
const quat = new Quaternion( q[ 0 ], q[ 1 ], q[ 2 ], q[ 3 ] );
|
|
304
|
+
tempMatrix.makeRotationFromQuaternion( quat );
|
|
305
|
+
if ( isInverse ) tempMatrix.invert();
|
|
306
|
+
matrix.multiply( tempMatrix );
|
|
307
|
+
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
obj.matrix.copy( matrix );
|
|
315
|
+
obj.matrix.decompose( obj.position, obj.quaternion, obj.scale );
|
|
316
|
+
|
|
317
|
+
// Fix for negative scale: decompose() may absorb negative scale into quaternion
|
|
318
|
+
// Restore original scale signs to keep animation consistent
|
|
319
|
+
if ( scaleValues ) {
|
|
320
|
+
|
|
321
|
+
const negX = scaleValues[ 0 ] < 0;
|
|
322
|
+
const negY = scaleValues[ 1 ] < 0;
|
|
323
|
+
const negZ = scaleValues[ 2 ] < 0;
|
|
324
|
+
const negCount = ( negX ? 1 : 0 ) + ( negY ? 1 : 0 ) + ( negZ ? 1 : 0 );
|
|
325
|
+
|
|
326
|
+
// decompose() absorbs pairs of negative scales into rotation
|
|
327
|
+
// For [-1,-1,-1] → [-1,1,1], Y and Z were absorbed, flip quat.y and quat.w
|
|
328
|
+
if ( negCount === 3 ) {
|
|
329
|
+
|
|
330
|
+
obj.scale.set( scaleValues[ 0 ], scaleValues[ 1 ], scaleValues[ 2 ] );
|
|
331
|
+
obj.quaternion.set(
|
|
332
|
+
obj.quaternion.x,
|
|
333
|
+
- obj.quaternion.y,
|
|
334
|
+
obj.quaternion.z,
|
|
335
|
+
- obj.quaternion.w
|
|
336
|
+
);
|
|
337
|
+
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
return;
|
|
343
|
+
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// Fallback: handle individual transform ops without order
|
|
347
|
+
if ( data[ 'xformOp:translate' ] ) {
|
|
348
|
+
|
|
349
|
+
const t = data[ 'xformOp:translate' ];
|
|
350
|
+
obj.position.set( t[ 0 ], t[ 1 ], t[ 2 ] );
|
|
351
|
+
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
if ( data[ 'xformOp:translate:pivot' ] ) {
|
|
355
|
+
|
|
356
|
+
const p = data[ 'xformOp:translate:pivot' ];
|
|
357
|
+
obj.pivot = new Vector3( p[ 0 ], p[ 1 ], p[ 2 ] );
|
|
358
|
+
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if ( data[ 'xformOp:scale' ] ) {
|
|
362
|
+
|
|
363
|
+
const s = data[ 'xformOp:scale' ];
|
|
364
|
+
|
|
365
|
+
if ( Array.isArray( s ) ) {
|
|
366
|
+
|
|
367
|
+
obj.scale.set( s[ 0 ], s[ 1 ], s[ 2 ] );
|
|
368
|
+
|
|
369
|
+
} else {
|
|
370
|
+
|
|
371
|
+
obj.scale.set( s, s, s );
|
|
372
|
+
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if ( data[ 'xformOp:rotateXYZ' ] ) {
|
|
378
|
+
|
|
379
|
+
const r = data[ 'xformOp:rotateXYZ' ];
|
|
380
|
+
obj.rotation.set(
|
|
381
|
+
r[ 0 ] * Math.PI / 180,
|
|
382
|
+
r[ 1 ] * Math.PI / 180,
|
|
383
|
+
r[ 2 ] * Math.PI / 180
|
|
384
|
+
);
|
|
385
|
+
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if ( data[ 'xformOp:orient' ] ) {
|
|
389
|
+
|
|
390
|
+
const q = data[ 'xformOp:orient' ];
|
|
391
|
+
if ( q.length === 4 ) {
|
|
392
|
+
|
|
393
|
+
obj.quaternion.set( q[ 0 ], q[ 1 ], q[ 2 ], q[ 3 ] );
|
|
394
|
+
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Build indexes for efficient lookups.
|
|
403
|
+
* Called once during compose() to avoid O(n) scans per lookup.
|
|
404
|
+
*/
|
|
405
|
+
_buildIndexes() {
|
|
406
|
+
|
|
407
|
+
// childrenByPath: parentPath -> [childName1, childName2, ...]
|
|
408
|
+
this.childrenByPath = new Map();
|
|
409
|
+
|
|
410
|
+
// attributesByPrimPath: primPath -> Map(attrName -> attrSpec)
|
|
411
|
+
this.attributesByPrimPath = new Map();
|
|
412
|
+
|
|
413
|
+
// materialsByRoot: rootPath -> [materialPath1, materialPath2, ...]
|
|
414
|
+
this.materialsByRoot = new Map();
|
|
415
|
+
|
|
416
|
+
// shadersByMaterialPath: materialPath -> [shaderPath1, shaderPath2, ...]
|
|
417
|
+
this.shadersByMaterialPath = new Map();
|
|
418
|
+
|
|
419
|
+
// geomSubsetsByMeshPath: meshPath -> [subsetPath1, subsetPath2, ...]
|
|
420
|
+
this.geomSubsetsByMeshPath = new Map();
|
|
421
|
+
|
|
422
|
+
for ( const path in this.specsByPath ) {
|
|
423
|
+
|
|
424
|
+
const spec = this.specsByPath[ path ];
|
|
425
|
+
|
|
426
|
+
if ( spec.specType === SpecType.Prim ) {
|
|
427
|
+
|
|
428
|
+
// Build parent-child index
|
|
429
|
+
const lastSlash = path.lastIndexOf( '/' );
|
|
430
|
+
|
|
431
|
+
if ( lastSlash > 0 ) {
|
|
432
|
+
|
|
433
|
+
const parentPath = path.slice( 0, lastSlash );
|
|
434
|
+
const childName = path.slice( lastSlash + 1 );
|
|
435
|
+
|
|
436
|
+
if ( ! this.childrenByPath.has( parentPath ) ) {
|
|
437
|
+
|
|
438
|
+
this.childrenByPath.set( parentPath, [] );
|
|
439
|
+
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
this.childrenByPath.get( parentPath ).push( { name: childName, path: path } );
|
|
443
|
+
|
|
444
|
+
} else if ( lastSlash === 0 && path.length > 1 ) {
|
|
445
|
+
|
|
446
|
+
// Direct child of root
|
|
447
|
+
const childName = path.slice( 1 );
|
|
448
|
+
|
|
449
|
+
if ( ! this.childrenByPath.has( '/' ) ) {
|
|
450
|
+
|
|
451
|
+
this.childrenByPath.set( '/', [] );
|
|
452
|
+
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
this.childrenByPath.get( '/' ).push( { name: childName, path: path } );
|
|
456
|
+
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
const typeName = spec.fields.typeName;
|
|
460
|
+
|
|
461
|
+
// Build material index
|
|
462
|
+
if ( typeName === 'Material' ) {
|
|
463
|
+
|
|
464
|
+
const parts = path.split( '/' );
|
|
465
|
+
const rootPath = parts.length > 1 ? '/' + parts[ 1 ] : '/';
|
|
466
|
+
|
|
467
|
+
if ( ! this.materialsByRoot.has( rootPath ) ) {
|
|
468
|
+
|
|
469
|
+
this.materialsByRoot.set( rootPath, [] );
|
|
470
|
+
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
this.materialsByRoot.get( rootPath ).push( path );
|
|
474
|
+
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// Build shader index (shaders are children or descendants of materials)
|
|
478
|
+
if ( typeName === 'Shader' && lastSlash > 0 ) {
|
|
479
|
+
|
|
480
|
+
// Walk up ancestors to find the nearest Material prim.
|
|
481
|
+
// Shaders may be direct children of a Material, or nested
|
|
482
|
+
// inside a NodeGraph (common with MaterialX materials).
|
|
483
|
+
|
|
484
|
+
let ancestorPath = path.slice( 0, lastSlash );
|
|
485
|
+
|
|
486
|
+
while ( ancestorPath.length > 0 ) {
|
|
487
|
+
|
|
488
|
+
const ancestorSpec = this.specsByPath[ ancestorPath ];
|
|
489
|
+
|
|
490
|
+
if ( ancestorSpec && ancestorSpec.specType === SpecType.Prim && ancestorSpec.fields.typeName === 'Material' ) {
|
|
491
|
+
|
|
492
|
+
if ( ! this.shadersByMaterialPath.has( ancestorPath ) ) {
|
|
493
|
+
|
|
494
|
+
this.shadersByMaterialPath.set( ancestorPath, [] );
|
|
495
|
+
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
this.shadersByMaterialPath.get( ancestorPath ).push( path );
|
|
499
|
+
break;
|
|
500
|
+
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
const slash = ancestorPath.lastIndexOf( '/' );
|
|
504
|
+
if ( slash <= 0 ) break;
|
|
505
|
+
ancestorPath = ancestorPath.slice( 0, slash );
|
|
506
|
+
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// Build GeomSubset index (subsets are children of meshes)
|
|
512
|
+
if ( typeName === 'GeomSubset' && lastSlash > 0 ) {
|
|
513
|
+
|
|
514
|
+
const meshPath = path.slice( 0, lastSlash );
|
|
515
|
+
|
|
516
|
+
if ( ! this.geomSubsetsByMeshPath.has( meshPath ) ) {
|
|
517
|
+
|
|
518
|
+
this.geomSubsetsByMeshPath.set( meshPath, [] );
|
|
519
|
+
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
this.geomSubsetsByMeshPath.get( meshPath ).push( path );
|
|
523
|
+
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
} else if ( spec.specType === SpecType.Attribute || spec.specType === SpecType.Relationship ) {
|
|
527
|
+
|
|
528
|
+
// Build attribute index
|
|
529
|
+
const dotIndex = path.lastIndexOf( '.' );
|
|
530
|
+
|
|
531
|
+
if ( dotIndex > 0 ) {
|
|
532
|
+
|
|
533
|
+
const primPath = path.slice( 0, dotIndex );
|
|
534
|
+
const attrName = path.slice( dotIndex + 1 );
|
|
535
|
+
|
|
536
|
+
if ( ! this.attributesByPrimPath.has( primPath ) ) {
|
|
537
|
+
|
|
538
|
+
this.attributesByPrimPath.set( primPath, new Map() );
|
|
539
|
+
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
this.attributesByPrimPath.get( primPath ).set( attrName, spec );
|
|
543
|
+
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Check if a path is a direct child of parentPath.
|
|
554
|
+
*/
|
|
555
|
+
_isDirectChild( parentPath, path, prefix ) {
|
|
556
|
+
|
|
557
|
+
if ( ! path.startsWith( prefix ) ) return false;
|
|
558
|
+
|
|
559
|
+
const remainder = path.slice( prefix.length );
|
|
560
|
+
if ( remainder.length === 0 ) return false;
|
|
561
|
+
|
|
562
|
+
// Check for variant paths or simple names
|
|
563
|
+
if ( remainder.startsWith( '{' ) ) {
|
|
564
|
+
|
|
565
|
+
return false; // Variant paths are not direct children
|
|
566
|
+
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
return ! remainder.includes( '/' );
|
|
570
|
+
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Build the scene hierarchy recursively.
|
|
575
|
+
* Uses childrenByPath index for O(1) child lookup instead of O(n) iteration.
|
|
576
|
+
*/
|
|
577
|
+
_buildHierarchy( parent, parentPath ) {
|
|
578
|
+
|
|
579
|
+
// Collect children from parentPath and any active variant paths
|
|
580
|
+
const childEntries = [];
|
|
581
|
+
const seenPaths = new Set();
|
|
582
|
+
|
|
583
|
+
// Get direct children using the index
|
|
584
|
+
const directChildren = this.childrenByPath.get( parentPath );
|
|
585
|
+
|
|
586
|
+
if ( directChildren ) {
|
|
587
|
+
|
|
588
|
+
for ( const child of directChildren ) {
|
|
589
|
+
|
|
590
|
+
if ( ! seenPaths.has( child.path ) ) {
|
|
591
|
+
|
|
592
|
+
seenPaths.add( child.path );
|
|
593
|
+
childEntries.push( child );
|
|
594
|
+
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
// Also get children from active variant paths
|
|
602
|
+
const variantPaths = this._getVariantPaths( parentPath );
|
|
603
|
+
|
|
604
|
+
for ( const vp of variantPaths ) {
|
|
605
|
+
|
|
606
|
+
const variantChildren = this.childrenByPath.get( vp );
|
|
607
|
+
|
|
608
|
+
if ( variantChildren ) {
|
|
609
|
+
|
|
610
|
+
for ( const child of variantChildren ) {
|
|
611
|
+
|
|
612
|
+
if ( ! seenPaths.has( child.path ) ) {
|
|
613
|
+
|
|
614
|
+
seenPaths.add( child.path );
|
|
615
|
+
childEntries.push( child );
|
|
616
|
+
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
// Process each child
|
|
626
|
+
for ( const { name, path } of childEntries ) {
|
|
627
|
+
|
|
628
|
+
const spec = this.specsByPath[ path ];
|
|
629
|
+
if ( ! spec || spec.specType !== SpecType.Prim ) continue;
|
|
630
|
+
|
|
631
|
+
const typeName = spec.fields.typeName;
|
|
632
|
+
|
|
633
|
+
// Check for references/payloads
|
|
634
|
+
const refValues = this._getReferences( spec );
|
|
635
|
+
if ( refValues.length > 0 ) {
|
|
636
|
+
|
|
637
|
+
// Get local variant selections from this prim
|
|
638
|
+
const localVariants = this._getLocalVariantSelections( spec.fields );
|
|
639
|
+
|
|
640
|
+
// Resolve all references
|
|
641
|
+
const resolvedGroups = [];
|
|
642
|
+
for ( const refValue of refValues ) {
|
|
643
|
+
|
|
644
|
+
const referencedGroup = this._resolveReference( refValue, localVariants );
|
|
645
|
+
if ( referencedGroup ) resolvedGroups.push( referencedGroup );
|
|
646
|
+
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
if ( resolvedGroups.length > 0 ) {
|
|
650
|
+
|
|
651
|
+
const attrs = this._getAttributes( path );
|
|
652
|
+
|
|
653
|
+
// Single reference with single mesh: use optimized path
|
|
654
|
+
// This handles the USDZExporter pattern: Xform references geometry file
|
|
655
|
+
if ( resolvedGroups.length === 1 ) {
|
|
656
|
+
|
|
657
|
+
const singleMesh = this._findSingleMesh( resolvedGroups[ 0 ] );
|
|
658
|
+
|
|
659
|
+
if ( singleMesh && ( typeName === 'Xform' || ! typeName ) ) {
|
|
660
|
+
|
|
661
|
+
// Merge the mesh into this prim
|
|
662
|
+
singleMesh.name = name;
|
|
663
|
+
this.applyTransform( singleMesh, spec.fields, attrs );
|
|
664
|
+
|
|
665
|
+
// Apply material binding from the referencing prim if present
|
|
666
|
+
this._applyMaterialBinding( singleMesh, path );
|
|
667
|
+
|
|
668
|
+
parent.add( singleMesh );
|
|
669
|
+
|
|
670
|
+
// Still build local children (overrides)
|
|
671
|
+
this._buildHierarchy( singleMesh, path );
|
|
672
|
+
|
|
673
|
+
continue;
|
|
674
|
+
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
// Create a container for the referenced content
|
|
680
|
+
const obj = new Object3D();
|
|
681
|
+
obj.name = name;
|
|
682
|
+
this.applyTransform( obj, spec.fields, attrs );
|
|
683
|
+
|
|
684
|
+
// Add all children from all resolved references
|
|
685
|
+
for ( const referencedGroup of resolvedGroups ) {
|
|
686
|
+
|
|
687
|
+
while ( referencedGroup.children.length > 0 ) {
|
|
688
|
+
|
|
689
|
+
obj.add( referencedGroup.children[ 0 ] );
|
|
690
|
+
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
parent.add( obj );
|
|
696
|
+
|
|
697
|
+
// Still build local children (overrides)
|
|
698
|
+
this._buildHierarchy( obj, path );
|
|
699
|
+
|
|
700
|
+
continue;
|
|
701
|
+
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
// Build appropriate object based on type
|
|
707
|
+
if ( typeName === 'SkelRoot' ) {
|
|
708
|
+
|
|
709
|
+
// Skeletal root - treat as transform but track for skeleton binding
|
|
710
|
+
const obj = new Object3D();
|
|
711
|
+
obj.name = name;
|
|
712
|
+
obj.userData.isSkelRoot = true;
|
|
713
|
+
const attrs = this._getAttributes( path );
|
|
714
|
+
this.applyTransform( obj, spec.fields, attrs );
|
|
715
|
+
parent.add( obj );
|
|
716
|
+
this._buildHierarchy( obj, path );
|
|
717
|
+
|
|
718
|
+
} else if ( typeName === 'Skeleton' ) {
|
|
719
|
+
|
|
720
|
+
// Build skeleton and store it
|
|
721
|
+
const skeleton = this._buildSkeleton( path );
|
|
722
|
+
if ( skeleton ) {
|
|
723
|
+
|
|
724
|
+
this.skeletons[ path ] = skeleton;
|
|
725
|
+
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
// Recursively build children (may contain SkelAnimation)
|
|
729
|
+
this._buildHierarchy( parent, path );
|
|
730
|
+
|
|
731
|
+
} else if ( typeName === 'SkelAnimation' ) {
|
|
732
|
+
|
|
733
|
+
// Skip - animations are processed separately in _buildAnimations
|
|
734
|
+
|
|
735
|
+
} else if ( typeName === 'Mesh' ) {
|
|
736
|
+
|
|
737
|
+
const obj = this._buildMesh( path, spec );
|
|
738
|
+
if ( obj ) {
|
|
739
|
+
|
|
740
|
+
parent.add( obj );
|
|
741
|
+
this._buildHierarchy( obj, path );
|
|
742
|
+
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
} else if ( typeName === 'Camera' ) {
|
|
746
|
+
|
|
747
|
+
const obj = this._buildCamera( path );
|
|
748
|
+
obj.name = name;
|
|
749
|
+
const attrs = this._getAttributes( path );
|
|
750
|
+
this.applyTransform( obj, spec.fields, attrs );
|
|
751
|
+
parent.add( obj );
|
|
752
|
+
this._buildHierarchy( obj, path );
|
|
753
|
+
|
|
754
|
+
} else if ( typeName === 'DistantLight' || typeName === 'SphereLight' || typeName === 'RectLight' || typeName === 'DiskLight' ) {
|
|
755
|
+
|
|
756
|
+
const obj = this._buildLight( path, typeName );
|
|
757
|
+
obj.name = name;
|
|
758
|
+
const attrs = this._getAttributes( path );
|
|
759
|
+
this.applyTransform( obj, spec.fields, attrs );
|
|
760
|
+
parent.add( obj );
|
|
761
|
+
this._buildHierarchy( obj, path );
|
|
762
|
+
|
|
763
|
+
} else if ( typeName === 'Cube' || typeName === 'Sphere' || typeName === 'Cylinder' || typeName === 'Cone' || typeName === 'Capsule' ) {
|
|
764
|
+
|
|
765
|
+
const obj = this._buildGeomPrimitive( path, spec, typeName );
|
|
766
|
+
if ( obj ) {
|
|
767
|
+
|
|
768
|
+
parent.add( obj );
|
|
769
|
+
this._buildHierarchy( obj, path );
|
|
770
|
+
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
} else if ( typeName === 'Material' || typeName === 'Shader' || typeName === 'GeomSubset' ) {
|
|
774
|
+
|
|
775
|
+
// Skip materials/shaders/subsets, they're referenced by meshes
|
|
776
|
+
|
|
777
|
+
} else {
|
|
778
|
+
|
|
779
|
+
// Transform node, group, or unknown type
|
|
780
|
+
const obj = new Object3D();
|
|
781
|
+
obj.name = name;
|
|
782
|
+
const attrs = this._getAttributes( path );
|
|
783
|
+
this.applyTransform( obj, spec.fields, attrs );
|
|
784
|
+
parent.add( obj );
|
|
785
|
+
this._buildHierarchy( obj, path );
|
|
786
|
+
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
/**
|
|
794
|
+
* Get variant paths for a parent path based on variant selections.
|
|
795
|
+
*/
|
|
796
|
+
_getVariantPaths( parentPath ) {
|
|
797
|
+
|
|
798
|
+
const parentSpec = this.specsByPath[ parentPath ];
|
|
799
|
+
const variantSetChildren = parentSpec?.fields?.variantSetChildren;
|
|
800
|
+
const variantPaths = [];
|
|
801
|
+
|
|
802
|
+
if ( ! variantSetChildren || variantSetChildren.length === 0 ) {
|
|
803
|
+
|
|
804
|
+
return variantPaths;
|
|
805
|
+
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
for ( const variantSetName of variantSetChildren ) {
|
|
809
|
+
|
|
810
|
+
// External selections take priority
|
|
811
|
+
let selectedVariant = this.externalVariantSelections[ variantSetName ] || null;
|
|
812
|
+
|
|
813
|
+
// Fall back to file's internal selection
|
|
814
|
+
if ( ! selectedVariant ) {
|
|
815
|
+
|
|
816
|
+
const variantSelection = parentSpec.fields.variantSelection;
|
|
817
|
+
selectedVariant = variantSelection ? variantSelection[ variantSetName ] : null;
|
|
818
|
+
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
// Fall back to first variant child
|
|
822
|
+
if ( ! selectedVariant ) {
|
|
823
|
+
|
|
824
|
+
const variantSetPath = parentPath + '/{' + variantSetName + '=}';
|
|
825
|
+
const variantSetSpec = this.specsByPath[ variantSetPath ];
|
|
826
|
+
if ( variantSetSpec?.fields?.variantChildren ) {
|
|
827
|
+
|
|
828
|
+
selectedVariant = variantSetSpec.fields.variantChildren[ 0 ];
|
|
829
|
+
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
if ( selectedVariant ) {
|
|
835
|
+
|
|
836
|
+
const variantPath = parentPath + '/{' + variantSetName + '=' + selectedVariant + '}';
|
|
837
|
+
variantPaths.push( variantPath );
|
|
838
|
+
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
return variantPaths;
|
|
844
|
+
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* Resolve a file path relative to basePath.
|
|
849
|
+
*/
|
|
850
|
+
_resolveFilePath( refPath ) {
|
|
851
|
+
|
|
852
|
+
let cleanPath = refPath;
|
|
853
|
+
|
|
854
|
+
// Remove ./ prefix
|
|
855
|
+
if ( cleanPath.startsWith( './' ) ) {
|
|
856
|
+
|
|
857
|
+
cleanPath = cleanPath.slice( 2 );
|
|
858
|
+
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
if ( ! this.basePath ) return cleanPath;
|
|
862
|
+
|
|
863
|
+
// LoaderUtils.resolveURL expects basePath to end with a separator;
|
|
864
|
+
// the USDZ flow passes the zip-internal directory name without one.
|
|
865
|
+
const base = this.basePath.endsWith( '/' ) ? this.basePath : this.basePath + '/';
|
|
866
|
+
|
|
867
|
+
return LoaderUtils.resolveURL( cleanPath, base );
|
|
868
|
+
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* Resolve a USD reference and return the composed content.
|
|
873
|
+
* @param {string} refValue - Reference value like "@./path/to/file.usdc@"
|
|
874
|
+
* @param {Object} localVariants - Variant selections to apply
|
|
875
|
+
* @returns {Group|null} Composed content or null
|
|
876
|
+
*/
|
|
877
|
+
_resolveReference( refValue, localVariants = {} ) {
|
|
878
|
+
|
|
879
|
+
if ( ! refValue ) return null;
|
|
880
|
+
|
|
881
|
+
const match = refValue.match( /@([^@]+)@(?:<([^>]+)>)?/ );
|
|
882
|
+
if ( ! match ) return null;
|
|
883
|
+
|
|
884
|
+
const filePath = match[ 1 ];
|
|
885
|
+
const primPath = match[ 2 ]; // e.g., "/Geometry"
|
|
886
|
+
|
|
887
|
+
const resolvedPath = this._resolveFilePath( filePath );
|
|
888
|
+
|
|
889
|
+
// Merge variant selections - external takes priority, then local
|
|
890
|
+
const mergedVariants = { ...localVariants, ...this.externalVariantSelections };
|
|
891
|
+
|
|
892
|
+
// Look up pre-parsed data in assets
|
|
893
|
+
const referencedData = this.assets[ resolvedPath ];
|
|
894
|
+
if ( ! referencedData ) return null;
|
|
895
|
+
|
|
896
|
+
// If it's specsByPath data, compose it
|
|
897
|
+
if ( referencedData.specsByPath ) {
|
|
898
|
+
|
|
899
|
+
const composer = new USDComposer( this.manager );
|
|
900
|
+
composer.imageLoader.setCrossOrigin( this.imageLoader.crossOrigin );
|
|
901
|
+
composer.imageLoader.setPriority( this.imageLoader.priority );
|
|
902
|
+
composer.imageLoader.setCache( this.imageLoader.cache );
|
|
903
|
+
const newBasePath = this._getBasePath( resolvedPath );
|
|
904
|
+
const composedGroup = composer.compose( referencedData, this.assets, mergedVariants, newBasePath );
|
|
905
|
+
|
|
906
|
+
// If a primPath is specified, find and return just that subtree
|
|
907
|
+
if ( primPath ) {
|
|
908
|
+
|
|
909
|
+
const primName = primPath.split( '/' ).pop();
|
|
910
|
+
|
|
911
|
+
// Find the direct child with this name (not a deep search)
|
|
912
|
+
// This is important because there may be multiple objects with the same name
|
|
913
|
+
let targetObject = null;
|
|
914
|
+
for ( const child of composedGroup.children ) {
|
|
915
|
+
|
|
916
|
+
if ( child.name === primName ) {
|
|
917
|
+
|
|
918
|
+
targetObject = child;
|
|
919
|
+
break;
|
|
920
|
+
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
if ( targetObject ) {
|
|
926
|
+
|
|
927
|
+
// Detach from parent for re-parenting
|
|
928
|
+
composedGroup.remove( targetObject );
|
|
929
|
+
|
|
930
|
+
// Wrap in a group to maintain consistent return type
|
|
931
|
+
const wrapper = new Group();
|
|
932
|
+
wrapper.add( targetObject );
|
|
933
|
+
return wrapper;
|
|
934
|
+
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
return composedGroup;
|
|
940
|
+
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
// If it's already a Three.js Group (legacy support), clone it
|
|
944
|
+
if ( referencedData.isGroup || referencedData.isObject3D ) {
|
|
945
|
+
|
|
946
|
+
return referencedData.clone();
|
|
947
|
+
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
return null;
|
|
951
|
+
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* Find a single mesh in the group's shallow hierarchy.
|
|
956
|
+
* Only returns a mesh if it's at depth 0 or 1, not deeply nested.
|
|
957
|
+
* This preserves transforms in complex hierarchies like Kitchen Set
|
|
958
|
+
* while supporting USDZExporter round-trip (Xform > Xform > Mesh pattern).
|
|
959
|
+
*/
|
|
960
|
+
_findSingleMesh( group ) {
|
|
961
|
+
|
|
962
|
+
// Check direct children first
|
|
963
|
+
for ( const child of group.children ) {
|
|
964
|
+
|
|
965
|
+
if ( child.isMesh ) {
|
|
966
|
+
|
|
967
|
+
group.remove( child );
|
|
968
|
+
return child;
|
|
969
|
+
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
// Check grandchildren (USDZExporter pattern: Xform > Geometry > Mesh)
|
|
975
|
+
// Only if there's exactly one child with exactly one grandchild
|
|
976
|
+
if ( group.children.length === 1 ) {
|
|
977
|
+
|
|
978
|
+
const child = group.children[ 0 ];
|
|
979
|
+
|
|
980
|
+
if ( child.children && child.children.length === 1 ) {
|
|
981
|
+
|
|
982
|
+
const grandchild = child.children[ 0 ];
|
|
983
|
+
|
|
984
|
+
if ( grandchild.isMesh && ! this._hasNonIdentityTransform( child ) ) {
|
|
985
|
+
|
|
986
|
+
// Safe to merge - intermediate has identity transform
|
|
987
|
+
child.remove( grandchild );
|
|
988
|
+
return grandchild;
|
|
989
|
+
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
return null;
|
|
997
|
+
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* Check if an object has a non-identity local transform.
|
|
1002
|
+
*/
|
|
1003
|
+
_hasNonIdentityTransform( obj ) {
|
|
1004
|
+
|
|
1005
|
+
const pos = obj.position;
|
|
1006
|
+
const rot = obj.rotation;
|
|
1007
|
+
const scale = obj.scale;
|
|
1008
|
+
|
|
1009
|
+
const hasPosition = pos.x !== 0 || pos.y !== 0 || pos.z !== 0;
|
|
1010
|
+
const hasRotation = rot.x !== 0 || rot.y !== 0 || rot.z !== 0;
|
|
1011
|
+
const hasScale = scale.x !== 1 || scale.y !== 1 || scale.z !== 1;
|
|
1012
|
+
|
|
1013
|
+
return hasPosition || hasRotation || hasScale;
|
|
1014
|
+
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
/**
|
|
1018
|
+
* Get the base path (directory) from a file path.
|
|
1019
|
+
*/
|
|
1020
|
+
_getBasePath( filePath ) {
|
|
1021
|
+
|
|
1022
|
+
const lastSlash = filePath.lastIndexOf( '/' );
|
|
1023
|
+
return lastSlash >= 0 ? filePath.slice( 0, lastSlash ) : '';
|
|
1024
|
+
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
/**
|
|
1028
|
+
* Extract variant selections from a spec's fields.
|
|
1029
|
+
*/
|
|
1030
|
+
_getLocalVariantSelections( fields ) {
|
|
1031
|
+
|
|
1032
|
+
const variants = {};
|
|
1033
|
+
|
|
1034
|
+
if ( fields.variantSelection ) {
|
|
1035
|
+
|
|
1036
|
+
for ( const key in fields.variantSelection ) {
|
|
1037
|
+
|
|
1038
|
+
variants[ key ] = fields.variantSelection[ key ];
|
|
1039
|
+
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
return variants;
|
|
1045
|
+
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
/**
|
|
1049
|
+
* Get all reference values from a prim spec.
|
|
1050
|
+
* @returns {string[]} Array of reference strings like "@path@" or "@path@<prim>"
|
|
1051
|
+
*/
|
|
1052
|
+
_getReferences( spec ) {
|
|
1053
|
+
|
|
1054
|
+
const results = [];
|
|
1055
|
+
|
|
1056
|
+
if ( spec.fields.references && spec.fields.references.length > 0 ) {
|
|
1057
|
+
|
|
1058
|
+
const ref = spec.fields.references[ 0 ];
|
|
1059
|
+
|
|
1060
|
+
if ( typeof ref === 'string' ) {
|
|
1061
|
+
|
|
1062
|
+
// Extract all @...@ references (handles both single and array values)
|
|
1063
|
+
const matches = ref.matchAll( /@([^@]+)@(?:<([^>]+)>)?/g );
|
|
1064
|
+
for ( const match of matches ) {
|
|
1065
|
+
|
|
1066
|
+
results.push( match[ 0 ] );
|
|
1067
|
+
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
} else if ( ref.assetPath ) {
|
|
1071
|
+
|
|
1072
|
+
results.push( '@' + ref.assetPath + '@' );
|
|
1073
|
+
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
if ( results.length === 0 && spec.fields.payload ) {
|
|
1079
|
+
|
|
1080
|
+
const payload = spec.fields.payload;
|
|
1081
|
+
if ( typeof payload === 'string' ) results.push( payload );
|
|
1082
|
+
else if ( payload.assetPath ) results.push( '@' + payload.assetPath + '@' );
|
|
1083
|
+
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
return results;
|
|
1087
|
+
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* Resolve an attribute's authored value, following connections before using
|
|
1092
|
+
* local fallback values.
|
|
1093
|
+
*/
|
|
1094
|
+
_resolveAttributeValue( path, visited = new Set() ) {
|
|
1095
|
+
|
|
1096
|
+
const cleanPath = String( path ).replace( /<|>/g, '' );
|
|
1097
|
+
if ( visited.has( cleanPath ) ) return undefined;
|
|
1098
|
+
|
|
1099
|
+
const fields = this.specsByPath[ cleanPath ]?.fields;
|
|
1100
|
+
if ( ! fields ) return undefined;
|
|
1101
|
+
|
|
1102
|
+
const nextVisited = new Set( visited );
|
|
1103
|
+
nextVisited.add( cleanPath );
|
|
1104
|
+
|
|
1105
|
+
if ( fields.connectionPaths ) {
|
|
1106
|
+
|
|
1107
|
+
for ( const connectionPath of fields.connectionPaths ) {
|
|
1108
|
+
|
|
1109
|
+
const value = this._resolveAttributeValue( connectionPath, nextVisited );
|
|
1110
|
+
if ( value !== undefined ) return value;
|
|
1111
|
+
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
if ( fields.default !== undefined ) return fields.default;
|
|
1117
|
+
|
|
1118
|
+
const { times, values } = fields.timeSamples || {};
|
|
1119
|
+
if ( times && values && times.length > 0 ) {
|
|
1120
|
+
|
|
1121
|
+
// Find time 0, or use the first available time (rest pose).
|
|
1122
|
+
const index = times.indexOf( 0 );
|
|
1123
|
+
return values[ index >= 0 ? index : 0 ];
|
|
1124
|
+
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
return undefined;
|
|
1128
|
+
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
/**
|
|
1132
|
+
* Get attributes for a path from attribute specs.
|
|
1133
|
+
*/
|
|
1134
|
+
_getAttributes( path ) {
|
|
1135
|
+
|
|
1136
|
+
const attrs = {};
|
|
1137
|
+
|
|
1138
|
+
this._collectAttributesFromPath( path, attrs );
|
|
1139
|
+
|
|
1140
|
+
// Collect overrides from sibling variants (when path is inside a variant)
|
|
1141
|
+
const variantMatch = path.match( VARIANT_PATH_REGEX );
|
|
1142
|
+
if ( variantMatch ) {
|
|
1143
|
+
|
|
1144
|
+
const basePath = variantMatch[ 1 ];
|
|
1145
|
+
const relativePath = variantMatch[ 4 ];
|
|
1146
|
+
const variantPaths = this._getVariantPaths( basePath );
|
|
1147
|
+
|
|
1148
|
+
for ( const vp of variantPaths ) {
|
|
1149
|
+
|
|
1150
|
+
if ( path.startsWith( vp ) ) continue;
|
|
1151
|
+
|
|
1152
|
+
const overridePath = vp + '/' + relativePath;
|
|
1153
|
+
this._collectAttributesFromPath( overridePath, attrs );
|
|
1154
|
+
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
} else {
|
|
1158
|
+
|
|
1159
|
+
// Check for variant overrides at ancestor levels
|
|
1160
|
+
const parts = path.split( '/' );
|
|
1161
|
+
for ( let i = 1; i < parts.length - 1; i ++ ) {
|
|
1162
|
+
|
|
1163
|
+
const ancestorPath = parts.slice( 0, i + 1 ).join( '/' );
|
|
1164
|
+
const relativePath = parts.slice( i + 1 ).join( '/' );
|
|
1165
|
+
const variantPaths = this._getVariantPaths( ancestorPath );
|
|
1166
|
+
|
|
1167
|
+
for ( const vp of variantPaths ) {
|
|
1168
|
+
|
|
1169
|
+
const overridePath = vp + '/' + relativePath;
|
|
1170
|
+
this._collectAttributesFromPath( overridePath, attrs );
|
|
1171
|
+
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
return attrs;
|
|
1179
|
+
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
_collectAttributesFromPath( path, attrs ) {
|
|
1183
|
+
|
|
1184
|
+
// Use the attribute index for O(1) lookup instead of O(n) iteration
|
|
1185
|
+
const attrMap = this.attributesByPrimPath.get( path );
|
|
1186
|
+
|
|
1187
|
+
if ( ! attrMap ) return;
|
|
1188
|
+
|
|
1189
|
+
for ( const [ attrName, attrSpec ] of attrMap ) {
|
|
1190
|
+
|
|
1191
|
+
const value = this._resolveAttributeValue( path + '.' + attrName );
|
|
1192
|
+
if ( value !== undefined ) {
|
|
1193
|
+
|
|
1194
|
+
attrs[ attrName ] = value;
|
|
1195
|
+
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
if ( attrSpec.fields?.elementSize !== undefined ) {
|
|
1199
|
+
|
|
1200
|
+
attrs[ attrName + ':elementSize' ] = attrSpec.fields.elementSize;
|
|
1201
|
+
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
if ( attrName.startsWith( 'primvars:' ) && attrSpec.fields?.typeName !== undefined ) {
|
|
1205
|
+
|
|
1206
|
+
attrs[ attrName + ':typeName' ] = attrSpec.fields.typeName;
|
|
1207
|
+
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
/**
|
|
1215
|
+
* Build a mesh from a USD geometric primitive (Cube, Sphere, Cylinder, Cone, Capsule).
|
|
1216
|
+
*/
|
|
1217
|
+
_buildGeomPrimitive( path, spec, typeName ) {
|
|
1218
|
+
|
|
1219
|
+
const attrs = this._getAttributes( path );
|
|
1220
|
+
const name = path.split( '/' ).pop();
|
|
1221
|
+
|
|
1222
|
+
let geometry;
|
|
1223
|
+
|
|
1224
|
+
switch ( typeName ) {
|
|
1225
|
+
|
|
1226
|
+
case 'Cube': {
|
|
1227
|
+
|
|
1228
|
+
const size = attrs[ 'size' ] || 2;
|
|
1229
|
+
geometry = new BoxGeometry( size, size, size );
|
|
1230
|
+
break;
|
|
1231
|
+
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
case 'Sphere': {
|
|
1235
|
+
|
|
1236
|
+
const radius = attrs[ 'radius' ] || 1;
|
|
1237
|
+
geometry = new SphereGeometry( radius, 32, 16 );
|
|
1238
|
+
break;
|
|
1239
|
+
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
case 'Cylinder': {
|
|
1243
|
+
|
|
1244
|
+
const height = attrs[ 'height' ] || 2;
|
|
1245
|
+
const radius = attrs[ 'radius' ] || 1;
|
|
1246
|
+
geometry = new CylinderGeometry( radius, radius, height, 32 );
|
|
1247
|
+
break;
|
|
1248
|
+
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
case 'Cone': {
|
|
1252
|
+
|
|
1253
|
+
const height = attrs[ 'height' ] || 2;
|
|
1254
|
+
const radius = attrs[ 'radius' ] || 1;
|
|
1255
|
+
geometry = new ConeGeometry( radius, height, 32 );
|
|
1256
|
+
break;
|
|
1257
|
+
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
case 'Capsule': {
|
|
1261
|
+
|
|
1262
|
+
const height = attrs[ 'height' ] || 1;
|
|
1263
|
+
const radius = attrs[ 'radius' ] || 0.5;
|
|
1264
|
+
geometry = new CapsuleGeometry( radius, height, 16, 32 );
|
|
1265
|
+
break;
|
|
1266
|
+
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
// USD defaults axis to "Z", Three.js uses Y
|
|
1272
|
+
const axis = attrs[ 'axis' ] || 'Z';
|
|
1273
|
+
|
|
1274
|
+
if ( axis === 'X' ) {
|
|
1275
|
+
|
|
1276
|
+
geometry.rotateZ( - Math.PI / 2 );
|
|
1277
|
+
|
|
1278
|
+
} else if ( axis === 'Z' ) {
|
|
1279
|
+
|
|
1280
|
+
geometry.rotateX( Math.PI / 2 );
|
|
1281
|
+
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
const material = this._buildMaterial( path, spec.fields );
|
|
1285
|
+
const mesh = new Mesh( geometry, material );
|
|
1286
|
+
mesh.name = name;
|
|
1287
|
+
|
|
1288
|
+
this.applyTransform( mesh, spec.fields, attrs );
|
|
1289
|
+
|
|
1290
|
+
return mesh;
|
|
1291
|
+
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
/**
|
|
1295
|
+
* Build a mesh from a Mesh spec.
|
|
1296
|
+
*/
|
|
1297
|
+
_buildMesh( path, spec ) {
|
|
1298
|
+
|
|
1299
|
+
const attrs = this._getAttributes( path );
|
|
1300
|
+
|
|
1301
|
+
// Check for skinning data
|
|
1302
|
+
const jointIndices = attrs[ 'primvars:skel:jointIndices' ];
|
|
1303
|
+
const jointWeights = attrs[ 'primvars:skel:jointWeights' ];
|
|
1304
|
+
const hasSkinning = jointIndices && jointWeights &&
|
|
1305
|
+
jointIndices.length > 0 && jointWeights.length > 0;
|
|
1306
|
+
|
|
1307
|
+
// Collect GeomSubsets for multi-material support
|
|
1308
|
+
const geomSubsets = this._getGeomSubsets( path );
|
|
1309
|
+
|
|
1310
|
+
let geometry, material;
|
|
1311
|
+
|
|
1312
|
+
if ( geomSubsets.length > 0 ) {
|
|
1313
|
+
|
|
1314
|
+
geometry = this._buildGeometryWithSubsets( attrs, geomSubsets, hasSkinning );
|
|
1315
|
+
|
|
1316
|
+
const meshMaterialPath = this._getMaterialPath( path, spec.fields );
|
|
1317
|
+
|
|
1318
|
+
material = geomSubsets.map( subset => {
|
|
1319
|
+
|
|
1320
|
+
const matPath = subset.materialPath || meshMaterialPath;
|
|
1321
|
+
return this._buildMaterialForPath( matPath );
|
|
1322
|
+
|
|
1323
|
+
} );
|
|
1324
|
+
|
|
1325
|
+
} else {
|
|
1326
|
+
|
|
1327
|
+
geometry = this._buildGeometry( path, attrs, hasSkinning );
|
|
1328
|
+
material = this._buildMaterial( path, spec.fields );
|
|
1329
|
+
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
const displayColor = attrs[ 'primvars:displayColor' ];
|
|
1333
|
+
if ( displayColor && displayColor.length >= 3 ) {
|
|
1334
|
+
|
|
1335
|
+
const applyDisplayColor = ( mat ) => {
|
|
1336
|
+
|
|
1337
|
+
if ( mat.color && mat.color.r === 1 && mat.color.g === 1 && mat.color.b === 1 && ! mat.map ) {
|
|
1338
|
+
|
|
1339
|
+
mat.color.setRGB( displayColor[ 0 ], displayColor[ 1 ], displayColor[ 2 ], LinearSRGBColorSpace );
|
|
1340
|
+
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
};
|
|
1344
|
+
|
|
1345
|
+
if ( Array.isArray( material ) ) {
|
|
1346
|
+
|
|
1347
|
+
material.forEach( applyDisplayColor );
|
|
1348
|
+
|
|
1349
|
+
} else {
|
|
1350
|
+
|
|
1351
|
+
applyDisplayColor( material );
|
|
1352
|
+
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
const displayOpacity = attrs[ 'primvars:displayOpacity' ];
|
|
1358
|
+
if ( displayOpacity && displayOpacity.length === 1 && geomSubsets.length === 0 ) {
|
|
1359
|
+
|
|
1360
|
+
const opacity = displayOpacity[ 0 ];
|
|
1361
|
+
|
|
1362
|
+
const applyDisplayOpacity = ( mat ) => {
|
|
1363
|
+
|
|
1364
|
+
if ( opacity < 1 && mat.opacity === 1 && mat.transparent === false ) {
|
|
1365
|
+
|
|
1366
|
+
mat.opacity = opacity;
|
|
1367
|
+
mat.transparent = true;
|
|
1368
|
+
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
};
|
|
1372
|
+
|
|
1373
|
+
if ( Array.isArray( material ) ) {
|
|
1374
|
+
|
|
1375
|
+
material.forEach( applyDisplayOpacity );
|
|
1376
|
+
|
|
1377
|
+
} else {
|
|
1378
|
+
|
|
1379
|
+
applyDisplayOpacity( material );
|
|
1380
|
+
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
let mesh;
|
|
1386
|
+
|
|
1387
|
+
if ( hasSkinning ) {
|
|
1388
|
+
|
|
1389
|
+
mesh = new SkinnedMesh( geometry, material );
|
|
1390
|
+
|
|
1391
|
+
// Find skeleton path from skel:skeleton relationship
|
|
1392
|
+
let skelBindingSpec = this.specsByPath[ path + '.skel:skeleton' ];
|
|
1393
|
+
if ( ! skelBindingSpec ) {
|
|
1394
|
+
|
|
1395
|
+
skelBindingSpec = this.specsByPath[ path + '.rel skel:skeleton' ];
|
|
1396
|
+
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
let skeletonPath = null;
|
|
1400
|
+
|
|
1401
|
+
if ( skelBindingSpec ) {
|
|
1402
|
+
|
|
1403
|
+
if ( skelBindingSpec.fields.targetPaths && skelBindingSpec.fields.targetPaths.length > 0 ) {
|
|
1404
|
+
|
|
1405
|
+
skeletonPath = skelBindingSpec.fields.targetPaths[ 0 ];
|
|
1406
|
+
|
|
1407
|
+
} else if ( skelBindingSpec.fields.default ) {
|
|
1408
|
+
|
|
1409
|
+
skeletonPath = skelBindingSpec.fields.default.replace( /<|>/g, '' );
|
|
1410
|
+
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
// Get per-mesh joint mapping
|
|
1416
|
+
const localJoints = attrs[ 'skel:joints' ];
|
|
1417
|
+
|
|
1418
|
+
// Get geomBindTransform if present
|
|
1419
|
+
const geomBindTransform = attrs[ 'primvars:skel:geomBindTransform' ];
|
|
1420
|
+
|
|
1421
|
+
this.skinnedMeshes.push( { mesh, skeletonPath, path, localJoints, geomBindTransform } );
|
|
1422
|
+
|
|
1423
|
+
} else {
|
|
1424
|
+
|
|
1425
|
+
mesh = new Mesh( geometry, material );
|
|
1426
|
+
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
mesh.name = path.split( '/' ).pop();
|
|
1430
|
+
this.applyTransform( mesh, spec.fields, attrs );
|
|
1431
|
+
|
|
1432
|
+
return mesh;
|
|
1433
|
+
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
/**
|
|
1437
|
+
* Build a camera from a Camera spec.
|
|
1438
|
+
*/
|
|
1439
|
+
_buildCamera( path ) {
|
|
1440
|
+
|
|
1441
|
+
const attrs = this._getAttributes( path );
|
|
1442
|
+
const projectionToken = attrs[ 'projection' ];
|
|
1443
|
+
const projection = typeof projectionToken === 'string'
|
|
1444
|
+
? projectionToken.toLowerCase()
|
|
1445
|
+
: USD_CAMERA_DEFAULTS.projection;
|
|
1446
|
+
const clippingRange = attrs[ 'clippingRange' ] || USD_CAMERA_DEFAULTS.clippingRange;
|
|
1447
|
+
const near = Math.max(
|
|
1448
|
+
Number.EPSILON,
|
|
1449
|
+
this._parseNumber( clippingRange[ 0 ], USD_CAMERA_DEFAULTS.clippingRange[ 0 ] )
|
|
1450
|
+
);
|
|
1451
|
+
const far = Math.max(
|
|
1452
|
+
near + Number.EPSILON,
|
|
1453
|
+
this._parseNumber( clippingRange[ 1 ], USD_CAMERA_DEFAULTS.clippingRange[ 1 ] )
|
|
1454
|
+
);
|
|
1455
|
+
const horizontalAperture = this._parseNumber(
|
|
1456
|
+
attrs[ 'horizontalAperture' ],
|
|
1457
|
+
USD_CAMERA_DEFAULTS.horizontalAperture
|
|
1458
|
+
);
|
|
1459
|
+
const verticalAperture = this._parseNumber(
|
|
1460
|
+
attrs[ 'verticalAperture' ],
|
|
1461
|
+
USD_CAMERA_DEFAULTS.verticalAperture
|
|
1462
|
+
);
|
|
1463
|
+
const horizontalApertureOffset = this._parseNumber(
|
|
1464
|
+
attrs[ 'horizontalApertureOffset' ],
|
|
1465
|
+
USD_CAMERA_DEFAULTS.horizontalApertureOffset
|
|
1466
|
+
);
|
|
1467
|
+
const verticalApertureOffset = this._parseNumber(
|
|
1468
|
+
attrs[ 'verticalApertureOffset' ],
|
|
1469
|
+
USD_CAMERA_DEFAULTS.verticalApertureOffset
|
|
1470
|
+
);
|
|
1471
|
+
const focalLength = this._parseNumber( attrs[ 'focalLength' ], USD_CAMERA_DEFAULTS.focalLength );
|
|
1472
|
+
const focusDistance = this._parseNumber( attrs[ 'focusDistance' ], USD_CAMERA_DEFAULTS.focusDistance );
|
|
1473
|
+
const fStop = this._parseNumber( attrs[ 'fStop' ], USD_CAMERA_DEFAULTS.fStop );
|
|
1474
|
+
|
|
1475
|
+
let camera;
|
|
1476
|
+
|
|
1477
|
+
if ( projection === 'orthographic' ) {
|
|
1478
|
+
|
|
1479
|
+
// USD orthographic apertures are in tenths of a world unit.
|
|
1480
|
+
const width = horizontalAperture / 10;
|
|
1481
|
+
const height = verticalAperture / 10;
|
|
1482
|
+
const offsetX = horizontalApertureOffset / 10;
|
|
1483
|
+
const offsetY = verticalApertureOffset / 10;
|
|
1484
|
+
|
|
1485
|
+
camera = new OrthographicCamera(
|
|
1486
|
+
offsetX - width * 0.5,
|
|
1487
|
+
offsetX + width * 0.5,
|
|
1488
|
+
offsetY + height * 0.5,
|
|
1489
|
+
offsetY - height * 0.5,
|
|
1490
|
+
near,
|
|
1491
|
+
far
|
|
1492
|
+
);
|
|
1493
|
+
|
|
1494
|
+
} else {
|
|
1495
|
+
|
|
1496
|
+
const safeVerticalAperture = Math.max( Number.EPSILON, verticalAperture );
|
|
1497
|
+
const safeFocalLength = Math.max( Number.EPSILON, focalLength );
|
|
1498
|
+
const aspect = horizontalAperture / safeVerticalAperture;
|
|
1499
|
+
const fov = 2 * Math.atan( safeVerticalAperture / ( 2 * safeFocalLength ) ) * 180 / Math.PI;
|
|
1500
|
+
|
|
1501
|
+
camera = new PerspectiveCamera( fov, aspect, near, far );
|
|
1502
|
+
camera.filmGauge = Math.max( horizontalAperture, verticalAperture );
|
|
1503
|
+
camera.filmOffset = horizontalApertureOffset;
|
|
1504
|
+
camera.focus = focusDistance;
|
|
1505
|
+
camera.setFocalLength( safeFocalLength );
|
|
1506
|
+
|
|
1507
|
+
if ( verticalApertureOffset !== 0 ) {
|
|
1508
|
+
|
|
1509
|
+
// Three.js supports only horizontal film offset directly.
|
|
1510
|
+
camera.userData.verticalApertureOffset = verticalApertureOffset;
|
|
1511
|
+
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
camera.userData.fStop = fStop;
|
|
1517
|
+
camera.userData.usdProjection = projection;
|
|
1518
|
+
return camera;
|
|
1519
|
+
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
/**
|
|
1523
|
+
* Build a light from a UsdLux light spec.
|
|
1524
|
+
*/
|
|
1525
|
+
_buildLight( path, typeName ) {
|
|
1526
|
+
|
|
1527
|
+
const attrs = this._getAttributes( path );
|
|
1528
|
+
|
|
1529
|
+
const intensity = this._parseNumber( attrs[ 'inputs:intensity' ], 1 );
|
|
1530
|
+
const baseColor = attrs[ 'inputs:color' ] || [ 1, 1, 1 ];
|
|
1531
|
+
const enableColorTemperature = attrs[ 'inputs:enableColorTemperature' ] === true;
|
|
1532
|
+
const colorTemperature = this._parseNumber( attrs[ 'inputs:colorTemperature' ], 6500 );
|
|
1533
|
+
|
|
1534
|
+
const color = new Color( baseColor[ 0 ], baseColor[ 1 ], baseColor[ 2 ] );
|
|
1535
|
+
|
|
1536
|
+
if ( enableColorTemperature ) {
|
|
1537
|
+
|
|
1538
|
+
const temp = this._colorTemperature( colorTemperature );
|
|
1539
|
+
color.multiply( temp );
|
|
1540
|
+
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
let light;
|
|
1544
|
+
|
|
1545
|
+
switch ( typeName ) {
|
|
1546
|
+
|
|
1547
|
+
case 'DistantLight':
|
|
1548
|
+
light = new DirectionalLight( color, intensity );
|
|
1549
|
+
break;
|
|
1550
|
+
|
|
1551
|
+
case 'SphereLight': {
|
|
1552
|
+
|
|
1553
|
+
const coneAngle = this._parseNumber( attrs[ 'shaping:cone:angle' ], 0 );
|
|
1554
|
+
|
|
1555
|
+
if ( coneAngle > 0 ) {
|
|
1556
|
+
|
|
1557
|
+
const angle = coneAngle * Math.PI / 180;
|
|
1558
|
+
const softness = this._parseNumber( attrs[ 'shaping:cone:softness' ], 0 );
|
|
1559
|
+
light = new SpotLight( color, intensity, 0, angle, softness );
|
|
1560
|
+
|
|
1561
|
+
} else {
|
|
1562
|
+
|
|
1563
|
+
light = new PointLight( color, intensity );
|
|
1564
|
+
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
break;
|
|
1568
|
+
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
case 'RectLight': {
|
|
1572
|
+
|
|
1573
|
+
const width = this._parseNumber( attrs[ 'inputs:width' ], 1 );
|
|
1574
|
+
const height = this._parseNumber( attrs[ 'inputs:height' ], 1 );
|
|
1575
|
+
light = new RectAreaLight( color, intensity, width, height );
|
|
1576
|
+
break;
|
|
1577
|
+
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
case 'DiskLight': {
|
|
1581
|
+
|
|
1582
|
+
const radius = this._parseNumber( attrs[ 'inputs:radius' ], 0.5 );
|
|
1583
|
+
const side = radius * 2;
|
|
1584
|
+
light = new RectAreaLight( color, intensity, side, side );
|
|
1585
|
+
break;
|
|
1586
|
+
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
return light;
|
|
1592
|
+
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
/**
|
|
1596
|
+
* Convert a color temperature in Kelvin to an RGB Color.
|
|
1597
|
+
* Based on Tanner Helland's algorithm.
|
|
1598
|
+
*/
|
|
1599
|
+
_colorTemperature( kelvin ) {
|
|
1600
|
+
|
|
1601
|
+
const temp = kelvin / 100;
|
|
1602
|
+
let r, g, b;
|
|
1603
|
+
|
|
1604
|
+
if ( temp <= 66 ) {
|
|
1605
|
+
|
|
1606
|
+
r = 1;
|
|
1607
|
+
g = 0.39008157876901960784 * Math.log( temp ) - 0.63184144378862745098;
|
|
1608
|
+
|
|
1609
|
+
} else {
|
|
1610
|
+
|
|
1611
|
+
r = 1.29293618606274509804 * Math.pow( temp - 60, - 0.1332047592 );
|
|
1612
|
+
g = 1.12989086089529411765 * Math.pow( temp - 60, - 0.0755148492 );
|
|
1613
|
+
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
if ( temp >= 66 ) {
|
|
1617
|
+
|
|
1618
|
+
b = 1;
|
|
1619
|
+
|
|
1620
|
+
} else if ( temp <= 19 ) {
|
|
1621
|
+
|
|
1622
|
+
b = 0;
|
|
1623
|
+
|
|
1624
|
+
} else {
|
|
1625
|
+
|
|
1626
|
+
b = 0.54320678911019607843 * Math.log( temp - 10 ) - 1.19625408914;
|
|
1627
|
+
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
return new Color(
|
|
1631
|
+
Math.min( Math.max( r, 0 ), 1 ),
|
|
1632
|
+
Math.min( Math.max( g, 0 ), 1 ),
|
|
1633
|
+
Math.min( Math.max( b, 0 ), 1 )
|
|
1634
|
+
);
|
|
1635
|
+
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
_parseNumber( value, fallback ) {
|
|
1639
|
+
|
|
1640
|
+
const n = Number( value );
|
|
1641
|
+
return Number.isFinite( n ) ? n : fallback;
|
|
1642
|
+
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
_getGeomSubsets( meshPath ) {
|
|
1646
|
+
|
|
1647
|
+
const subsets = [];
|
|
1648
|
+
const subsetPaths = this.geomSubsetsByMeshPath.get( meshPath );
|
|
1649
|
+
if ( ! subsetPaths ) return subsets;
|
|
1650
|
+
|
|
1651
|
+
for ( const p of subsetPaths ) {
|
|
1652
|
+
|
|
1653
|
+
const attrs = this._getAttributes( p );
|
|
1654
|
+
const indices = attrs[ 'indices' ];
|
|
1655
|
+
if ( ! indices || indices.length === 0 ) continue;
|
|
1656
|
+
|
|
1657
|
+
// Get material binding - check direct path and variant paths
|
|
1658
|
+
const materialPath = this._getMaterialBindingTarget( p );
|
|
1659
|
+
|
|
1660
|
+
subsets.push( {
|
|
1661
|
+
name: p.split( '/' ).pop(),
|
|
1662
|
+
indices: indices,
|
|
1663
|
+
materialPath: materialPath
|
|
1664
|
+
} );
|
|
1665
|
+
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
return subsets;
|
|
1669
|
+
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
/**
|
|
1673
|
+
* Get the material binding relationship for a prim, including overrides from
|
|
1674
|
+
* active variants.
|
|
1675
|
+
*/
|
|
1676
|
+
_getMaterialBindingSpec( primPath ) {
|
|
1677
|
+
|
|
1678
|
+
const attrName = 'material:binding';
|
|
1679
|
+
const directPath = primPath + '.' + attrName;
|
|
1680
|
+
let bindingSpec = this.specsByPath[ directPath ] || null;
|
|
1681
|
+
|
|
1682
|
+
// A variant on any ancestor may override this prim's relationship.
|
|
1683
|
+
const parts = primPath.split( '/' );
|
|
1684
|
+
for ( let i = 1; i < parts.length; i ++ ) {
|
|
1685
|
+
|
|
1686
|
+
const ancestorPath = parts.slice( 0, i + 1 ).join( '/' );
|
|
1687
|
+
const relativePath = parts.slice( i + 1 ).join( '/' );
|
|
1688
|
+
const variantPaths = this._getVariantPaths( ancestorPath );
|
|
1689
|
+
|
|
1690
|
+
for ( const vp of variantPaths ) {
|
|
1691
|
+
|
|
1692
|
+
const overridePath = relativePath ? vp + '/' + relativePath + '.' + attrName : vp + '.' + attrName;
|
|
1693
|
+
const overrideSpec = this.specsByPath[ overridePath ];
|
|
1694
|
+
|
|
1695
|
+
if ( overrideSpec?.fields?.targetPaths?.length > 0 ) {
|
|
1696
|
+
|
|
1697
|
+
bindingSpec = overrideSpec;
|
|
1698
|
+
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
return bindingSpec;
|
|
1706
|
+
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
/**
|
|
1710
|
+
* Get the resolved material binding target for a prim. Material bindings are
|
|
1711
|
+
* inherited, and an ancestor marked strongerThanDescendants takes precedence
|
|
1712
|
+
* over bindings authored on its descendants.
|
|
1713
|
+
*/
|
|
1714
|
+
_getMaterialBindingTarget( primPath ) {
|
|
1715
|
+
|
|
1716
|
+
const parts = primPath.split( '/' ).filter( Boolean );
|
|
1717
|
+
let resolvedBinding = null;
|
|
1718
|
+
|
|
1719
|
+
for ( let i = 0; i < parts.length; i ++ ) {
|
|
1720
|
+
|
|
1721
|
+
const ancestorPath = '/' + parts.slice( 0, i + 1 ).join( '/' );
|
|
1722
|
+
const bindingSpec = this._getMaterialBindingSpec( ancestorPath );
|
|
1723
|
+
if ( ! bindingSpec?.fields?.targetPaths?.length ) continue;
|
|
1724
|
+
|
|
1725
|
+
if ( ! resolvedBinding || resolvedBinding.fields?.bindMaterialAs !== 'strongerThanDescendants' ) {
|
|
1726
|
+
|
|
1727
|
+
resolvedBinding = bindingSpec;
|
|
1728
|
+
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
return resolvedBinding?.fields.targetPaths[ 0 ] || null;
|
|
1734
|
+
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
_buildGeometry( path, fields, hasSkinning = false ) {
|
|
1738
|
+
|
|
1739
|
+
const geometry = new BufferGeometry();
|
|
1740
|
+
|
|
1741
|
+
const points = fields[ 'points' ];
|
|
1742
|
+
if ( ! points || points.length === 0 ) return geometry;
|
|
1743
|
+
|
|
1744
|
+
const faceVertexIndices = fields[ 'faceVertexIndices' ];
|
|
1745
|
+
const faceVertexCounts = fields[ 'faceVertexCounts' ];
|
|
1746
|
+
|
|
1747
|
+
// Parse polygon holes (Arnold format: [holeFaceIdx, parentFaceIdx, ...])
|
|
1748
|
+
const polygonHoles = fields[ 'primvars:arnold:polygon_holes' ];
|
|
1749
|
+
const holeMap = this._buildHoleMap( polygonHoles );
|
|
1750
|
+
|
|
1751
|
+
// Compute triangulation pattern once using actual vertex positions
|
|
1752
|
+
// This pattern will be reused for normals, UVs, etc.
|
|
1753
|
+
let indices = faceVertexIndices;
|
|
1754
|
+
let triPattern = null;
|
|
1755
|
+
|
|
1756
|
+
if ( faceVertexCounts && faceVertexCounts.length > 0 ) {
|
|
1757
|
+
|
|
1758
|
+
const result = this._triangulateIndicesWithPattern( faceVertexIndices, faceVertexCounts, points, holeMap );
|
|
1759
|
+
indices = result.indices;
|
|
1760
|
+
triPattern = result.pattern;
|
|
1761
|
+
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
let positions = points;
|
|
1765
|
+
if ( indices && indices.length > 0 ) {
|
|
1766
|
+
|
|
1767
|
+
positions = this._expandAttribute( points, indices, 3 );
|
|
1768
|
+
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
geometry.setAttribute( 'position', new BufferAttribute( new Float32Array( positions ), 3 ) );
|
|
1772
|
+
|
|
1773
|
+
const normals = fields[ 'normals' ] || fields[ 'primvars:normals' ];
|
|
1774
|
+
const normalIndicesRaw = fields[ 'normals:indices' ] || fields[ 'primvars:normals:indices' ];
|
|
1775
|
+
|
|
1776
|
+
if ( normals && normals.length > 0 ) {
|
|
1777
|
+
|
|
1778
|
+
let normalData = normals;
|
|
1779
|
+
|
|
1780
|
+
if ( normalIndicesRaw && normalIndicesRaw.length > 0 && triPattern ) {
|
|
1781
|
+
|
|
1782
|
+
// Indexed normals - apply triangulation pattern to indices
|
|
1783
|
+
const triangulatedNormalIndices = this._applyTriangulationPattern( normalIndicesRaw, triPattern );
|
|
1784
|
+
normalData = this._expandAttribute( normals, triangulatedNormalIndices, 3 );
|
|
1785
|
+
|
|
1786
|
+
} else if ( normals.length === points.length ) {
|
|
1787
|
+
|
|
1788
|
+
// Per-vertex normals
|
|
1789
|
+
if ( indices && indices.length > 0 ) {
|
|
1790
|
+
|
|
1791
|
+
normalData = this._expandAttribute( normals, indices, 3 );
|
|
1792
|
+
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
} else if ( triPattern ) {
|
|
1796
|
+
|
|
1797
|
+
// Per-face-vertex normals (no separate indices) - use same triangulation pattern
|
|
1798
|
+
const normalIndices = this._applyTriangulationPattern(
|
|
1799
|
+
Array.from( { length: normals.length / 3 }, ( _, i ) => i ),
|
|
1800
|
+
triPattern
|
|
1801
|
+
);
|
|
1802
|
+
normalData = this._expandAttribute( normals, normalIndices, 3 );
|
|
1803
|
+
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
geometry.setAttribute( 'normal', new BufferAttribute( new Float32Array( normalData ), 3 ) );
|
|
1807
|
+
|
|
1808
|
+
} else {
|
|
1809
|
+
|
|
1810
|
+
// Compute vertex normals from the original indexed topology where
|
|
1811
|
+
// vertices are shared, then expand them like positions.
|
|
1812
|
+
const vertexNormals = this._computeVertexNormals( points, indices );
|
|
1813
|
+
geometry.setAttribute( 'normal', new BufferAttribute( new Float32Array(
|
|
1814
|
+
this._expandAttribute( vertexNormals, indices, 3 )
|
|
1815
|
+
), 3 ) );
|
|
1816
|
+
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
const { uvs, uvIndices } = this._findUVPrimvar( fields );
|
|
1820
|
+
const numFaceVertices = faceVertexIndices ? faceVertexIndices.length : 0;
|
|
1821
|
+
|
|
1822
|
+
if ( uvs && uvs.length > 0 ) {
|
|
1823
|
+
|
|
1824
|
+
let uvData = uvs;
|
|
1825
|
+
|
|
1826
|
+
if ( uvIndices && uvIndices.length > 0 && triPattern ) {
|
|
1827
|
+
|
|
1828
|
+
const triangulatedUvIndices = this._applyTriangulationPattern( uvIndices, triPattern );
|
|
1829
|
+
uvData = this._expandAttribute( uvs, triangulatedUvIndices, 2 );
|
|
1830
|
+
|
|
1831
|
+
} else if ( indices && uvs.length / 2 === points.length / 3 ) {
|
|
1832
|
+
|
|
1833
|
+
uvData = this._expandAttribute( uvs, indices, 2 );
|
|
1834
|
+
|
|
1835
|
+
} else if ( triPattern && uvs.length / 2 === numFaceVertices ) {
|
|
1836
|
+
|
|
1837
|
+
// Per-face-vertex UVs (faceVarying, no separate indices)
|
|
1838
|
+
const uvIndicesFromPattern = this._applyTriangulationPattern(
|
|
1839
|
+
Array.from( { length: numFaceVertices }, ( _, i ) => i ),
|
|
1840
|
+
triPattern
|
|
1841
|
+
);
|
|
1842
|
+
uvData = this._expandAttribute( uvs, uvIndicesFromPattern, 2 );
|
|
1843
|
+
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
geometry.setAttribute( 'uv', new BufferAttribute( new Float32Array( uvData ), 2 ) );
|
|
1847
|
+
|
|
1848
|
+
}
|
|
1849
|
+
|
|
1850
|
+
// Second UV set (st1) for lightmaps/AO
|
|
1851
|
+
const { uvs2, uv2Indices } = this._findUV2Primvar( fields );
|
|
1852
|
+
|
|
1853
|
+
if ( uvs2 && uvs2.length > 0 ) {
|
|
1854
|
+
|
|
1855
|
+
let uv2Data = uvs2;
|
|
1856
|
+
|
|
1857
|
+
if ( uv2Indices && uv2Indices.length > 0 && triPattern ) {
|
|
1858
|
+
|
|
1859
|
+
const triangulatedUv2Indices = this._applyTriangulationPattern( uv2Indices, triPattern );
|
|
1860
|
+
uv2Data = this._expandAttribute( uvs2, triangulatedUv2Indices, 2 );
|
|
1861
|
+
|
|
1862
|
+
} else if ( indices && uvs2.length / 2 === points.length / 3 ) {
|
|
1863
|
+
|
|
1864
|
+
uv2Data = this._expandAttribute( uvs2, indices, 2 );
|
|
1865
|
+
|
|
1866
|
+
} else if ( triPattern && uvs2.length / 2 === numFaceVertices ) {
|
|
1867
|
+
|
|
1868
|
+
// Per-face-vertex UV2 (faceVarying, no separate indices)
|
|
1869
|
+
const uv2IndicesFromPattern = this._applyTriangulationPattern(
|
|
1870
|
+
Array.from( { length: numFaceVertices }, ( _, i ) => i ),
|
|
1871
|
+
triPattern
|
|
1872
|
+
);
|
|
1873
|
+
uv2Data = this._expandAttribute( uvs2, uv2IndicesFromPattern, 2 );
|
|
1874
|
+
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
geometry.setAttribute( 'uv1', new BufferAttribute( new Float32Array( uv2Data ), 2 ) );
|
|
1878
|
+
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
// Add skinning attributes
|
|
1882
|
+
if ( hasSkinning ) {
|
|
1883
|
+
|
|
1884
|
+
const jointIndices = fields[ 'primvars:skel:jointIndices' ];
|
|
1885
|
+
const jointWeights = fields[ 'primvars:skel:jointWeights' ];
|
|
1886
|
+
const elementSize = fields[ 'primvars:skel:jointIndices:elementSize' ] || 4;
|
|
1887
|
+
|
|
1888
|
+
if ( jointIndices && jointWeights ) {
|
|
1889
|
+
|
|
1890
|
+
const numVertices = positions.length / 3;
|
|
1891
|
+
|
|
1892
|
+
let skinIndexData, skinWeightData;
|
|
1893
|
+
|
|
1894
|
+
if ( indices && indices.length > 0 ) {
|
|
1895
|
+
|
|
1896
|
+
skinIndexData = this._expandAttribute( jointIndices, indices, elementSize );
|
|
1897
|
+
skinWeightData = this._expandAttribute( jointWeights, indices, elementSize );
|
|
1898
|
+
|
|
1899
|
+
} else {
|
|
1900
|
+
|
|
1901
|
+
skinIndexData = jointIndices;
|
|
1902
|
+
skinWeightData = jointWeights;
|
|
1903
|
+
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1906
|
+
const skinIndices = new Uint16Array( numVertices * 4 );
|
|
1907
|
+
const skinWeights = new Float32Array( numVertices * 4 );
|
|
1908
|
+
|
|
1909
|
+
this._selectTopWeights( skinIndexData, skinWeightData, elementSize, numVertices, skinIndices, skinWeights );
|
|
1910
|
+
|
|
1911
|
+
geometry.setAttribute( 'skinIndex', new BufferAttribute( skinIndices, 4 ) );
|
|
1912
|
+
geometry.setAttribute( 'skinWeight', new BufferAttribute( skinWeights, 4 ) );
|
|
1913
|
+
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
return geometry;
|
|
1919
|
+
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
_buildGeometryWithSubsets( fields, geomSubsets, hasSkinning = false ) {
|
|
1923
|
+
|
|
1924
|
+
const geometry = new BufferGeometry();
|
|
1925
|
+
|
|
1926
|
+
const points = fields[ 'points' ];
|
|
1927
|
+
if ( ! points || points.length === 0 ) return geometry;
|
|
1928
|
+
|
|
1929
|
+
const faceVertexIndices = fields[ 'faceVertexIndices' ];
|
|
1930
|
+
const faceVertexCounts = fields[ 'faceVertexCounts' ];
|
|
1931
|
+
|
|
1932
|
+
if ( ! faceVertexCounts || faceVertexCounts.length === 0 ) return geometry;
|
|
1933
|
+
|
|
1934
|
+
const polygonHoles = fields[ 'primvars:arnold:polygon_holes' ];
|
|
1935
|
+
const holeMap = this._buildHoleMap( polygonHoles );
|
|
1936
|
+
const holeFaces = holeMap.holeFaces;
|
|
1937
|
+
const parentToHoles = holeMap.parentToHoles;
|
|
1938
|
+
|
|
1939
|
+
const { uvs, uvIndices } = this._findUVPrimvar( fields );
|
|
1940
|
+
const { uvs2, uv2Indices } = this._findUV2Primvar( fields );
|
|
1941
|
+
const normals = fields[ 'normals' ] || fields[ 'primvars:normals' ];
|
|
1942
|
+
const normalIndicesRaw = fields[ 'normals:indices' ] || fields[ 'primvars:normals:indices' ];
|
|
1943
|
+
|
|
1944
|
+
const jointIndices = hasSkinning ? fields[ 'primvars:skel:jointIndices' ] : null;
|
|
1945
|
+
const jointWeights = hasSkinning ? fields[ 'primvars:skel:jointWeights' ] : null;
|
|
1946
|
+
const elementSize = fields[ 'primvars:skel:jointIndices:elementSize' ] || 4;
|
|
1947
|
+
|
|
1948
|
+
// Build face-to-triangle mapping (accounting for holes)
|
|
1949
|
+
const faceTriangleOffset = [];
|
|
1950
|
+
let triangleCount = 0;
|
|
1951
|
+
|
|
1952
|
+
for ( let i = 0; i < faceVertexCounts.length; i ++ ) {
|
|
1953
|
+
|
|
1954
|
+
faceTriangleOffset.push( triangleCount );
|
|
1955
|
+
|
|
1956
|
+
// Skip hole faces - they're triangulated with their parent
|
|
1957
|
+
if ( holeFaces.has( i ) ) continue;
|
|
1958
|
+
|
|
1959
|
+
const count = faceVertexCounts[ i ];
|
|
1960
|
+
const holes = parentToHoles.get( i );
|
|
1961
|
+
|
|
1962
|
+
if ( holes && holes.length > 0 ) {
|
|
1963
|
+
|
|
1964
|
+
// For faces with holes, count triangles based on total vertices
|
|
1965
|
+
// Earcut produces (total_vertices - 2) triangles for any polygon including holes
|
|
1966
|
+
let totalVerts = count;
|
|
1967
|
+
for ( const holeIdx of holes ) {
|
|
1968
|
+
|
|
1969
|
+
totalVerts += faceVertexCounts[ holeIdx ];
|
|
1970
|
+
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
triangleCount += totalVerts - 2;
|
|
1974
|
+
|
|
1975
|
+
} else if ( count >= 3 ) {
|
|
1976
|
+
|
|
1977
|
+
triangleCount += count - 2;
|
|
1978
|
+
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
const triangleToSubset = new Int32Array( triangleCount ).fill( - 1 );
|
|
1984
|
+
|
|
1985
|
+
for ( let si = 0; si < geomSubsets.length; si ++ ) {
|
|
1986
|
+
|
|
1987
|
+
const subset = geomSubsets[ si ];
|
|
1988
|
+
|
|
1989
|
+
for ( let i = 0; i < subset.indices.length; i ++ ) {
|
|
1990
|
+
|
|
1991
|
+
const faceIdx = subset.indices[ i ];
|
|
1992
|
+
if ( faceIdx >= faceVertexCounts.length ) continue;
|
|
1993
|
+
|
|
1994
|
+
const triStart = faceTriangleOffset[ faceIdx ];
|
|
1995
|
+
const triCount = faceVertexCounts[ faceIdx ] - 2;
|
|
1996
|
+
|
|
1997
|
+
for ( let t = 0; t < triCount; t ++ ) {
|
|
1998
|
+
|
|
1999
|
+
triangleToSubset[ triStart + t ] = si;
|
|
2000
|
+
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
// Sort triangles by subset
|
|
2008
|
+
const sortedTriangles = [];
|
|
2009
|
+
|
|
2010
|
+
for ( let tri = 0; tri < triangleCount; tri ++ ) {
|
|
2011
|
+
|
|
2012
|
+
sortedTriangles.push( { original: tri, subset: triangleToSubset[ tri ] } );
|
|
2013
|
+
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
sortedTriangles.sort( ( a, b ) => a.subset - b.subset );
|
|
2017
|
+
|
|
2018
|
+
const groups = [];
|
|
2019
|
+
let currentSubset = sortedTriangles.length > 0 ? sortedTriangles[ 0 ].subset : - 1;
|
|
2020
|
+
let groupStart = 0;
|
|
2021
|
+
|
|
2022
|
+
for ( let i = 0; i < sortedTriangles.length; i ++ ) {
|
|
2023
|
+
|
|
2024
|
+
if ( sortedTriangles[ i ].subset !== currentSubset ) {
|
|
2025
|
+
|
|
2026
|
+
if ( currentSubset >= 0 ) {
|
|
2027
|
+
|
|
2028
|
+
groups.push( {
|
|
2029
|
+
start: groupStart * 3,
|
|
2030
|
+
count: ( i - groupStart ) * 3,
|
|
2031
|
+
materialIndex: currentSubset
|
|
2032
|
+
} );
|
|
2033
|
+
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
currentSubset = sortedTriangles[ i ].subset;
|
|
2037
|
+
groupStart = i;
|
|
2038
|
+
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2043
|
+
if ( currentSubset >= 0 && sortedTriangles.length > groupStart ) {
|
|
2044
|
+
|
|
2045
|
+
groups.push( {
|
|
2046
|
+
start: groupStart * 3,
|
|
2047
|
+
count: ( sortedTriangles.length - groupStart ) * 3,
|
|
2048
|
+
materialIndex: currentSubset
|
|
2049
|
+
} );
|
|
2050
|
+
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
for ( const group of groups ) {
|
|
2054
|
+
|
|
2055
|
+
geometry.addGroup( group.start, group.count, group.materialIndex );
|
|
2056
|
+
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
// Triangulate original data using consistent pattern
|
|
2060
|
+
const { indices: origIndices, pattern: triPattern } = this._triangulateIndicesWithPattern( faceVertexIndices, faceVertexCounts, points, holeMap );
|
|
2061
|
+
const numFaceVertices = faceVertexCounts.reduce( ( a, b ) => a + b, 0 );
|
|
2062
|
+
const faceVaryingIdentity = ( uvs && ! uvIndices && uvs.length / 2 === numFaceVertices ) ||
|
|
2063
|
+
( uvs2 && ! uv2Indices && uvs2.length / 2 === numFaceVertices )
|
|
2064
|
+
? this._applyTriangulationPattern( Array.from( { length: numFaceVertices }, ( _, i ) => i ), triPattern )
|
|
2065
|
+
: null;
|
|
2066
|
+
const origUvIndices = uvIndices
|
|
2067
|
+
? this._applyTriangulationPattern( uvIndices, triPattern )
|
|
2068
|
+
: ( uvs && uvs.length / 2 === numFaceVertices ? faceVaryingIdentity : null );
|
|
2069
|
+
const origUv2Indices = uv2Indices
|
|
2070
|
+
? this._applyTriangulationPattern( uv2Indices, triPattern )
|
|
2071
|
+
: ( uvs2 && uvs2.length / 2 === numFaceVertices ? faceVaryingIdentity : null );
|
|
2072
|
+
const hasIndexedNormals = normals && normalIndicesRaw && normalIndicesRaw.length > 0;
|
|
2073
|
+
const hasFaceVaryingNormals = normals && normals.length / 3 === numFaceVertices;
|
|
2074
|
+
const origNormalIndices = hasIndexedNormals
|
|
2075
|
+
? this._applyTriangulationPattern( normalIndicesRaw, triPattern )
|
|
2076
|
+
: ( hasFaceVaryingNormals
|
|
2077
|
+
? this._applyTriangulationPattern( Array.from( { length: numFaceVertices }, ( _, i ) => i ), triPattern )
|
|
2078
|
+
: null );
|
|
2079
|
+
|
|
2080
|
+
// When no normals are provided, compute vertex normals from
|
|
2081
|
+
// the indexed topology so that shared vertices produce averaged normals.
|
|
2082
|
+
const vertexNormals = ( ! normals && origIndices.length > 0 )
|
|
2083
|
+
? this._computeVertexNormals( points, origIndices )
|
|
2084
|
+
: null;
|
|
2085
|
+
|
|
2086
|
+
// Build reordered vertex data
|
|
2087
|
+
const vertexCount = triangleCount * 3;
|
|
2088
|
+
const positions = new Float32Array( vertexCount * 3 );
|
|
2089
|
+
const uvData = uvs ? new Float32Array( vertexCount * 2 ) : null;
|
|
2090
|
+
const uv1Data = uvs2 ? new Float32Array( vertexCount * 2 ) : null;
|
|
2091
|
+
const normalData = ( normals || vertexNormals ) ? new Float32Array( vertexCount * 3 ) : null;
|
|
2092
|
+
const skinSrcIndices = jointIndices ? new Uint16Array( vertexCount * elementSize ) : null;
|
|
2093
|
+
const skinSrcWeights = jointWeights ? new Float32Array( vertexCount * elementSize ) : null;
|
|
2094
|
+
|
|
2095
|
+
for ( let i = 0; i < sortedTriangles.length; i ++ ) {
|
|
2096
|
+
|
|
2097
|
+
const origTri = sortedTriangles[ i ].original;
|
|
2098
|
+
|
|
2099
|
+
for ( let v = 0; v < 3; v ++ ) {
|
|
2100
|
+
|
|
2101
|
+
const origIdx = origTri * 3 + v;
|
|
2102
|
+
const newIdx = i * 3 + v;
|
|
2103
|
+
|
|
2104
|
+
const pointIdx = origIndices[ origIdx ];
|
|
2105
|
+
positions[ newIdx * 3 ] = points[ pointIdx * 3 ];
|
|
2106
|
+
positions[ newIdx * 3 + 1 ] = points[ pointIdx * 3 + 1 ];
|
|
2107
|
+
positions[ newIdx * 3 + 2 ] = points[ pointIdx * 3 + 2 ];
|
|
2108
|
+
|
|
2109
|
+
if ( uvData && uvs ) {
|
|
2110
|
+
|
|
2111
|
+
if ( origUvIndices ) {
|
|
2112
|
+
|
|
2113
|
+
const uvIdx = origUvIndices[ origIdx ];
|
|
2114
|
+
uvData[ newIdx * 2 ] = uvs[ uvIdx * 2 ];
|
|
2115
|
+
uvData[ newIdx * 2 + 1 ] = uvs[ uvIdx * 2 + 1 ];
|
|
2116
|
+
|
|
2117
|
+
} else if ( uvs.length / 2 === points.length / 3 ) {
|
|
2118
|
+
|
|
2119
|
+
uvData[ newIdx * 2 ] = uvs[ pointIdx * 2 ];
|
|
2120
|
+
uvData[ newIdx * 2 + 1 ] = uvs[ pointIdx * 2 + 1 ];
|
|
2121
|
+
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2126
|
+
if ( uv1Data && uvs2 ) {
|
|
2127
|
+
|
|
2128
|
+
if ( origUv2Indices ) {
|
|
2129
|
+
|
|
2130
|
+
const uv2Idx = origUv2Indices[ origIdx ];
|
|
2131
|
+
uv1Data[ newIdx * 2 ] = uvs2[ uv2Idx * 2 ];
|
|
2132
|
+
uv1Data[ newIdx * 2 + 1 ] = uvs2[ uv2Idx * 2 + 1 ];
|
|
2133
|
+
|
|
2134
|
+
} else if ( uvs2.length / 2 === points.length / 3 ) {
|
|
2135
|
+
|
|
2136
|
+
uv1Data[ newIdx * 2 ] = uvs2[ pointIdx * 2 ];
|
|
2137
|
+
uv1Data[ newIdx * 2 + 1 ] = uvs2[ pointIdx * 2 + 1 ];
|
|
2138
|
+
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2141
|
+
}
|
|
2142
|
+
|
|
2143
|
+
if ( normalData ) {
|
|
2144
|
+
|
|
2145
|
+
if ( normals && origNormalIndices ) {
|
|
2146
|
+
|
|
2147
|
+
const normalIdx = origNormalIndices[ origIdx ];
|
|
2148
|
+
normalData[ newIdx * 3 ] = normals[ normalIdx * 3 ];
|
|
2149
|
+
normalData[ newIdx * 3 + 1 ] = normals[ normalIdx * 3 + 1 ];
|
|
2150
|
+
normalData[ newIdx * 3 + 2 ] = normals[ normalIdx * 3 + 2 ];
|
|
2151
|
+
|
|
2152
|
+
} else if ( normals && normals.length === points.length ) {
|
|
2153
|
+
|
|
2154
|
+
normalData[ newIdx * 3 ] = normals[ pointIdx * 3 ];
|
|
2155
|
+
normalData[ newIdx * 3 + 1 ] = normals[ pointIdx * 3 + 1 ];
|
|
2156
|
+
normalData[ newIdx * 3 + 2 ] = normals[ pointIdx * 3 + 2 ];
|
|
2157
|
+
|
|
2158
|
+
} else if ( vertexNormals ) {
|
|
2159
|
+
|
|
2160
|
+
normalData[ newIdx * 3 ] = vertexNormals[ pointIdx * 3 ];
|
|
2161
|
+
normalData[ newIdx * 3 + 1 ] = vertexNormals[ pointIdx * 3 + 1 ];
|
|
2162
|
+
normalData[ newIdx * 3 + 2 ] = vertexNormals[ pointIdx * 3 + 2 ];
|
|
2163
|
+
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
if ( skinSrcIndices && skinSrcWeights && jointIndices && jointWeights ) {
|
|
2169
|
+
|
|
2170
|
+
for ( let j = 0; j < elementSize; j ++ ) {
|
|
2171
|
+
|
|
2172
|
+
skinSrcIndices[ newIdx * elementSize + j ] = jointIndices[ pointIdx * elementSize + j ] || 0;
|
|
2173
|
+
skinSrcWeights[ newIdx * elementSize + j ] = jointWeights[ pointIdx * elementSize + j ] || 0;
|
|
2174
|
+
|
|
2175
|
+
}
|
|
2176
|
+
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2179
|
+
}
|
|
2180
|
+
|
|
2181
|
+
}
|
|
2182
|
+
|
|
2183
|
+
geometry.setAttribute( 'position', new BufferAttribute( positions, 3 ) );
|
|
2184
|
+
|
|
2185
|
+
if ( uvData ) {
|
|
2186
|
+
|
|
2187
|
+
geometry.setAttribute( 'uv', new BufferAttribute( uvData, 2 ) );
|
|
2188
|
+
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
if ( uv1Data ) {
|
|
2192
|
+
|
|
2193
|
+
geometry.setAttribute( 'uv1', new BufferAttribute( uv1Data, 2 ) );
|
|
2194
|
+
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2197
|
+
geometry.setAttribute( 'normal', new BufferAttribute( normalData, 3 ) );
|
|
2198
|
+
|
|
2199
|
+
if ( skinSrcIndices && skinSrcWeights ) {
|
|
2200
|
+
|
|
2201
|
+
const skinIndexData = new Uint16Array( vertexCount * 4 );
|
|
2202
|
+
const skinWeightData = new Float32Array( vertexCount * 4 );
|
|
2203
|
+
|
|
2204
|
+
this._selectTopWeights( skinSrcIndices, skinSrcWeights, elementSize, vertexCount, skinIndexData, skinWeightData );
|
|
2205
|
+
|
|
2206
|
+
geometry.setAttribute( 'skinIndex', new BufferAttribute( skinIndexData, 4 ) );
|
|
2207
|
+
geometry.setAttribute( 'skinWeight', new BufferAttribute( skinWeightData, 4 ) );
|
|
2208
|
+
|
|
2209
|
+
}
|
|
2210
|
+
|
|
2211
|
+
return geometry;
|
|
2212
|
+
|
|
2213
|
+
}
|
|
2214
|
+
|
|
2215
|
+
_selectTopWeights( srcIndices, srcWeights, elementSize, numVertices, dstIndices, dstWeights ) {
|
|
2216
|
+
|
|
2217
|
+
if ( elementSize <= 4 ) {
|
|
2218
|
+
|
|
2219
|
+
for ( let i = 0; i < numVertices; i ++ ) {
|
|
2220
|
+
|
|
2221
|
+
for ( let j = 0; j < 4; j ++ ) {
|
|
2222
|
+
|
|
2223
|
+
if ( j < elementSize ) {
|
|
2224
|
+
|
|
2225
|
+
dstIndices[ i * 4 + j ] = srcIndices[ i * elementSize + j ] || 0;
|
|
2226
|
+
dstWeights[ i * 4 + j ] = srcWeights[ i * elementSize + j ] || 0;
|
|
2227
|
+
|
|
2228
|
+
} else {
|
|
2229
|
+
|
|
2230
|
+
dstIndices[ i * 4 + j ] = 0;
|
|
2231
|
+
dstWeights[ i * 4 + j ] = 0;
|
|
2232
|
+
|
|
2233
|
+
}
|
|
2234
|
+
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
return;
|
|
2240
|
+
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
// When elementSize > 4, find the 4 largest weights per vertex
|
|
2244
|
+
// using a partial selection sort (4 iterations of O(elementSize)).
|
|
2245
|
+
const order = new Uint32Array( elementSize );
|
|
2246
|
+
|
|
2247
|
+
for ( let i = 0; i < numVertices; i ++ ) {
|
|
2248
|
+
|
|
2249
|
+
const base = i * elementSize;
|
|
2250
|
+
|
|
2251
|
+
for ( let j = 0; j < elementSize; j ++ ) order[ j ] = j;
|
|
2252
|
+
|
|
2253
|
+
for ( let k = 0; k < 4; k ++ ) {
|
|
2254
|
+
|
|
2255
|
+
let maxIdx = k;
|
|
2256
|
+
let maxW = srcWeights[ base + order[ k ] ] || 0;
|
|
2257
|
+
|
|
2258
|
+
for ( let j = k + 1; j < elementSize; j ++ ) {
|
|
2259
|
+
|
|
2260
|
+
const w = srcWeights[ base + order[ j ] ] || 0;
|
|
2261
|
+
|
|
2262
|
+
if ( w > maxW ) {
|
|
2263
|
+
|
|
2264
|
+
maxW = w;
|
|
2265
|
+
maxIdx = j;
|
|
2266
|
+
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
}
|
|
2270
|
+
|
|
2271
|
+
if ( maxIdx !== k ) {
|
|
2272
|
+
|
|
2273
|
+
const tmp = order[ k ];
|
|
2274
|
+
order[ k ] = order[ maxIdx ];
|
|
2275
|
+
order[ maxIdx ] = tmp;
|
|
2276
|
+
|
|
2277
|
+
}
|
|
2278
|
+
|
|
2279
|
+
}
|
|
2280
|
+
|
|
2281
|
+
let total = 0;
|
|
2282
|
+
|
|
2283
|
+
for ( let j = 0; j < 4; j ++ ) {
|
|
2284
|
+
|
|
2285
|
+
total += srcWeights[ base + order[ j ] ] || 0;
|
|
2286
|
+
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
for ( let j = 0; j < 4; j ++ ) {
|
|
2290
|
+
|
|
2291
|
+
const s = order[ j ];
|
|
2292
|
+
|
|
2293
|
+
if ( total > 0 ) {
|
|
2294
|
+
|
|
2295
|
+
dstIndices[ i * 4 + j ] = srcIndices[ base + s ] || 0;
|
|
2296
|
+
dstWeights[ i * 4 + j ] = ( srcWeights[ base + s ] || 0 ) / total;
|
|
2297
|
+
|
|
2298
|
+
} else {
|
|
2299
|
+
|
|
2300
|
+
dstIndices[ i * 4 + j ] = 0;
|
|
2301
|
+
dstWeights[ i * 4 + j ] = 0;
|
|
2302
|
+
|
|
2303
|
+
}
|
|
2304
|
+
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
_findUVPrimvar( fields ) {
|
|
2312
|
+
|
|
2313
|
+
for ( const key in fields ) {
|
|
2314
|
+
|
|
2315
|
+
if ( ! key.startsWith( 'primvars:' ) ) continue;
|
|
2316
|
+
if ( key.endsWith( ':typeName' ) || key.endsWith( ':elementSize' ) || key.endsWith( ':indices' ) ) continue;
|
|
2317
|
+
if ( key.includes( 'skel:' ) ) continue;
|
|
2318
|
+
|
|
2319
|
+
const typeName = fields[ key + ':typeName' ];
|
|
2320
|
+
if ( typeName && typeName.includes( 'texCoord' ) ) {
|
|
2321
|
+
|
|
2322
|
+
return {
|
|
2323
|
+
uvs: fields[ key ],
|
|
2324
|
+
uvIndices: fields[ key + ':indices' ]
|
|
2325
|
+
};
|
|
2326
|
+
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2331
|
+
const uvs = fields[ 'primvars:st' ] || fields[ 'primvars:UVMap' ];
|
|
2332
|
+
const uvIndices = fields[ 'primvars:st:indices' ];
|
|
2333
|
+
return { uvs, uvIndices };
|
|
2334
|
+
|
|
2335
|
+
}
|
|
2336
|
+
|
|
2337
|
+
_findUV2Primvar( fields ) {
|
|
2338
|
+
|
|
2339
|
+
const uvs2 = fields[ 'primvars:st1' ];
|
|
2340
|
+
const uv2Indices = fields[ 'primvars:st1:indices' ];
|
|
2341
|
+
return { uvs2, uv2Indices };
|
|
2342
|
+
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2345
|
+
_buildHoleMap( polygonHoles ) {
|
|
2346
|
+
|
|
2347
|
+
// polygonHoles is in Arnold format: [holeFaceIdx, parentFaceIdx, holeFaceIdx, parentFaceIdx, ...]
|
|
2348
|
+
// Returns a map: parentFaceIdx -> [holeFaceIdx1, holeFaceIdx2, ...]
|
|
2349
|
+
// Also returns a set of hole face indices to skip during triangulation
|
|
2350
|
+
if ( ! polygonHoles || polygonHoles.length === 0 ) {
|
|
2351
|
+
|
|
2352
|
+
return { parentToHoles: new Map(), holeFaces: new Set() };
|
|
2353
|
+
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
const parentToHoles = new Map();
|
|
2357
|
+
const holeFaces = new Set();
|
|
2358
|
+
|
|
2359
|
+
for ( let i = 0; i < polygonHoles.length; i += 2 ) {
|
|
2360
|
+
|
|
2361
|
+
const holeFaceIdx = polygonHoles[ i ];
|
|
2362
|
+
const parentFaceIdx = polygonHoles[ i + 1 ];
|
|
2363
|
+
|
|
2364
|
+
holeFaces.add( holeFaceIdx );
|
|
2365
|
+
|
|
2366
|
+
if ( ! parentToHoles.has( parentFaceIdx ) ) {
|
|
2367
|
+
|
|
2368
|
+
parentToHoles.set( parentFaceIdx, [] );
|
|
2369
|
+
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
parentToHoles.get( parentFaceIdx ).push( holeFaceIdx );
|
|
2373
|
+
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
return { parentToHoles, holeFaces };
|
|
2377
|
+
|
|
2378
|
+
}
|
|
2379
|
+
|
|
2380
|
+
_triangulateIndicesWithPattern( indices, counts, points = null, holeMap = null ) {
|
|
2381
|
+
|
|
2382
|
+
const triangulated = [];
|
|
2383
|
+
const pattern = []; // Stores face-local indices for each triangle vertex
|
|
2384
|
+
|
|
2385
|
+
// Build face offset lookup for accessing hole face data
|
|
2386
|
+
const faceOffsets = [];
|
|
2387
|
+
let offsetAccum = 0;
|
|
2388
|
+
for ( let i = 0; i < counts.length; i ++ ) {
|
|
2389
|
+
|
|
2390
|
+
faceOffsets.push( offsetAccum );
|
|
2391
|
+
offsetAccum += counts[ i ];
|
|
2392
|
+
|
|
2393
|
+
}
|
|
2394
|
+
|
|
2395
|
+
const parentToHoles = holeMap?.parentToHoles || new Map();
|
|
2396
|
+
const holeFaces = holeMap?.holeFaces || new Set();
|
|
2397
|
+
|
|
2398
|
+
let offset = 0;
|
|
2399
|
+
|
|
2400
|
+
for ( let i = 0; i < counts.length; i ++ ) {
|
|
2401
|
+
|
|
2402
|
+
const count = counts[ i ];
|
|
2403
|
+
|
|
2404
|
+
// Skip faces that are holes - they will be triangulated with their parent
|
|
2405
|
+
if ( holeFaces.has( i ) ) {
|
|
2406
|
+
|
|
2407
|
+
offset += count;
|
|
2408
|
+
continue;
|
|
2409
|
+
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2412
|
+
// Check if this face has holes
|
|
2413
|
+
const holes = parentToHoles.get( i );
|
|
2414
|
+
|
|
2415
|
+
if ( holes && holes.length > 0 && points && points.length > 0 ) {
|
|
2416
|
+
|
|
2417
|
+
// Triangulate face with holes using vertex -> face-vertex mapping
|
|
2418
|
+
const vertexToFaceVertex = new Map();
|
|
2419
|
+
|
|
2420
|
+
const faceIndices = [];
|
|
2421
|
+
for ( let j = 0; j < count; j ++ ) {
|
|
2422
|
+
|
|
2423
|
+
const vertIdx = indices[ offset + j ];
|
|
2424
|
+
faceIndices.push( vertIdx );
|
|
2425
|
+
vertexToFaceVertex.set( vertIdx, offset + j );
|
|
2426
|
+
|
|
2427
|
+
}
|
|
2428
|
+
|
|
2429
|
+
const holeContours = [];
|
|
2430
|
+
for ( const holeFaceIdx of holes ) {
|
|
2431
|
+
|
|
2432
|
+
const holeOffset = faceOffsets[ holeFaceIdx ];
|
|
2433
|
+
const holeCount = counts[ holeFaceIdx ];
|
|
2434
|
+
const holeIndices = [];
|
|
2435
|
+
for ( let j = 0; j < holeCount; j ++ ) {
|
|
2436
|
+
|
|
2437
|
+
const vertIdx = indices[ holeOffset + j ];
|
|
2438
|
+
holeIndices.push( vertIdx );
|
|
2439
|
+
vertexToFaceVertex.set( vertIdx, holeOffset + j );
|
|
2440
|
+
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
holeContours.push( holeIndices );
|
|
2444
|
+
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
const triangles = this._triangulateNGonWithHoles( faceIndices, holeContours, points );
|
|
2448
|
+
|
|
2449
|
+
for ( const tri of triangles ) {
|
|
2450
|
+
|
|
2451
|
+
triangulated.push( tri[ 0 ], tri[ 1 ], tri[ 2 ] );
|
|
2452
|
+
pattern.push(
|
|
2453
|
+
vertexToFaceVertex.get( tri[ 0 ] ),
|
|
2454
|
+
vertexToFaceVertex.get( tri[ 1 ] ),
|
|
2455
|
+
vertexToFaceVertex.get( tri[ 2 ] )
|
|
2456
|
+
);
|
|
2457
|
+
|
|
2458
|
+
}
|
|
2459
|
+
|
|
2460
|
+
} else if ( count === 3 ) {
|
|
2461
|
+
|
|
2462
|
+
triangulated.push(
|
|
2463
|
+
indices[ offset ],
|
|
2464
|
+
indices[ offset + 1 ],
|
|
2465
|
+
indices[ offset + 2 ]
|
|
2466
|
+
);
|
|
2467
|
+
pattern.push( offset, offset + 1, offset + 2 );
|
|
2468
|
+
|
|
2469
|
+
} else if ( count === 4 ) {
|
|
2470
|
+
|
|
2471
|
+
triangulated.push(
|
|
2472
|
+
indices[ offset ],
|
|
2473
|
+
indices[ offset + 1 ],
|
|
2474
|
+
indices[ offset + 2 ],
|
|
2475
|
+
indices[ offset ],
|
|
2476
|
+
indices[ offset + 2 ],
|
|
2477
|
+
indices[ offset + 3 ]
|
|
2478
|
+
);
|
|
2479
|
+
pattern.push(
|
|
2480
|
+
offset, offset + 1, offset + 2,
|
|
2481
|
+
offset, offset + 2, offset + 3
|
|
2482
|
+
);
|
|
2483
|
+
|
|
2484
|
+
} else if ( count > 4 ) {
|
|
2485
|
+
|
|
2486
|
+
// Use ear-clipping for complex n-gons if we have vertex positions
|
|
2487
|
+
if ( points && points.length > 0 ) {
|
|
2488
|
+
|
|
2489
|
+
const faceIndices = [];
|
|
2490
|
+
for ( let j = 0; j < count; j ++ ) {
|
|
2491
|
+
|
|
2492
|
+
faceIndices.push( indices[ offset + j ] );
|
|
2493
|
+
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2496
|
+
const triangles = this._triangulateNGon( faceIndices, points );
|
|
2497
|
+
|
|
2498
|
+
for ( const tri of triangles ) {
|
|
2499
|
+
|
|
2500
|
+
triangulated.push( tri[ 0 ], tri[ 1 ], tri[ 2 ] );
|
|
2501
|
+
// Find local indices within the face
|
|
2502
|
+
pattern.push(
|
|
2503
|
+
offset + faceIndices.indexOf( tri[ 0 ] ),
|
|
2504
|
+
offset + faceIndices.indexOf( tri[ 1 ] ),
|
|
2505
|
+
offset + faceIndices.indexOf( tri[ 2 ] )
|
|
2506
|
+
);
|
|
2507
|
+
|
|
2508
|
+
}
|
|
2509
|
+
|
|
2510
|
+
} else {
|
|
2511
|
+
|
|
2512
|
+
// Fallback to fan triangulation
|
|
2513
|
+
for ( let j = 1; j < count - 1; j ++ ) {
|
|
2514
|
+
|
|
2515
|
+
triangulated.push(
|
|
2516
|
+
indices[ offset ],
|
|
2517
|
+
indices[ offset + j ],
|
|
2518
|
+
indices[ offset + j + 1 ]
|
|
2519
|
+
);
|
|
2520
|
+
pattern.push( offset, offset + j, offset + j + 1 );
|
|
2521
|
+
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
offset += count;
|
|
2529
|
+
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2532
|
+
return { indices: triangulated, pattern };
|
|
2533
|
+
|
|
2534
|
+
}
|
|
2535
|
+
|
|
2536
|
+
_applyTriangulationPattern( indices, pattern ) {
|
|
2537
|
+
|
|
2538
|
+
const result = [];
|
|
2539
|
+
for ( let i = 0; i < pattern.length; i ++ ) {
|
|
2540
|
+
|
|
2541
|
+
result.push( indices[ pattern[ i ] ] );
|
|
2542
|
+
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
return result;
|
|
2546
|
+
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
_triangulateNGon( faceIndices, points ) {
|
|
2550
|
+
|
|
2551
|
+
// Project 3D polygon to 2D for triangulation using Newell's method for normal
|
|
2552
|
+
const contour2D = [];
|
|
2553
|
+
const contour3D = [];
|
|
2554
|
+
|
|
2555
|
+
for ( const idx of faceIndices ) {
|
|
2556
|
+
|
|
2557
|
+
contour3D.push( new Vector3(
|
|
2558
|
+
points[ idx * 3 ],
|
|
2559
|
+
points[ idx * 3 + 1 ],
|
|
2560
|
+
points[ idx * 3 + 2 ]
|
|
2561
|
+
) );
|
|
2562
|
+
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2565
|
+
// Calculate polygon normal using Newell's method
|
|
2566
|
+
const normal = new Vector3();
|
|
2567
|
+
for ( let i = 0; i < contour3D.length; i ++ ) {
|
|
2568
|
+
|
|
2569
|
+
const curr = contour3D[ i ];
|
|
2570
|
+
const next = contour3D[ ( i + 1 ) % contour3D.length ];
|
|
2571
|
+
normal.x += ( curr.y - next.y ) * ( curr.z + next.z );
|
|
2572
|
+
normal.y += ( curr.z - next.z ) * ( curr.x + next.x );
|
|
2573
|
+
normal.z += ( curr.x - next.x ) * ( curr.y + next.y );
|
|
2574
|
+
|
|
2575
|
+
}
|
|
2576
|
+
|
|
2577
|
+
normal.normalize();
|
|
2578
|
+
|
|
2579
|
+
// Create tangent basis for projection
|
|
2580
|
+
const tangent = new Vector3();
|
|
2581
|
+
const bitangent = new Vector3();
|
|
2582
|
+
|
|
2583
|
+
if ( Math.abs( normal.y ) > 0.9 ) {
|
|
2584
|
+
|
|
2585
|
+
tangent.set( 1, 0, 0 );
|
|
2586
|
+
|
|
2587
|
+
} else {
|
|
2588
|
+
|
|
2589
|
+
tangent.set( 0, 1, 0 );
|
|
2590
|
+
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2593
|
+
bitangent.crossVectors( normal, tangent ).normalize();
|
|
2594
|
+
tangent.crossVectors( bitangent, normal ).normalize();
|
|
2595
|
+
|
|
2596
|
+
// Project to 2D
|
|
2597
|
+
for ( const p of contour3D ) {
|
|
2598
|
+
|
|
2599
|
+
contour2D.push( new Vector2( p.dot( tangent ), p.dot( bitangent ) ) );
|
|
2600
|
+
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2603
|
+
// Triangulate using ShapeUtils
|
|
2604
|
+
const triangles = ShapeUtils.triangulateShape( contour2D, [] );
|
|
2605
|
+
|
|
2606
|
+
// Map back to original indices
|
|
2607
|
+
const result = [];
|
|
2608
|
+
for ( const tri of triangles ) {
|
|
2609
|
+
|
|
2610
|
+
result.push( [
|
|
2611
|
+
faceIndices[ tri[ 0 ] ],
|
|
2612
|
+
faceIndices[ tri[ 1 ] ],
|
|
2613
|
+
faceIndices[ tri[ 2 ] ]
|
|
2614
|
+
] );
|
|
2615
|
+
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
return result;
|
|
2619
|
+
|
|
2620
|
+
}
|
|
2621
|
+
|
|
2622
|
+
_triangulateNGonWithHoles( outerIndices, holeContours, points ) {
|
|
2623
|
+
|
|
2624
|
+
// Project 3D polygon with holes to 2D for triangulation
|
|
2625
|
+
const outer3D = [];
|
|
2626
|
+
|
|
2627
|
+
for ( const idx of outerIndices ) {
|
|
2628
|
+
|
|
2629
|
+
outer3D.push( new Vector3(
|
|
2630
|
+
points[ idx * 3 ],
|
|
2631
|
+
points[ idx * 3 + 1 ],
|
|
2632
|
+
points[ idx * 3 + 2 ]
|
|
2633
|
+
) );
|
|
2634
|
+
|
|
2635
|
+
}
|
|
2636
|
+
|
|
2637
|
+
// Calculate polygon normal using Newell's method
|
|
2638
|
+
const normal = new Vector3();
|
|
2639
|
+
for ( let i = 0; i < outer3D.length; i ++ ) {
|
|
2640
|
+
|
|
2641
|
+
const curr = outer3D[ i ];
|
|
2642
|
+
const next = outer3D[ ( i + 1 ) % outer3D.length ];
|
|
2643
|
+
normal.x += ( curr.y - next.y ) * ( curr.z + next.z );
|
|
2644
|
+
normal.y += ( curr.z - next.z ) * ( curr.x + next.x );
|
|
2645
|
+
normal.z += ( curr.x - next.x ) * ( curr.y + next.y );
|
|
2646
|
+
|
|
2647
|
+
}
|
|
2648
|
+
|
|
2649
|
+
normal.normalize();
|
|
2650
|
+
|
|
2651
|
+
// Create tangent basis for projection
|
|
2652
|
+
const tangent = new Vector3();
|
|
2653
|
+
const bitangent = new Vector3();
|
|
2654
|
+
|
|
2655
|
+
if ( Math.abs( normal.y ) > 0.9 ) {
|
|
2656
|
+
|
|
2657
|
+
tangent.set( 1, 0, 0 );
|
|
2658
|
+
|
|
2659
|
+
} else {
|
|
2660
|
+
|
|
2661
|
+
tangent.set( 0, 1, 0 );
|
|
2662
|
+
|
|
2663
|
+
}
|
|
2664
|
+
|
|
2665
|
+
bitangent.crossVectors( normal, tangent ).normalize();
|
|
2666
|
+
tangent.crossVectors( bitangent, normal ).normalize();
|
|
2667
|
+
|
|
2668
|
+
// Project outer contour to 2D
|
|
2669
|
+
const outer2D = [];
|
|
2670
|
+
for ( const p of outer3D ) {
|
|
2671
|
+
|
|
2672
|
+
outer2D.push( new Vector2( p.dot( tangent ), p.dot( bitangent ) ) );
|
|
2673
|
+
|
|
2674
|
+
}
|
|
2675
|
+
|
|
2676
|
+
// Project hole contours to 2D
|
|
2677
|
+
const holes2D = [];
|
|
2678
|
+
|
|
2679
|
+
for ( const holeIndices of holeContours ) {
|
|
2680
|
+
|
|
2681
|
+
const hole2D = [];
|
|
2682
|
+
|
|
2683
|
+
for ( const idx of holeIndices ) {
|
|
2684
|
+
|
|
2685
|
+
const p = new Vector3(
|
|
2686
|
+
points[ idx * 3 ],
|
|
2687
|
+
points[ idx * 3 + 1 ],
|
|
2688
|
+
points[ idx * 3 + 2 ]
|
|
2689
|
+
);
|
|
2690
|
+
hole2D.push( new Vector2( p.dot( tangent ), p.dot( bitangent ) ) );
|
|
2691
|
+
|
|
2692
|
+
}
|
|
2693
|
+
|
|
2694
|
+
holes2D.push( hole2D );
|
|
2695
|
+
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2698
|
+
// Build combined index array: outer contour followed by all holes
|
|
2699
|
+
const allIndices = [ ...outerIndices ];
|
|
2700
|
+
for ( const holeIndices of holeContours ) {
|
|
2701
|
+
|
|
2702
|
+
allIndices.push( ...holeIndices );
|
|
2703
|
+
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
// Triangulate using ShapeUtils with holes
|
|
2707
|
+
const triangles = ShapeUtils.triangulateShape( outer2D, holes2D );
|
|
2708
|
+
|
|
2709
|
+
// Map back to original vertex indices
|
|
2710
|
+
const result = [];
|
|
2711
|
+
for ( const tri of triangles ) {
|
|
2712
|
+
|
|
2713
|
+
result.push( [
|
|
2714
|
+
allIndices[ tri[ 0 ] ],
|
|
2715
|
+
allIndices[ tri[ 1 ] ],
|
|
2716
|
+
allIndices[ tri[ 2 ] ]
|
|
2717
|
+
] );
|
|
2718
|
+
|
|
2719
|
+
}
|
|
2720
|
+
|
|
2721
|
+
return result;
|
|
2722
|
+
|
|
2723
|
+
}
|
|
2724
|
+
|
|
2725
|
+
_triangulateIndices( indices, counts ) {
|
|
2726
|
+
|
|
2727
|
+
const triangulated = [];
|
|
2728
|
+
let offset = 0;
|
|
2729
|
+
|
|
2730
|
+
for ( let i = 0; i < counts.length; i ++ ) {
|
|
2731
|
+
|
|
2732
|
+
const count = counts[ i ];
|
|
2733
|
+
|
|
2734
|
+
if ( count === 3 ) {
|
|
2735
|
+
|
|
2736
|
+
triangulated.push(
|
|
2737
|
+
indices[ offset ],
|
|
2738
|
+
indices[ offset + 1 ],
|
|
2739
|
+
indices[ offset + 2 ]
|
|
2740
|
+
);
|
|
2741
|
+
|
|
2742
|
+
} else if ( count === 4 ) {
|
|
2743
|
+
|
|
2744
|
+
triangulated.push(
|
|
2745
|
+
indices[ offset ],
|
|
2746
|
+
indices[ offset + 1 ],
|
|
2747
|
+
indices[ offset + 2 ],
|
|
2748
|
+
indices[ offset ],
|
|
2749
|
+
indices[ offset + 2 ],
|
|
2750
|
+
indices[ offset + 3 ]
|
|
2751
|
+
);
|
|
2752
|
+
|
|
2753
|
+
} else if ( count > 4 ) {
|
|
2754
|
+
|
|
2755
|
+
// Fan triangulation for n-gons
|
|
2756
|
+
for ( let j = 1; j < count - 1; j ++ ) {
|
|
2757
|
+
|
|
2758
|
+
triangulated.push(
|
|
2759
|
+
indices[ offset ],
|
|
2760
|
+
indices[ offset + j ],
|
|
2761
|
+
indices[ offset + j + 1 ]
|
|
2762
|
+
);
|
|
2763
|
+
|
|
2764
|
+
}
|
|
2765
|
+
|
|
2766
|
+
}
|
|
2767
|
+
|
|
2768
|
+
offset += count;
|
|
2769
|
+
|
|
2770
|
+
}
|
|
2771
|
+
|
|
2772
|
+
return triangulated;
|
|
2773
|
+
|
|
2774
|
+
}
|
|
2775
|
+
|
|
2776
|
+
_expandAttribute( data, indices, itemSize ) {
|
|
2777
|
+
|
|
2778
|
+
const expanded = new Array( indices.length * itemSize );
|
|
2779
|
+
|
|
2780
|
+
for ( let i = 0; i < indices.length; i ++ ) {
|
|
2781
|
+
|
|
2782
|
+
const srcIdx = indices[ i ];
|
|
2783
|
+
|
|
2784
|
+
for ( let j = 0; j < itemSize; j ++ ) {
|
|
2785
|
+
|
|
2786
|
+
expanded[ i * itemSize + j ] = data[ srcIdx * itemSize + j ];
|
|
2787
|
+
|
|
2788
|
+
}
|
|
2789
|
+
|
|
2790
|
+
}
|
|
2791
|
+
|
|
2792
|
+
return expanded;
|
|
2793
|
+
|
|
2794
|
+
}
|
|
2795
|
+
|
|
2796
|
+
/**
|
|
2797
|
+
* Compute per-vertex normals from indexed triangle data.
|
|
2798
|
+
* Accumulates area-weighted face normals at each shared vertex and normalizes.
|
|
2799
|
+
*/
|
|
2800
|
+
_computeVertexNormals( points, indices ) {
|
|
2801
|
+
|
|
2802
|
+
const numVertices = points.length / 3;
|
|
2803
|
+
const normals = new Float32Array( numVertices * 3 );
|
|
2804
|
+
|
|
2805
|
+
for ( let i = 0; i < indices.length; i += 3 ) {
|
|
2806
|
+
|
|
2807
|
+
const a = indices[ i ];
|
|
2808
|
+
const b = indices[ i + 1 ];
|
|
2809
|
+
const c = indices[ i + 2 ];
|
|
2810
|
+
|
|
2811
|
+
const ax = points[ a * 3 ], ay = points[ a * 3 + 1 ], az = points[ a * 3 + 2 ];
|
|
2812
|
+
const bx = points[ b * 3 ], by = points[ b * 3 + 1 ], bz = points[ b * 3 + 2 ];
|
|
2813
|
+
const cx = points[ c * 3 ], cy = points[ c * 3 + 1 ], cz = points[ c * 3 + 2 ];
|
|
2814
|
+
|
|
2815
|
+
const e1x = bx - ax, e1y = by - ay, e1z = bz - az;
|
|
2816
|
+
const e2x = cx - ax, e2y = cy - ay, e2z = cz - az;
|
|
2817
|
+
|
|
2818
|
+
const nx = e1y * e2z - e1z * e2y;
|
|
2819
|
+
const ny = e1z * e2x - e1x * e2z;
|
|
2820
|
+
const nz = e1x * e2y - e1y * e2x;
|
|
2821
|
+
|
|
2822
|
+
normals[ a * 3 ] += nx; normals[ a * 3 + 1 ] += ny; normals[ a * 3 + 2 ] += nz;
|
|
2823
|
+
normals[ b * 3 ] += nx; normals[ b * 3 + 1 ] += ny; normals[ b * 3 + 2 ] += nz;
|
|
2824
|
+
normals[ c * 3 ] += nx; normals[ c * 3 + 1 ] += ny; normals[ c * 3 + 2 ] += nz;
|
|
2825
|
+
|
|
2826
|
+
}
|
|
2827
|
+
|
|
2828
|
+
for ( let i = 0; i < numVertices; i ++ ) {
|
|
2829
|
+
|
|
2830
|
+
const x = normals[ i * 3 ], y = normals[ i * 3 + 1 ], z = normals[ i * 3 + 2 ];
|
|
2831
|
+
const len = Math.sqrt( x * x + y * y + z * z );
|
|
2832
|
+
|
|
2833
|
+
if ( len > 0 ) {
|
|
2834
|
+
|
|
2835
|
+
normals[ i * 3 ] /= len;
|
|
2836
|
+
normals[ i * 3 + 1 ] /= len;
|
|
2837
|
+
normals[ i * 3 + 2 ] /= len;
|
|
2838
|
+
|
|
2839
|
+
}
|
|
2840
|
+
|
|
2841
|
+
}
|
|
2842
|
+
|
|
2843
|
+
return normals;
|
|
2844
|
+
|
|
2845
|
+
}
|
|
2846
|
+
|
|
2847
|
+
/**
|
|
2848
|
+
* Get the material path for a mesh, checking various binding sources.
|
|
2849
|
+
*/
|
|
2850
|
+
_getMaterialPath( meshPath, fields ) {
|
|
2851
|
+
|
|
2852
|
+
let materialPath = null;
|
|
2853
|
+
const materialBinding = fields[ 'material:binding' ];
|
|
2854
|
+
|
|
2855
|
+
if ( materialBinding ) {
|
|
2856
|
+
|
|
2857
|
+
materialPath = Array.isArray( materialBinding ) ? materialBinding[ 0 ] : materialBinding;
|
|
2858
|
+
|
|
2859
|
+
}
|
|
2860
|
+
|
|
2861
|
+
// Use variant-aware lookup if no direct binding in fields
|
|
2862
|
+
if ( ! materialPath ) {
|
|
2863
|
+
|
|
2864
|
+
materialPath = this._getMaterialBindingTarget( meshPath );
|
|
2865
|
+
|
|
2866
|
+
}
|
|
2867
|
+
|
|
2868
|
+
return materialPath;
|
|
2869
|
+
|
|
2870
|
+
}
|
|
2871
|
+
|
|
2872
|
+
_buildMaterial( meshPath, fields ) {
|
|
2873
|
+
|
|
2874
|
+
const material = new MeshPhysicalMaterial();
|
|
2875
|
+
|
|
2876
|
+
let materialPath = null;
|
|
2877
|
+
const materialBinding = fields[ 'material:binding' ];
|
|
2878
|
+
|
|
2879
|
+
if ( materialBinding ) {
|
|
2880
|
+
|
|
2881
|
+
materialPath = Array.isArray( materialBinding ) ? materialBinding[ 0 ] : materialBinding;
|
|
2882
|
+
|
|
2883
|
+
}
|
|
2884
|
+
|
|
2885
|
+
// Use variant-aware lookup if no direct binding in fields
|
|
2886
|
+
if ( ! materialPath ) {
|
|
2887
|
+
|
|
2888
|
+
materialPath = this._getMaterialBindingTarget( meshPath );
|
|
2889
|
+
|
|
2890
|
+
}
|
|
2891
|
+
|
|
2892
|
+
if ( ! materialPath ) {
|
|
2893
|
+
|
|
2894
|
+
const materialPaths = [];
|
|
2895
|
+
const prefix = meshPath + '/';
|
|
2896
|
+
|
|
2897
|
+
for ( const path in this.specsByPath ) {
|
|
2898
|
+
|
|
2899
|
+
if ( ! path.startsWith( prefix ) ) continue;
|
|
2900
|
+
if ( ! path.endsWith( '.material:binding' ) ) continue;
|
|
2901
|
+
|
|
2902
|
+
const bindingSpec = this.specsByPath[ path ];
|
|
2903
|
+
if ( ! bindingSpec ) continue;
|
|
2904
|
+
|
|
2905
|
+
const targetPaths = bindingSpec.fields.targetPaths;
|
|
2906
|
+
if ( targetPaths && targetPaths.length > 0 ) {
|
|
2907
|
+
|
|
2908
|
+
materialPaths.push( targetPaths[ 0 ] );
|
|
2909
|
+
|
|
2910
|
+
}
|
|
2911
|
+
|
|
2912
|
+
}
|
|
2913
|
+
|
|
2914
|
+
if ( materialPaths.length > 0 ) {
|
|
2915
|
+
|
|
2916
|
+
materialPath = this._pickBestMaterial( materialPaths );
|
|
2917
|
+
|
|
2918
|
+
}
|
|
2919
|
+
|
|
2920
|
+
}
|
|
2921
|
+
|
|
2922
|
+
if ( ! materialPath ) {
|
|
2923
|
+
|
|
2924
|
+
// Use material index for O(1) lookup instead of O(n) iteration
|
|
2925
|
+
const meshParts = meshPath.split( '/' );
|
|
2926
|
+
const rootPath = '/' + meshParts[ 1 ];
|
|
2927
|
+
|
|
2928
|
+
const materialsInRoot = this.materialsByRoot.get( rootPath );
|
|
2929
|
+
|
|
2930
|
+
if ( materialsInRoot ) {
|
|
2931
|
+
|
|
2932
|
+
for ( const path of materialsInRoot ) {
|
|
2933
|
+
|
|
2934
|
+
if ( path.startsWith( rootPath + '/Looks/' ) ||
|
|
2935
|
+
path.startsWith( rootPath + '/Materials/' ) ) {
|
|
2936
|
+
|
|
2937
|
+
materialPath = path;
|
|
2938
|
+
break;
|
|
2939
|
+
|
|
2940
|
+
}
|
|
2941
|
+
|
|
2942
|
+
}
|
|
2943
|
+
|
|
2944
|
+
}
|
|
2945
|
+
|
|
2946
|
+
}
|
|
2947
|
+
|
|
2948
|
+
if ( materialPath ) {
|
|
2949
|
+
|
|
2950
|
+
this._applyMaterial( material, materialPath );
|
|
2951
|
+
|
|
2952
|
+
}
|
|
2953
|
+
|
|
2954
|
+
return material;
|
|
2955
|
+
|
|
2956
|
+
}
|
|
2957
|
+
|
|
2958
|
+
_buildMaterialForPath( materialPath ) {
|
|
2959
|
+
|
|
2960
|
+
const material = new MeshPhysicalMaterial();
|
|
2961
|
+
|
|
2962
|
+
if ( materialPath ) {
|
|
2963
|
+
|
|
2964
|
+
this._applyMaterial( material, materialPath );
|
|
2965
|
+
|
|
2966
|
+
}
|
|
2967
|
+
|
|
2968
|
+
return material;
|
|
2969
|
+
|
|
2970
|
+
}
|
|
2971
|
+
|
|
2972
|
+
/**
|
|
2973
|
+
* Apply material binding from a prim path to a mesh.
|
|
2974
|
+
* Used when merging referenced geometry into a prim that has material binding.
|
|
2975
|
+
*/
|
|
2976
|
+
_applyMaterialBinding( mesh, primPath ) {
|
|
2977
|
+
|
|
2978
|
+
let materialPath = this._getMaterialBindingTarget( primPath );
|
|
2979
|
+
if ( ! materialPath ) return;
|
|
2980
|
+
|
|
2981
|
+
// Clean the material path
|
|
2982
|
+
materialPath = String( materialPath ).replace( /^<|>$/g, '' );
|
|
2983
|
+
|
|
2984
|
+
// Build and apply the material
|
|
2985
|
+
const material = new MeshPhysicalMaterial();
|
|
2986
|
+
this._applyMaterial( material, materialPath );
|
|
2987
|
+
mesh.material = material;
|
|
2988
|
+
|
|
2989
|
+
}
|
|
2990
|
+
|
|
2991
|
+
_pickBestMaterial( materialPaths ) {
|
|
2992
|
+
|
|
2993
|
+
for ( const materialPath of materialPaths ) {
|
|
2994
|
+
|
|
2995
|
+
const shaderPaths = this.shadersByMaterialPath.get( materialPath );
|
|
2996
|
+
if ( ! shaderPaths ) continue;
|
|
2997
|
+
|
|
2998
|
+
for ( const path of shaderPaths ) {
|
|
2999
|
+
|
|
3000
|
+
const attrs = this._getAttributes( path );
|
|
3001
|
+
if ( attrs[ 'info:id' ] === 'UsdUVTexture' && attrs[ 'inputs:file' ] ) {
|
|
3002
|
+
|
|
3003
|
+
return materialPath;
|
|
3004
|
+
|
|
3005
|
+
}
|
|
3006
|
+
|
|
3007
|
+
}
|
|
3008
|
+
|
|
3009
|
+
}
|
|
3010
|
+
|
|
3011
|
+
return materialPaths[ 0 ];
|
|
3012
|
+
|
|
3013
|
+
}
|
|
3014
|
+
|
|
3015
|
+
_applyMaterial( material, materialPath ) {
|
|
3016
|
+
|
|
3017
|
+
const materialSpec = this.specsByPath[ materialPath ];
|
|
3018
|
+
if ( ! materialSpec ) return;
|
|
3019
|
+
|
|
3020
|
+
const shaderPaths = this.shadersByMaterialPath.get( materialPath );
|
|
3021
|
+
if ( ! shaderPaths ) return;
|
|
3022
|
+
|
|
3023
|
+
for ( const path of shaderPaths ) {
|
|
3024
|
+
|
|
3025
|
+
const spec = this.specsByPath[ path ];
|
|
3026
|
+
if ( ! spec ) continue;
|
|
3027
|
+
|
|
3028
|
+
const shaderAttrs = this._getAttributes( path );
|
|
3029
|
+
const infoId = shaderAttrs[ 'info:id' ] || spec.fields[ 'info:id' ];
|
|
3030
|
+
|
|
3031
|
+
if ( infoId === 'UsdPreviewSurface' || infoId === 'ND_UsdPreviewSurface_surfaceshader' ) {
|
|
3032
|
+
|
|
3033
|
+
this._applyPreviewSurface( material, path );
|
|
3034
|
+
|
|
3035
|
+
} else if ( infoId === 'arnold:openpbr_surface' ) {
|
|
3036
|
+
|
|
3037
|
+
this._applyOpenPBRSurface( material, path );
|
|
3038
|
+
|
|
3039
|
+
}
|
|
3040
|
+
|
|
3041
|
+
}
|
|
3042
|
+
|
|
3043
|
+
}
|
|
3044
|
+
|
|
3045
|
+
/**
|
|
3046
|
+
* Shared helper for applying texture or value from shader attribute.
|
|
3047
|
+
* Reduces duplication between _applyPreviewSurface and _applyOpenPBRSurface.
|
|
3048
|
+
*/
|
|
3049
|
+
_applyTextureOrValue( material, shaderPath, fields, attrName, textureProperty, colorSpace, valueCallback, textureGetter ) {
|
|
3050
|
+
|
|
3051
|
+
const attrPath = shaderPath + '.' + attrName;
|
|
3052
|
+
const spec = this.specsByPath[ attrPath ];
|
|
3053
|
+
|
|
3054
|
+
if ( spec && spec.fields.connectionPaths && spec.fields.connectionPaths.length > 0 ) {
|
|
3055
|
+
|
|
3056
|
+
// For OpenPBR, try all connection paths; for PreviewSurface, just the first
|
|
3057
|
+
const paths = textureGetter === this._getTextureFromOpenPBRConnection
|
|
3058
|
+
? spec.fields.connectionPaths
|
|
3059
|
+
: [ spec.fields.connectionPaths[ 0 ] ];
|
|
3060
|
+
|
|
3061
|
+
for ( const connPath of paths ) {
|
|
3062
|
+
|
|
3063
|
+
const texture = textureGetter.call( this, connPath );
|
|
3064
|
+
|
|
3065
|
+
if ( texture ) {
|
|
3066
|
+
|
|
3067
|
+
texture.colorSpace = colorSpace;
|
|
3068
|
+
material[ textureProperty ] = texture;
|
|
3069
|
+
return true;
|
|
3070
|
+
|
|
3071
|
+
}
|
|
3072
|
+
|
|
3073
|
+
}
|
|
3074
|
+
|
|
3075
|
+
}
|
|
3076
|
+
|
|
3077
|
+
if ( fields[ attrName ] !== undefined && valueCallback ) {
|
|
3078
|
+
|
|
3079
|
+
valueCallback( fields[ attrName ] );
|
|
3080
|
+
|
|
3081
|
+
}
|
|
3082
|
+
|
|
3083
|
+
return false;
|
|
3084
|
+
|
|
3085
|
+
}
|
|
3086
|
+
|
|
3087
|
+
_applyPreviewSurface( material, shaderPath ) {
|
|
3088
|
+
|
|
3089
|
+
const fields = this._getAttributes( shaderPath );
|
|
3090
|
+
|
|
3091
|
+
const applyTexture = ( attrName, textureProperty, colorSpace, valueCallback ) => {
|
|
3092
|
+
|
|
3093
|
+
return this._applyTextureOrValue(
|
|
3094
|
+
material, shaderPath, fields, attrName, textureProperty, colorSpace, valueCallback,
|
|
3095
|
+
this._getTextureFromConnection
|
|
3096
|
+
);
|
|
3097
|
+
|
|
3098
|
+
};
|
|
3099
|
+
|
|
3100
|
+
const getAttrSpec = ( attrName ) => {
|
|
3101
|
+
|
|
3102
|
+
const attrPath = shaderPath + '.' + attrName;
|
|
3103
|
+
return this.specsByPath[ attrPath ];
|
|
3104
|
+
|
|
3105
|
+
};
|
|
3106
|
+
|
|
3107
|
+
// Diffuse color / base color map
|
|
3108
|
+
applyTexture(
|
|
3109
|
+
'inputs:diffuseColor',
|
|
3110
|
+
'map',
|
|
3111
|
+
SRGBColorSpace,
|
|
3112
|
+
( color ) => {
|
|
3113
|
+
|
|
3114
|
+
if ( Array.isArray( color ) && color.length >= 3 ) {
|
|
3115
|
+
|
|
3116
|
+
material.color.setRGB( color[ 0 ], color[ 1 ], color[ 2 ], LinearSRGBColorSpace );
|
|
3117
|
+
|
|
3118
|
+
}
|
|
3119
|
+
|
|
3120
|
+
}
|
|
3121
|
+
);
|
|
3122
|
+
|
|
3123
|
+
// Apply UsdUVTexture scale to diffuse color (output = texture * scale + bias)
|
|
3124
|
+
if ( material.map && material.map.userData.scale ) {
|
|
3125
|
+
|
|
3126
|
+
const scale = material.map.userData.scale;
|
|
3127
|
+
if ( Array.isArray( scale ) && scale.length >= 3 ) {
|
|
3128
|
+
|
|
3129
|
+
material.color.setRGB( scale[ 0 ], scale[ 1 ], scale[ 2 ], LinearSRGBColorSpace );
|
|
3130
|
+
|
|
3131
|
+
}
|
|
3132
|
+
|
|
3133
|
+
}
|
|
3134
|
+
|
|
3135
|
+
// Emissive
|
|
3136
|
+
applyTexture(
|
|
3137
|
+
'inputs:emissiveColor',
|
|
3138
|
+
'emissiveMap',
|
|
3139
|
+
SRGBColorSpace,
|
|
3140
|
+
( color ) => {
|
|
3141
|
+
|
|
3142
|
+
if ( Array.isArray( color ) && color.length >= 3 ) {
|
|
3143
|
+
|
|
3144
|
+
material.emissive.setRGB( color[ 0 ], color[ 1 ], color[ 2 ], LinearSRGBColorSpace );
|
|
3145
|
+
|
|
3146
|
+
}
|
|
3147
|
+
|
|
3148
|
+
}
|
|
3149
|
+
);
|
|
3150
|
+
|
|
3151
|
+
if ( material.emissiveMap ) {
|
|
3152
|
+
|
|
3153
|
+
if ( material.emissiveMap.userData.scale ) {
|
|
3154
|
+
|
|
3155
|
+
const scale = material.emissiveMap.userData.scale;
|
|
3156
|
+
if ( Array.isArray( scale ) && scale.length >= 3 ) {
|
|
3157
|
+
|
|
3158
|
+
material.emissive.setRGB( scale[ 0 ], scale[ 1 ], scale[ 2 ], LinearSRGBColorSpace );
|
|
3159
|
+
|
|
3160
|
+
}
|
|
3161
|
+
|
|
3162
|
+
} else {
|
|
3163
|
+
|
|
3164
|
+
material.emissive.set( 0xffffff );
|
|
3165
|
+
|
|
3166
|
+
}
|
|
3167
|
+
|
|
3168
|
+
}
|
|
3169
|
+
|
|
3170
|
+
// Normal map
|
|
3171
|
+
applyTexture( 'inputs:normal', 'normalMap', NoColorSpace, null );
|
|
3172
|
+
|
|
3173
|
+
// Apply normal map scale from UsdUVTexture scale input
|
|
3174
|
+
if ( material.normalMap && material.normalMap.userData.scale ) {
|
|
3175
|
+
|
|
3176
|
+
const scale = material.normalMap.userData.scale;
|
|
3177
|
+
// UsdUVTexture scale is float4 (r,g,b,a), use first two components for normalScale
|
|
3178
|
+
material.normalScale = new Vector2( scale[ 0 ], scale[ 1 ] );
|
|
3179
|
+
|
|
3180
|
+
}
|
|
3181
|
+
|
|
3182
|
+
// Roughness
|
|
3183
|
+
const hasRoughnessMap = applyTexture(
|
|
3184
|
+
'inputs:roughness',
|
|
3185
|
+
'roughnessMap',
|
|
3186
|
+
NoColorSpace,
|
|
3187
|
+
( value ) => {
|
|
3188
|
+
|
|
3189
|
+
material.roughness = value;
|
|
3190
|
+
|
|
3191
|
+
}
|
|
3192
|
+
);
|
|
3193
|
+
|
|
3194
|
+
if ( hasRoughnessMap ) {
|
|
3195
|
+
|
|
3196
|
+
material.roughness = 1.0;
|
|
3197
|
+
|
|
3198
|
+
}
|
|
3199
|
+
|
|
3200
|
+
// Metallic
|
|
3201
|
+
const hasMetalnessMap = applyTexture(
|
|
3202
|
+
'inputs:metallic',
|
|
3203
|
+
'metalnessMap',
|
|
3204
|
+
NoColorSpace,
|
|
3205
|
+
( value ) => {
|
|
3206
|
+
|
|
3207
|
+
material.metalness = value;
|
|
3208
|
+
|
|
3209
|
+
}
|
|
3210
|
+
);
|
|
3211
|
+
|
|
3212
|
+
if ( hasMetalnessMap ) {
|
|
3213
|
+
|
|
3214
|
+
material.metalness = 1.0;
|
|
3215
|
+
|
|
3216
|
+
}
|
|
3217
|
+
|
|
3218
|
+
// Occlusion
|
|
3219
|
+
applyTexture( 'inputs:occlusion', 'aoMap', NoColorSpace, null );
|
|
3220
|
+
|
|
3221
|
+
// IOR
|
|
3222
|
+
if ( fields[ 'inputs:ior' ] !== undefined ) {
|
|
3223
|
+
|
|
3224
|
+
material.ior = fields[ 'inputs:ior' ];
|
|
3225
|
+
|
|
3226
|
+
}
|
|
3227
|
+
|
|
3228
|
+
// Specular color
|
|
3229
|
+
applyTexture(
|
|
3230
|
+
'inputs:specularColor',
|
|
3231
|
+
'specularColorMap',
|
|
3232
|
+
SRGBColorSpace,
|
|
3233
|
+
( color ) => {
|
|
3234
|
+
|
|
3235
|
+
if ( Array.isArray( color ) && color.length >= 3 ) {
|
|
3236
|
+
|
|
3237
|
+
material.specularColor.setRGB( color[ 0 ], color[ 1 ], color[ 2 ], LinearSRGBColorSpace );
|
|
3238
|
+
|
|
3239
|
+
}
|
|
3240
|
+
|
|
3241
|
+
}
|
|
3242
|
+
);
|
|
3243
|
+
|
|
3244
|
+
// Apply UsdUVTexture scale to specular color
|
|
3245
|
+
if ( material.specularColorMap && material.specularColorMap.userData.scale ) {
|
|
3246
|
+
|
|
3247
|
+
const scale = material.specularColorMap.userData.scale;
|
|
3248
|
+
if ( Array.isArray( scale ) && scale.length >= 3 ) {
|
|
3249
|
+
|
|
3250
|
+
material.specularColor.setRGB( scale[ 0 ], scale[ 1 ], scale[ 2 ], LinearSRGBColorSpace );
|
|
3251
|
+
|
|
3252
|
+
}
|
|
3253
|
+
|
|
3254
|
+
}
|
|
3255
|
+
|
|
3256
|
+
// Clearcoat
|
|
3257
|
+
if ( fields[ 'inputs:clearcoat' ] !== undefined ) {
|
|
3258
|
+
|
|
3259
|
+
material.clearcoat = fields[ 'inputs:clearcoat' ];
|
|
3260
|
+
|
|
3261
|
+
}
|
|
3262
|
+
|
|
3263
|
+
// Clearcoat roughness
|
|
3264
|
+
if ( fields[ 'inputs:clearcoatRoughness' ] !== undefined ) {
|
|
3265
|
+
|
|
3266
|
+
material.clearcoatRoughness = fields[ 'inputs:clearcoatRoughness' ];
|
|
3267
|
+
|
|
3268
|
+
}
|
|
3269
|
+
|
|
3270
|
+
// Opacity and opacity modes
|
|
3271
|
+
const opacityThreshold = fields[ 'inputs:opacityThreshold' ] !== undefined ? fields[ 'inputs:opacityThreshold' ] : 0.0;
|
|
3272
|
+
|
|
3273
|
+
// Check if opacity is connected to a texture (e.g., diffuse texture's alpha)
|
|
3274
|
+
const opacitySpec = getAttrSpec( 'inputs:opacity' );
|
|
3275
|
+
const hasOpacityConnection = opacitySpec?.fields?.connectionPaths?.length > 0;
|
|
3276
|
+
|
|
3277
|
+
if ( hasOpacityConnection ) {
|
|
3278
|
+
|
|
3279
|
+
// Opacity from texture alpha - use the diffuse map's alpha channel
|
|
3280
|
+
if ( opacityThreshold > 0 ) {
|
|
3281
|
+
|
|
3282
|
+
// Alpha cutoff mode
|
|
3283
|
+
material.alphaTest = opacityThreshold;
|
|
3284
|
+
material.transparent = false;
|
|
3285
|
+
|
|
3286
|
+
} else {
|
|
3287
|
+
|
|
3288
|
+
// Alpha blend mode
|
|
3289
|
+
material.transparent = true;
|
|
3290
|
+
|
|
3291
|
+
}
|
|
3292
|
+
|
|
3293
|
+
} else {
|
|
3294
|
+
|
|
3295
|
+
// Direct opacity value
|
|
3296
|
+
const opacity = fields[ 'inputs:opacity' ] !== undefined ? fields[ 'inputs:opacity' ] : 1.0;
|
|
3297
|
+
|
|
3298
|
+
if ( opacity < 1.0 ) {
|
|
3299
|
+
|
|
3300
|
+
material.transparent = true;
|
|
3301
|
+
material.opacity = opacity;
|
|
3302
|
+
|
|
3303
|
+
}
|
|
3304
|
+
|
|
3305
|
+
}
|
|
3306
|
+
|
|
3307
|
+
}
|
|
3308
|
+
|
|
3309
|
+
_applyOpenPBRSurface( material, shaderPath ) {
|
|
3310
|
+
|
|
3311
|
+
const fields = this._getAttributes( shaderPath );
|
|
3312
|
+
|
|
3313
|
+
const applyTexture = ( attrName, textureProperty, colorSpace, valueCallback ) => {
|
|
3314
|
+
|
|
3315
|
+
return this._applyTextureOrValue(
|
|
3316
|
+
material, shaderPath, fields, attrName, textureProperty, colorSpace, valueCallback,
|
|
3317
|
+
this._getTextureFromOpenPBRConnection
|
|
3318
|
+
);
|
|
3319
|
+
|
|
3320
|
+
};
|
|
3321
|
+
|
|
3322
|
+
// Base color (diffuse)
|
|
3323
|
+
applyTexture(
|
|
3324
|
+
'inputs:base_color',
|
|
3325
|
+
'map',
|
|
3326
|
+
SRGBColorSpace,
|
|
3327
|
+
( color ) => {
|
|
3328
|
+
|
|
3329
|
+
if ( Array.isArray( color ) && color.length >= 3 ) {
|
|
3330
|
+
|
|
3331
|
+
material.color.setRGB( color[ 0 ], color[ 1 ], color[ 2 ], LinearSRGBColorSpace );
|
|
3332
|
+
|
|
3333
|
+
}
|
|
3334
|
+
|
|
3335
|
+
}
|
|
3336
|
+
);
|
|
3337
|
+
|
|
3338
|
+
// Apply UsdUVTexture scale to base color
|
|
3339
|
+
if ( material.map && material.map.userData.scale ) {
|
|
3340
|
+
|
|
3341
|
+
const scale = material.map.userData.scale;
|
|
3342
|
+
if ( Array.isArray( scale ) && scale.length >= 3 ) {
|
|
3343
|
+
|
|
3344
|
+
material.color.setRGB( scale[ 0 ], scale[ 1 ], scale[ 2 ], LinearSRGBColorSpace );
|
|
3345
|
+
|
|
3346
|
+
}
|
|
3347
|
+
|
|
3348
|
+
}
|
|
3349
|
+
|
|
3350
|
+
// Base metalness
|
|
3351
|
+
applyTexture(
|
|
3352
|
+
'inputs:base_metalness',
|
|
3353
|
+
'metalnessMap',
|
|
3354
|
+
NoColorSpace,
|
|
3355
|
+
( value ) => {
|
|
3356
|
+
|
|
3357
|
+
if ( typeof value === 'number' ) {
|
|
3358
|
+
|
|
3359
|
+
material.metalness = value;
|
|
3360
|
+
|
|
3361
|
+
}
|
|
3362
|
+
|
|
3363
|
+
}
|
|
3364
|
+
);
|
|
3365
|
+
|
|
3366
|
+
// Specular roughness
|
|
3367
|
+
applyTexture(
|
|
3368
|
+
'inputs:specular_roughness',
|
|
3369
|
+
'roughnessMap',
|
|
3370
|
+
NoColorSpace,
|
|
3371
|
+
( value ) => {
|
|
3372
|
+
|
|
3373
|
+
if ( typeof value === 'number' ) {
|
|
3374
|
+
|
|
3375
|
+
material.roughness = value;
|
|
3376
|
+
|
|
3377
|
+
}
|
|
3378
|
+
|
|
3379
|
+
}
|
|
3380
|
+
);
|
|
3381
|
+
|
|
3382
|
+
// Emission color
|
|
3383
|
+
const hasEmissionMap = applyTexture(
|
|
3384
|
+
'inputs:emission_color',
|
|
3385
|
+
'emissiveMap',
|
|
3386
|
+
SRGBColorSpace,
|
|
3387
|
+
( color ) => {
|
|
3388
|
+
|
|
3389
|
+
if ( Array.isArray( color ) && color.length >= 3 ) {
|
|
3390
|
+
|
|
3391
|
+
material.emissive.setRGB( color[ 0 ], color[ 1 ], color[ 2 ], LinearSRGBColorSpace );
|
|
3392
|
+
|
|
3393
|
+
}
|
|
3394
|
+
|
|
3395
|
+
}
|
|
3396
|
+
);
|
|
3397
|
+
|
|
3398
|
+
// Emission luminance/weight - multiply emissive by this factor
|
|
3399
|
+
const emissionLuminance = fields[ 'inputs:emission_luminance' ];
|
|
3400
|
+
|
|
3401
|
+
if ( emissionLuminance !== undefined && emissionLuminance > 0 ) {
|
|
3402
|
+
|
|
3403
|
+
if ( hasEmissionMap ) {
|
|
3404
|
+
|
|
3405
|
+
material.emissiveIntensity = emissionLuminance;
|
|
3406
|
+
|
|
3407
|
+
} else {
|
|
3408
|
+
|
|
3409
|
+
// Scale the emissive color by luminance
|
|
3410
|
+
material.emissive.multiplyScalar( emissionLuminance );
|
|
3411
|
+
|
|
3412
|
+
}
|
|
3413
|
+
|
|
3414
|
+
}
|
|
3415
|
+
|
|
3416
|
+
// Transmission (transparency)
|
|
3417
|
+
const transmissionWeight = fields[ 'inputs:transmission_weight' ];
|
|
3418
|
+
|
|
3419
|
+
if ( transmissionWeight !== undefined && transmissionWeight > 0 ) {
|
|
3420
|
+
|
|
3421
|
+
material.transmission = transmissionWeight;
|
|
3422
|
+
|
|
3423
|
+
const transmissionDepth = fields[ 'inputs:transmission_depth' ];
|
|
3424
|
+
|
|
3425
|
+
if ( transmissionDepth !== undefined ) {
|
|
3426
|
+
|
|
3427
|
+
material.thickness = transmissionDepth;
|
|
3428
|
+
|
|
3429
|
+
}
|
|
3430
|
+
|
|
3431
|
+
const transmissionColor = fields[ 'inputs:transmission_color' ];
|
|
3432
|
+
|
|
3433
|
+
if ( transmissionColor !== undefined && Array.isArray( transmissionColor ) ) {
|
|
3434
|
+
|
|
3435
|
+
material.attenuationColor.setRGB( transmissionColor[ 0 ], transmissionColor[ 1 ], transmissionColor[ 2 ], LinearSRGBColorSpace );
|
|
3436
|
+
material.attenuationDistance = transmissionDepth || 1.0;
|
|
3437
|
+
|
|
3438
|
+
}
|
|
3439
|
+
|
|
3440
|
+
}
|
|
3441
|
+
|
|
3442
|
+
// Geometry opacity (overall surface opacity)
|
|
3443
|
+
const geometryOpacity = fields[ 'inputs:geometry_opacity' ];
|
|
3444
|
+
|
|
3445
|
+
if ( geometryOpacity !== undefined && geometryOpacity < 1.0 ) {
|
|
3446
|
+
|
|
3447
|
+
material.opacity = geometryOpacity;
|
|
3448
|
+
material.transparent = true;
|
|
3449
|
+
|
|
3450
|
+
}
|
|
3451
|
+
|
|
3452
|
+
// Specular IOR
|
|
3453
|
+
const specularIOR = fields[ 'inputs:specular_ior' ];
|
|
3454
|
+
|
|
3455
|
+
if ( specularIOR !== undefined ) {
|
|
3456
|
+
|
|
3457
|
+
material.ior = specularIOR;
|
|
3458
|
+
|
|
3459
|
+
}
|
|
3460
|
+
|
|
3461
|
+
// Coat (clearcoat)
|
|
3462
|
+
const coatWeight = fields[ 'inputs:coat_weight' ];
|
|
3463
|
+
|
|
3464
|
+
if ( coatWeight !== undefined && coatWeight > 0 ) {
|
|
3465
|
+
|
|
3466
|
+
material.clearcoat = coatWeight;
|
|
3467
|
+
|
|
3468
|
+
const coatRoughness = fields[ 'inputs:coat_roughness' ];
|
|
3469
|
+
|
|
3470
|
+
if ( coatRoughness !== undefined ) {
|
|
3471
|
+
|
|
3472
|
+
material.clearcoatRoughness = coatRoughness;
|
|
3473
|
+
|
|
3474
|
+
}
|
|
3475
|
+
|
|
3476
|
+
}
|
|
3477
|
+
|
|
3478
|
+
// Thin film (iridescence)
|
|
3479
|
+
const thinFilmWeight = fields[ 'inputs:thin_film_weight' ];
|
|
3480
|
+
|
|
3481
|
+
if ( thinFilmWeight !== undefined && thinFilmWeight > 0 ) {
|
|
3482
|
+
|
|
3483
|
+
material.iridescence = thinFilmWeight;
|
|
3484
|
+
|
|
3485
|
+
const thinFilmIOR = fields[ 'inputs:thin_film_ior' ];
|
|
3486
|
+
|
|
3487
|
+
if ( thinFilmIOR !== undefined ) {
|
|
3488
|
+
|
|
3489
|
+
material.iridescenceIOR = thinFilmIOR;
|
|
3490
|
+
|
|
3491
|
+
}
|
|
3492
|
+
|
|
3493
|
+
const thinFilmThickness = fields[ 'inputs:thin_film_thickness' ];
|
|
3494
|
+
|
|
3495
|
+
if ( thinFilmThickness !== undefined ) {
|
|
3496
|
+
|
|
3497
|
+
// OpenPBR uses micrometers, Three.js uses nanometers
|
|
3498
|
+
const thicknessNm = thinFilmThickness * 1000;
|
|
3499
|
+
material.iridescenceThicknessMinimum = thicknessNm;
|
|
3500
|
+
material.iridescenceThicknessMaximum = thicknessNm;
|
|
3501
|
+
|
|
3502
|
+
}
|
|
3503
|
+
|
|
3504
|
+
}
|
|
3505
|
+
|
|
3506
|
+
// Specular
|
|
3507
|
+
const specularWeight = fields[ 'inputs:specular_weight' ];
|
|
3508
|
+
|
|
3509
|
+
if ( specularWeight !== undefined ) {
|
|
3510
|
+
|
|
3511
|
+
material.specularIntensity = specularWeight;
|
|
3512
|
+
|
|
3513
|
+
}
|
|
3514
|
+
|
|
3515
|
+
const specularColor = fields[ 'inputs:specular_color' ];
|
|
3516
|
+
|
|
3517
|
+
if ( specularColor !== undefined && Array.isArray( specularColor ) ) {
|
|
3518
|
+
|
|
3519
|
+
material.specularColor.setRGB( specularColor[ 0 ], specularColor[ 1 ], specularColor[ 2 ], LinearSRGBColorSpace );
|
|
3520
|
+
|
|
3521
|
+
}
|
|
3522
|
+
|
|
3523
|
+
// Anisotropy
|
|
3524
|
+
const anisotropy = fields[ 'inputs:specular_roughness_anisotropy' ];
|
|
3525
|
+
|
|
3526
|
+
if ( anisotropy !== undefined && anisotropy > 0 ) {
|
|
3527
|
+
|
|
3528
|
+
material.anisotropy = anisotropy;
|
|
3529
|
+
|
|
3530
|
+
}
|
|
3531
|
+
|
|
3532
|
+
// Geometry normal (normal map)
|
|
3533
|
+
applyTexture(
|
|
3534
|
+
'inputs:geometry_normal',
|
|
3535
|
+
'normalMap',
|
|
3536
|
+
NoColorSpace,
|
|
3537
|
+
null
|
|
3538
|
+
);
|
|
3539
|
+
|
|
3540
|
+
}
|
|
3541
|
+
|
|
3542
|
+
_getTextureFromOpenPBRConnection( connPath ) {
|
|
3543
|
+
|
|
3544
|
+
// connPath is like /Material/NodeGraph.outputs:baseColor or /Material/Shader.outputs:out
|
|
3545
|
+
const cleanPath = connPath.replace( /<|>/g, '' );
|
|
3546
|
+
const shaderPath = cleanPath.split( '.' )[ 0 ];
|
|
3547
|
+
const shaderSpec = this.specsByPath[ shaderPath ];
|
|
3548
|
+
|
|
3549
|
+
if ( ! shaderSpec ) return null;
|
|
3550
|
+
|
|
3551
|
+
const attrs = this._getAttributes( shaderPath );
|
|
3552
|
+
const infoId = attrs[ 'info:id' ] || shaderSpec.fields[ 'info:id' ];
|
|
3553
|
+
const typeName = shaderSpec.fields.typeName;
|
|
3554
|
+
|
|
3555
|
+
// Handle NodeGraph - follow output connection to internal shader
|
|
3556
|
+
if ( typeName === 'NodeGraph' ) {
|
|
3557
|
+
|
|
3558
|
+
// Get the output attribute that's connected
|
|
3559
|
+
const outputName = cleanPath.split( '.' )[ 1 ]; // e.g., "outputs:baseColor"
|
|
3560
|
+
const outputAttrPath = shaderPath + '.' + outputName;
|
|
3561
|
+
const outputSpec = this.specsByPath[ outputAttrPath ];
|
|
3562
|
+
|
|
3563
|
+
if ( outputSpec?.fields?.connectionPaths?.length > 0 ) {
|
|
3564
|
+
|
|
3565
|
+
// Follow the internal connection
|
|
3566
|
+
return this._getTextureFromOpenPBRConnection( outputSpec.fields.connectionPaths[ 0 ] );
|
|
3567
|
+
|
|
3568
|
+
}
|
|
3569
|
+
|
|
3570
|
+
return null;
|
|
3571
|
+
|
|
3572
|
+
}
|
|
3573
|
+
|
|
3574
|
+
// Handle arnold:image - Arnold's texture node
|
|
3575
|
+
if ( infoId === 'arnold:image' ) {
|
|
3576
|
+
|
|
3577
|
+
const filePath = attrs[ 'inputs:filename' ];
|
|
3578
|
+
if ( ! filePath ) return null;
|
|
3579
|
+
|
|
3580
|
+
return this._loadTextureFromPath( filePath );
|
|
3581
|
+
|
|
3582
|
+
}
|
|
3583
|
+
|
|
3584
|
+
// Handle MaterialX image nodes (ND_image_color4, ND_image_color3, etc.)
|
|
3585
|
+
if ( infoId && infoId.startsWith( 'ND_image_' ) ) {
|
|
3586
|
+
|
|
3587
|
+
const filePath = attrs[ 'inputs:file' ];
|
|
3588
|
+
if ( ! filePath ) return null;
|
|
3589
|
+
|
|
3590
|
+
return this._loadTextureFromPath( filePath );
|
|
3591
|
+
|
|
3592
|
+
}
|
|
3593
|
+
|
|
3594
|
+
// Handle Maya file texture - follow the inColor connection to the actual image
|
|
3595
|
+
if ( infoId === 'MayaND_fileTexture_color4' ) {
|
|
3596
|
+
|
|
3597
|
+
const inColorPath = shaderPath + '.inputs:inColor';
|
|
3598
|
+
const inColorSpec = this.specsByPath[ inColorPath ];
|
|
3599
|
+
|
|
3600
|
+
if ( inColorSpec?.fields?.connectionPaths?.length > 0 ) {
|
|
3601
|
+
|
|
3602
|
+
return this._getTextureFromOpenPBRConnection( inColorSpec.fields.connectionPaths[ 0 ] );
|
|
3603
|
+
|
|
3604
|
+
}
|
|
3605
|
+
|
|
3606
|
+
return null;
|
|
3607
|
+
|
|
3608
|
+
}
|
|
3609
|
+
|
|
3610
|
+
// Handle color conversion nodes - follow the input connection
|
|
3611
|
+
if ( infoId && infoId.startsWith( 'ND_convert_' ) ) {
|
|
3612
|
+
|
|
3613
|
+
const inPath = shaderPath + '.inputs:in';
|
|
3614
|
+
const inSpec = this.specsByPath[ inPath ];
|
|
3615
|
+
|
|
3616
|
+
if ( inSpec?.fields?.connectionPaths?.length > 0 ) {
|
|
3617
|
+
|
|
3618
|
+
return this._getTextureFromOpenPBRConnection( inSpec.fields.connectionPaths[ 0 ] );
|
|
3619
|
+
|
|
3620
|
+
}
|
|
3621
|
+
|
|
3622
|
+
return null;
|
|
3623
|
+
|
|
3624
|
+
}
|
|
3625
|
+
|
|
3626
|
+
// Handle Arnold bump2d - follow the bump_map input
|
|
3627
|
+
if ( infoId === 'arnold:bump2d' ) {
|
|
3628
|
+
|
|
3629
|
+
const bumpMapPath = shaderPath + '.inputs:bump_map';
|
|
3630
|
+
const bumpMapSpec = this.specsByPath[ bumpMapPath ];
|
|
3631
|
+
|
|
3632
|
+
if ( bumpMapSpec?.fields?.connectionPaths?.length > 0 ) {
|
|
3633
|
+
|
|
3634
|
+
return this._getTextureFromOpenPBRConnection( bumpMapSpec.fields.connectionPaths[ 0 ] );
|
|
3635
|
+
|
|
3636
|
+
}
|
|
3637
|
+
|
|
3638
|
+
return null;
|
|
3639
|
+
|
|
3640
|
+
}
|
|
3641
|
+
|
|
3642
|
+
// Handle Arnold color_correct - follow the input connection
|
|
3643
|
+
if ( infoId === 'arnold:color_correct' ) {
|
|
3644
|
+
|
|
3645
|
+
const inputPath = shaderPath + '.inputs:input';
|
|
3646
|
+
const inputSpec = this.specsByPath[ inputPath ];
|
|
3647
|
+
|
|
3648
|
+
if ( inputSpec?.fields?.connectionPaths?.length > 0 ) {
|
|
3649
|
+
|
|
3650
|
+
return this._getTextureFromOpenPBRConnection( inputSpec.fields.connectionPaths[ 0 ] );
|
|
3651
|
+
|
|
3652
|
+
}
|
|
3653
|
+
|
|
3654
|
+
return null;
|
|
3655
|
+
|
|
3656
|
+
}
|
|
3657
|
+
|
|
3658
|
+
// Handle nested shader paths (e.g., /Material/file2/cc.outputs:a)
|
|
3659
|
+
// Check if parent path is an image node
|
|
3660
|
+
const parentPath = shaderPath.substring( 0, shaderPath.lastIndexOf( '/' ) );
|
|
3661
|
+
|
|
3662
|
+
if ( parentPath ) {
|
|
3663
|
+
|
|
3664
|
+
const parentSpec = this.specsByPath[ parentPath ];
|
|
3665
|
+
|
|
3666
|
+
if ( parentSpec ) {
|
|
3667
|
+
|
|
3668
|
+
const parentAttrs = this._getAttributes( parentPath );
|
|
3669
|
+
const parentInfoId = parentAttrs[ 'info:id' ] || parentSpec.fields[ 'info:id' ];
|
|
3670
|
+
|
|
3671
|
+
if ( parentInfoId === 'arnold:image' ) {
|
|
3672
|
+
|
|
3673
|
+
const filePath = parentAttrs[ 'inputs:filename' ];
|
|
3674
|
+
if ( filePath ) return this._loadTextureFromPath( filePath );
|
|
3675
|
+
|
|
3676
|
+
}
|
|
3677
|
+
|
|
3678
|
+
}
|
|
3679
|
+
|
|
3680
|
+
}
|
|
3681
|
+
|
|
3682
|
+
return null;
|
|
3683
|
+
|
|
3684
|
+
}
|
|
3685
|
+
|
|
3686
|
+
_loadTextureFromPath( filePath ) {
|
|
3687
|
+
|
|
3688
|
+
if ( ! filePath ) return null;
|
|
3689
|
+
|
|
3690
|
+
// Check cache first
|
|
3691
|
+
if ( this.textureCache[ filePath ] ) {
|
|
3692
|
+
|
|
3693
|
+
return this.textureCache[ filePath ];
|
|
3694
|
+
|
|
3695
|
+
}
|
|
3696
|
+
|
|
3697
|
+
const texture = this._loadTexture( filePath, null, null );
|
|
3698
|
+
|
|
3699
|
+
if ( texture ) {
|
|
3700
|
+
|
|
3701
|
+
this.textureCache[ filePath ] = texture;
|
|
3702
|
+
|
|
3703
|
+
}
|
|
3704
|
+
|
|
3705
|
+
return texture;
|
|
3706
|
+
|
|
3707
|
+
}
|
|
3708
|
+
|
|
3709
|
+
_getTextureFromConnection( connPath ) {
|
|
3710
|
+
|
|
3711
|
+
// connPath is like /Material/Shader.outputs:rgb
|
|
3712
|
+
const shaderPath = connPath.split( '.' )[ 0 ];
|
|
3713
|
+
const shaderSpec = this.specsByPath[ shaderPath ];
|
|
3714
|
+
|
|
3715
|
+
if ( ! shaderSpec ) return null;
|
|
3716
|
+
|
|
3717
|
+
const attrs = this._getAttributes( shaderPath );
|
|
3718
|
+
const infoId = attrs[ 'info:id' ] || shaderSpec.fields[ 'info:id' ];
|
|
3719
|
+
|
|
3720
|
+
if ( infoId !== 'UsdUVTexture' ) return null;
|
|
3721
|
+
|
|
3722
|
+
const filePath = attrs[ 'inputs:file' ];
|
|
3723
|
+
if ( ! filePath ) return null;
|
|
3724
|
+
|
|
3725
|
+
// Check for UsdTransform2d connection via inputs:st and trace to PrimvarReader
|
|
3726
|
+
let transformAttrs = null;
|
|
3727
|
+
let uvChannel = 0; // Default to first UV set
|
|
3728
|
+
const stAttrPath = shaderPath + '.inputs:st';
|
|
3729
|
+
const stAttrSpec = this.specsByPath[ stAttrPath ];
|
|
3730
|
+
|
|
3731
|
+
if ( stAttrSpec?.fields?.connectionPaths?.length > 0 ) {
|
|
3732
|
+
|
|
3733
|
+
const stConnPath = stAttrSpec.fields.connectionPaths[ 0 ];
|
|
3734
|
+
const stPath = stConnPath.replace( /<|>/g, '' ).split( '.' )[ 0 ];
|
|
3735
|
+
const stSpec = this.specsByPath[ stPath ];
|
|
3736
|
+
|
|
3737
|
+
if ( stSpec ) {
|
|
3738
|
+
|
|
3739
|
+
const stAttrs = this._getAttributes( stPath );
|
|
3740
|
+
const stInfoId = stAttrs[ 'info:id' ] || stSpec.fields[ 'info:id' ];
|
|
3741
|
+
|
|
3742
|
+
if ( stInfoId === 'UsdTransform2d' ) {
|
|
3743
|
+
|
|
3744
|
+
transformAttrs = stAttrs;
|
|
3745
|
+
|
|
3746
|
+
// Trace to PrimvarReader to find UV set
|
|
3747
|
+
const inAttrPath = stPath + '.inputs:in';
|
|
3748
|
+
const inAttrSpec = this.specsByPath[ inAttrPath ];
|
|
3749
|
+
|
|
3750
|
+
if ( inAttrSpec?.fields?.connectionPaths?.length > 0 ) {
|
|
3751
|
+
|
|
3752
|
+
const inConnPath = inAttrSpec.fields.connectionPaths[ 0 ];
|
|
3753
|
+
const primvarPath = inConnPath.replace( /<|>/g, '' ).split( '.' )[ 0 ];
|
|
3754
|
+
const primvarAttrs = this._getAttributes( primvarPath );
|
|
3755
|
+
|
|
3756
|
+
// Check varname to determine UV channel
|
|
3757
|
+
const varname = primvarAttrs[ 'inputs:varname' ];
|
|
3758
|
+
if ( varname === 'st1' ) uvChannel = 1;
|
|
3759
|
+
else if ( varname === 'st2' ) uvChannel = 2;
|
|
3760
|
+
|
|
3761
|
+
}
|
|
3762
|
+
|
|
3763
|
+
} else if ( stInfoId === 'UsdPrimvarReader_float2' ) {
|
|
3764
|
+
|
|
3765
|
+
// Direct connection to PrimvarReader
|
|
3766
|
+
const varname = stAttrs[ 'inputs:varname' ];
|
|
3767
|
+
if ( varname === 'st1' ) uvChannel = 1;
|
|
3768
|
+
else if ( varname === 'st2' ) uvChannel = 2;
|
|
3769
|
+
|
|
3770
|
+
}
|
|
3771
|
+
|
|
3772
|
+
}
|
|
3773
|
+
|
|
3774
|
+
}
|
|
3775
|
+
|
|
3776
|
+
// Extract scale and bias for texture value modification
|
|
3777
|
+
const scale = attrs[ 'inputs:scale' ];
|
|
3778
|
+
const bias = attrs[ 'inputs:bias' ];
|
|
3779
|
+
|
|
3780
|
+
// Create cache key that includes scale/bias if present
|
|
3781
|
+
let cacheKey = filePath;
|
|
3782
|
+
if ( scale ) cacheKey += ':s' + scale.join( ',' );
|
|
3783
|
+
if ( bias ) cacheKey += ':b' + bias.join( ',' );
|
|
3784
|
+
|
|
3785
|
+
if ( this.textureCache[ cacheKey ] ) {
|
|
3786
|
+
|
|
3787
|
+
return this.textureCache[ cacheKey ];
|
|
3788
|
+
|
|
3789
|
+
}
|
|
3790
|
+
|
|
3791
|
+
const texture = this._loadTexture( filePath, attrs, transformAttrs );
|
|
3792
|
+
|
|
3793
|
+
if ( texture ) {
|
|
3794
|
+
|
|
3795
|
+
// Store scale/bias and UV channel in userData
|
|
3796
|
+
if ( scale ) texture.userData.scale = scale;
|
|
3797
|
+
if ( bias ) texture.userData.bias = bias;
|
|
3798
|
+
if ( uvChannel !== 0 ) texture.channel = uvChannel;
|
|
3799
|
+
|
|
3800
|
+
this.textureCache[ cacheKey ] = texture;
|
|
3801
|
+
|
|
3802
|
+
}
|
|
3803
|
+
|
|
3804
|
+
return texture;
|
|
3805
|
+
|
|
3806
|
+
}
|
|
3807
|
+
|
|
3808
|
+
_applyTextureTransforms( texture, attrs ) {
|
|
3809
|
+
|
|
3810
|
+
if ( ! attrs ) return;
|
|
3811
|
+
|
|
3812
|
+
const scale = attrs[ 'inputs:scale' ];
|
|
3813
|
+
if ( scale && Array.isArray( scale ) && scale.length >= 2 ) {
|
|
3814
|
+
|
|
3815
|
+
texture.repeat.set( scale[ 0 ], scale[ 1 ] );
|
|
3816
|
+
|
|
3817
|
+
}
|
|
3818
|
+
|
|
3819
|
+
const translation = attrs[ 'inputs:translation' ];
|
|
3820
|
+
if ( translation && Array.isArray( translation ) && translation.length >= 2 ) {
|
|
3821
|
+
|
|
3822
|
+
texture.offset.set( translation[ 0 ], translation[ 1 ] );
|
|
3823
|
+
|
|
3824
|
+
}
|
|
3825
|
+
|
|
3826
|
+
const rotation = attrs[ 'inputs:rotation' ];
|
|
3827
|
+
if ( typeof rotation === 'number' ) {
|
|
3828
|
+
|
|
3829
|
+
texture.rotation = rotation * Math.PI / 180;
|
|
3830
|
+
|
|
3831
|
+
}
|
|
3832
|
+
|
|
3833
|
+
}
|
|
3834
|
+
|
|
3835
|
+
_loadTexture( filePath, textureAttrs, transformAttrs ) {
|
|
3836
|
+
|
|
3837
|
+
let cleanPath = filePath;
|
|
3838
|
+
if ( cleanPath.startsWith( '@' ) ) cleanPath = cleanPath.slice( 1 );
|
|
3839
|
+
if ( cleanPath.endsWith( '@' ) ) cleanPath = cleanPath.slice( 0, - 1 );
|
|
3840
|
+
|
|
3841
|
+
// Resolve relative to basePath first
|
|
3842
|
+
const resolvedPath = this._resolveFilePath( cleanPath );
|
|
3843
|
+
let assetData = this.assets[ resolvedPath ];
|
|
3844
|
+
|
|
3845
|
+
// Fallback to unresolved path
|
|
3846
|
+
if ( ! assetData ) {
|
|
3847
|
+
|
|
3848
|
+
assetData = this.assets[ cleanPath ];
|
|
3849
|
+
|
|
3850
|
+
}
|
|
3851
|
+
|
|
3852
|
+
// Last resort: search by basename
|
|
3853
|
+
if ( ! assetData ) {
|
|
3854
|
+
|
|
3855
|
+
const baseName = cleanPath.split( '/' ).pop();
|
|
3856
|
+
|
|
3857
|
+
for ( const key in this.assets ) {
|
|
3858
|
+
|
|
3859
|
+
if ( key.endsWith( baseName ) || key.endsWith( '/' + baseName ) ) {
|
|
3860
|
+
|
|
3861
|
+
return this._createTextureFromData( this.assets[ key ], textureAttrs, transformAttrs );
|
|
3862
|
+
|
|
3863
|
+
}
|
|
3864
|
+
|
|
3865
|
+
}
|
|
3866
|
+
|
|
3867
|
+
// Standalone .usd/.usda/.usdc files don't pre-load assets; treat the
|
|
3868
|
+
// resolved path as a URL relative to basePath so the browser fetches
|
|
3869
|
+
// the texture from disk next to the layer.
|
|
3870
|
+
|
|
3871
|
+
if ( this.basePath ) {
|
|
3872
|
+
|
|
3873
|
+
return this._createTextureFromData( resolvedPath, textureAttrs, transformAttrs );
|
|
3874
|
+
|
|
3875
|
+
}
|
|
3876
|
+
|
|
3877
|
+
// Try loading via LoadingManager if available
|
|
3878
|
+
if ( this.manager ) {
|
|
3879
|
+
|
|
3880
|
+
return this._createTextureFromData( baseName, textureAttrs, transformAttrs );
|
|
3881
|
+
|
|
3882
|
+
}
|
|
3883
|
+
|
|
3884
|
+
console.warn( 'USDLoader: Texture not found:', cleanPath );
|
|
3885
|
+
return null;
|
|
3886
|
+
|
|
3887
|
+
}
|
|
3888
|
+
|
|
3889
|
+
return this._createTextureFromData( assetData, textureAttrs, transformAttrs );
|
|
3890
|
+
|
|
3891
|
+
}
|
|
3892
|
+
|
|
3893
|
+
_createTextureFromData( data, textureAttrs, transformAttrs ) {
|
|
3894
|
+
|
|
3895
|
+
if ( ! data ) return null;
|
|
3896
|
+
|
|
3897
|
+
const scope = this;
|
|
3898
|
+
const texture = new Texture();
|
|
3899
|
+
|
|
3900
|
+
let url;
|
|
3901
|
+
|
|
3902
|
+
if ( typeof data === 'string' ) {
|
|
3903
|
+
|
|
3904
|
+
url = data;
|
|
3905
|
+
|
|
3906
|
+
} else if ( data instanceof Uint8Array || data instanceof ArrayBuffer ) {
|
|
3907
|
+
|
|
3908
|
+
const blob = new Blob( [ data ] );
|
|
3909
|
+
url = URL.createObjectURL( blob );
|
|
3910
|
+
|
|
3911
|
+
} else {
|
|
3912
|
+
|
|
3913
|
+
return null;
|
|
3914
|
+
|
|
3915
|
+
}
|
|
3916
|
+
|
|
3917
|
+
this.texturePromises.push( new Promise( ( resolve ) => {
|
|
3918
|
+
|
|
3919
|
+
this.imageLoader.load( url, function ( image ) {
|
|
3920
|
+
|
|
3921
|
+
texture.image = image;
|
|
3922
|
+
|
|
3923
|
+
if ( textureAttrs ) {
|
|
3924
|
+
|
|
3925
|
+
texture.wrapS = scope._getWrapMode( textureAttrs[ 'inputs:wrapS' ] );
|
|
3926
|
+
texture.wrapT = scope._getWrapMode( textureAttrs[ 'inputs:wrapT' ] );
|
|
3927
|
+
|
|
3928
|
+
}
|
|
3929
|
+
|
|
3930
|
+
scope._applyTextureTransforms( texture, transformAttrs );
|
|
3931
|
+
texture.needsUpdate = true;
|
|
3932
|
+
|
|
3933
|
+
if ( typeof data !== 'string' ) {
|
|
3934
|
+
|
|
3935
|
+
URL.revokeObjectURL( url );
|
|
3936
|
+
|
|
3937
|
+
}
|
|
3938
|
+
|
|
3939
|
+
resolve();
|
|
3940
|
+
|
|
3941
|
+
}, undefined, function () {
|
|
3942
|
+
|
|
3943
|
+
console.warn( 'USDLoader: Failed to load texture:', url );
|
|
3944
|
+
|
|
3945
|
+
if ( typeof data !== 'string' ) {
|
|
3946
|
+
|
|
3947
|
+
URL.revokeObjectURL( url );
|
|
3948
|
+
|
|
3949
|
+
}
|
|
3950
|
+
|
|
3951
|
+
resolve();
|
|
3952
|
+
|
|
3953
|
+
} );
|
|
3954
|
+
|
|
3955
|
+
} ) );
|
|
3956
|
+
|
|
3957
|
+
return texture;
|
|
3958
|
+
|
|
3959
|
+
}
|
|
3960
|
+
|
|
3961
|
+
_getWrapMode( wrapValue ) {
|
|
3962
|
+
|
|
3963
|
+
if ( wrapValue === 'repeat' ) return RepeatWrapping;
|
|
3964
|
+
if ( wrapValue === 'mirror' ) return MirroredRepeatWrapping;
|
|
3965
|
+
if ( wrapValue === 'clamp' ) return ClampToEdgeWrapping;
|
|
3966
|
+
return RepeatWrapping;
|
|
3967
|
+
|
|
3968
|
+
}
|
|
3969
|
+
|
|
3970
|
+
// ========================================================================
|
|
3971
|
+
// Skeletal Animation
|
|
3972
|
+
// ========================================================================
|
|
3973
|
+
|
|
3974
|
+
_buildSkeleton( path ) {
|
|
3975
|
+
|
|
3976
|
+
const attrs = this._getAttributes( path );
|
|
3977
|
+
|
|
3978
|
+
// Get joint names (paths like "root", "root/body_joint", etc.)
|
|
3979
|
+
const joints = attrs[ 'joints' ];
|
|
3980
|
+
if ( ! joints || joints.length === 0 ) return null;
|
|
3981
|
+
|
|
3982
|
+
// Get bind transforms (world-space bind pose matrices)
|
|
3983
|
+
// These can be nested arrays (USDA) or flat arrays (USDC)
|
|
3984
|
+
const rawBindTransforms = attrs[ 'bindTransforms' ];
|
|
3985
|
+
const rawRestTransforms = attrs[ 'restTransforms' ];
|
|
3986
|
+
|
|
3987
|
+
const bindTransforms = this._flattenMatrixArray( rawBindTransforms, joints.length );
|
|
3988
|
+
const restTransforms = this._flattenMatrixArray( rawRestTransforms, joints.length );
|
|
3989
|
+
|
|
3990
|
+
// Build bones
|
|
3991
|
+
const bones = [];
|
|
3992
|
+
const bonesByPath = {};
|
|
3993
|
+
const boneInverses = [];
|
|
3994
|
+
|
|
3995
|
+
for ( let i = 0; i < joints.length; i ++ ) {
|
|
3996
|
+
|
|
3997
|
+
const jointPath = joints[ i ];
|
|
3998
|
+
const jointName = jointPath.split( '/' ).pop();
|
|
3999
|
+
|
|
4000
|
+
const bone = new Bone();
|
|
4001
|
+
bone.name = jointName;
|
|
4002
|
+
bones.push( bone );
|
|
4003
|
+
bonesByPath[ jointPath ] = { bone, index: i };
|
|
4004
|
+
|
|
4005
|
+
// Compute inverse bind matrix
|
|
4006
|
+
if ( bindTransforms && bindTransforms.length >= ( i + 1 ) * 16 ) {
|
|
4007
|
+
|
|
4008
|
+
const bindMatrix = new Matrix4();
|
|
4009
|
+
// USD matrices are row-major, Three.js is column-major - need to transpose
|
|
4010
|
+
const m = bindTransforms.slice( i * 16, ( i + 1 ) * 16 );
|
|
4011
|
+
bindMatrix.set(
|
|
4012
|
+
m[ 0 ], m[ 4 ], m[ 8 ], m[ 12 ],
|
|
4013
|
+
m[ 1 ], m[ 5 ], m[ 9 ], m[ 13 ],
|
|
4014
|
+
m[ 2 ], m[ 6 ], m[ 10 ], m[ 14 ],
|
|
4015
|
+
m[ 3 ], m[ 7 ], m[ 11 ], m[ 15 ]
|
|
4016
|
+
);
|
|
4017
|
+
const inverseBindMatrix = bindMatrix.clone().invert();
|
|
4018
|
+
boneInverses.push( inverseBindMatrix );
|
|
4019
|
+
|
|
4020
|
+
} else {
|
|
4021
|
+
|
|
4022
|
+
boneInverses.push( new Matrix4() );
|
|
4023
|
+
|
|
4024
|
+
}
|
|
4025
|
+
|
|
4026
|
+
}
|
|
4027
|
+
|
|
4028
|
+
// Build parent-child relationships based on joint paths
|
|
4029
|
+
for ( let i = 0; i < joints.length; i ++ ) {
|
|
4030
|
+
|
|
4031
|
+
const jointPath = joints[ i ];
|
|
4032
|
+
const parts = jointPath.split( '/' );
|
|
4033
|
+
|
|
4034
|
+
if ( parts.length > 1 ) {
|
|
4035
|
+
|
|
4036
|
+
const parentPath = parts.slice( 0, - 1 ).join( '/' );
|
|
4037
|
+
const parentData = bonesByPath[ parentPath ];
|
|
4038
|
+
|
|
4039
|
+
if ( parentData ) {
|
|
4040
|
+
|
|
4041
|
+
parentData.bone.add( bones[ i ] );
|
|
4042
|
+
|
|
4043
|
+
}
|
|
4044
|
+
|
|
4045
|
+
}
|
|
4046
|
+
|
|
4047
|
+
}
|
|
4048
|
+
|
|
4049
|
+
// Apply rest transforms as bone local transforms.
|
|
4050
|
+
// Rest transforms are the skeleton's default local-space pose and match
|
|
4051
|
+
// the reference frame used by SkelAnimation data. Bind transforms are
|
|
4052
|
+
// world-space matrices used only for computing inverse bind matrices.
|
|
4053
|
+
if ( restTransforms && restTransforms.length >= joints.length * 16 ) {
|
|
4054
|
+
|
|
4055
|
+
for ( let i = 0; i < joints.length; i ++ ) {
|
|
4056
|
+
|
|
4057
|
+
const matrix = new Matrix4();
|
|
4058
|
+
const m = restTransforms.slice( i * 16, ( i + 1 ) * 16 );
|
|
4059
|
+
matrix.set(
|
|
4060
|
+
m[ 0 ], m[ 4 ], m[ 8 ], m[ 12 ],
|
|
4061
|
+
m[ 1 ], m[ 5 ], m[ 9 ], m[ 13 ],
|
|
4062
|
+
m[ 2 ], m[ 6 ], m[ 10 ], m[ 14 ],
|
|
4063
|
+
m[ 3 ], m[ 7 ], m[ 11 ], m[ 15 ]
|
|
4064
|
+
);
|
|
4065
|
+
matrix.decompose( bones[ i ].position, bones[ i ].quaternion, bones[ i ].scale );
|
|
4066
|
+
|
|
4067
|
+
}
|
|
4068
|
+
|
|
4069
|
+
}
|
|
4070
|
+
|
|
4071
|
+
// Find root bone(s) - bones without a parent bone
|
|
4072
|
+
const rootBones = bones.filter( bone => ! bone.parent || ! bone.parent.isBone );
|
|
4073
|
+
|
|
4074
|
+
// Get animation source path
|
|
4075
|
+
const animSourceSpec = this.specsByPath[ path + '.skel:animationSource' ];
|
|
4076
|
+
let animationPath = null;
|
|
4077
|
+
if ( animSourceSpec && animSourceSpec.fields.targetPaths && animSourceSpec.fields.targetPaths.length > 0 ) {
|
|
4078
|
+
|
|
4079
|
+
animationPath = animSourceSpec.fields.targetPaths[ 0 ];
|
|
4080
|
+
|
|
4081
|
+
}
|
|
4082
|
+
|
|
4083
|
+
return {
|
|
4084
|
+
skeleton: new Skeleton( bones, boneInverses ),
|
|
4085
|
+
joints: joints,
|
|
4086
|
+
rootBones: rootBones,
|
|
4087
|
+
animationPath: animationPath,
|
|
4088
|
+
path: path
|
|
4089
|
+
};
|
|
4090
|
+
|
|
4091
|
+
}
|
|
4092
|
+
|
|
4093
|
+
_bindSkeletons() {
|
|
4094
|
+
|
|
4095
|
+
for ( const meshData of this.skinnedMeshes ) {
|
|
4096
|
+
|
|
4097
|
+
const { mesh, skeletonPath, localJoints, geomBindTransform } = meshData;
|
|
4098
|
+
|
|
4099
|
+
let skeletonData = null;
|
|
4100
|
+
|
|
4101
|
+
// Try exact match first
|
|
4102
|
+
if ( skeletonPath && this.skeletons[ skeletonPath ] ) {
|
|
4103
|
+
|
|
4104
|
+
skeletonData = this.skeletons[ skeletonPath ];
|
|
4105
|
+
|
|
4106
|
+
}
|
|
4107
|
+
|
|
4108
|
+
// Try includes match as fallback
|
|
4109
|
+
if ( ! skeletonData ) {
|
|
4110
|
+
|
|
4111
|
+
for ( const skelPath in this.skeletons ) {
|
|
4112
|
+
|
|
4113
|
+
if ( skeletonPath && ( skeletonPath.includes( skelPath ) || skelPath.includes( skeletonPath ) ) ) {
|
|
4114
|
+
|
|
4115
|
+
skeletonData = this.skeletons[ skelPath ];
|
|
4116
|
+
break;
|
|
4117
|
+
|
|
4118
|
+
}
|
|
4119
|
+
|
|
4120
|
+
}
|
|
4121
|
+
|
|
4122
|
+
}
|
|
4123
|
+
|
|
4124
|
+
// Fallback to first skeleton for single-skeleton files
|
|
4125
|
+
if ( ! skeletonData ) {
|
|
4126
|
+
|
|
4127
|
+
const skeletonPaths = Object.keys( this.skeletons );
|
|
4128
|
+
if ( skeletonPaths.length > 0 ) {
|
|
4129
|
+
|
|
4130
|
+
skeletonData = this.skeletons[ skeletonPaths[ 0 ] ];
|
|
4131
|
+
|
|
4132
|
+
}
|
|
4133
|
+
|
|
4134
|
+
}
|
|
4135
|
+
|
|
4136
|
+
if ( ! skeletonData ) {
|
|
4137
|
+
|
|
4138
|
+
console.warn( 'USDComposer: No skeleton found for skinned mesh', mesh.name );
|
|
4139
|
+
continue;
|
|
4140
|
+
|
|
4141
|
+
}
|
|
4142
|
+
|
|
4143
|
+
const { skeleton, rootBones, joints } = skeletonData;
|
|
4144
|
+
|
|
4145
|
+
if ( localJoints && localJoints.length > 0 ) {
|
|
4146
|
+
|
|
4147
|
+
const skinIndex = mesh.geometry.attributes.skinIndex;
|
|
4148
|
+
if ( skinIndex ) {
|
|
4149
|
+
|
|
4150
|
+
const localToGlobal = [];
|
|
4151
|
+
for ( let i = 0; i < localJoints.length; i ++ ) {
|
|
4152
|
+
|
|
4153
|
+
const jointName = localJoints[ i ];
|
|
4154
|
+
const globalIdx = joints.indexOf( jointName );
|
|
4155
|
+
localToGlobal[ i ] = globalIdx >= 0 ? globalIdx : 0;
|
|
4156
|
+
|
|
4157
|
+
}
|
|
4158
|
+
|
|
4159
|
+
const arr = skinIndex.array;
|
|
4160
|
+
for ( let i = 0; i < arr.length; i ++ ) {
|
|
4161
|
+
|
|
4162
|
+
const localIdx = arr[ i ];
|
|
4163
|
+
if ( localIdx < localToGlobal.length ) {
|
|
4164
|
+
|
|
4165
|
+
arr[ i ] = localToGlobal[ localIdx ];
|
|
4166
|
+
|
|
4167
|
+
}
|
|
4168
|
+
|
|
4169
|
+
}
|
|
4170
|
+
|
|
4171
|
+
}
|
|
4172
|
+
|
|
4173
|
+
}
|
|
4174
|
+
|
|
4175
|
+
for ( const rootBone of rootBones ) {
|
|
4176
|
+
|
|
4177
|
+
mesh.add( rootBone );
|
|
4178
|
+
|
|
4179
|
+
}
|
|
4180
|
+
|
|
4181
|
+
// Use geomBindTransform if available, otherwise fall back to identity.
|
|
4182
|
+
// Estimating bind transforms from vertex/joint samples is not robust and can
|
|
4183
|
+
// produce severe skinning distortion for valid assets.
|
|
4184
|
+
const bindMatrix = new Matrix4();
|
|
4185
|
+
|
|
4186
|
+
if ( geomBindTransform && geomBindTransform.length === 16 ) {
|
|
4187
|
+
|
|
4188
|
+
// USD matrices are row-major, Three.js is column-major - need to transpose
|
|
4189
|
+
const m = geomBindTransform;
|
|
4190
|
+
bindMatrix.set(
|
|
4191
|
+
m[ 0 ], m[ 4 ], m[ 8 ], m[ 12 ],
|
|
4192
|
+
m[ 1 ], m[ 5 ], m[ 9 ], m[ 13 ],
|
|
4193
|
+
m[ 2 ], m[ 6 ], m[ 10 ], m[ 14 ],
|
|
4194
|
+
m[ 3 ], m[ 7 ], m[ 11 ], m[ 15 ]
|
|
4195
|
+
);
|
|
4196
|
+
|
|
4197
|
+
}
|
|
4198
|
+
|
|
4199
|
+
mesh.bind( skeleton, bindMatrix );
|
|
4200
|
+
|
|
4201
|
+
}
|
|
4202
|
+
|
|
4203
|
+
}
|
|
4204
|
+
|
|
4205
|
+
_buildAnimations() {
|
|
4206
|
+
|
|
4207
|
+
const animations = [];
|
|
4208
|
+
|
|
4209
|
+
// Find all SkelAnimation prims
|
|
4210
|
+
for ( const path in this.specsByPath ) {
|
|
4211
|
+
|
|
4212
|
+
const spec = this.specsByPath[ path ];
|
|
4213
|
+
if ( spec.specType !== SpecType.Prim ) continue;
|
|
4214
|
+
if ( spec.fields.typeName !== 'SkelAnimation' ) continue;
|
|
4215
|
+
|
|
4216
|
+
const clip = this._buildAnimationClip( path );
|
|
4217
|
+
if ( clip ) {
|
|
4218
|
+
|
|
4219
|
+
animations.push( clip );
|
|
4220
|
+
|
|
4221
|
+
}
|
|
4222
|
+
|
|
4223
|
+
}
|
|
4224
|
+
|
|
4225
|
+
// Build transform animations from time-sampled xformOps
|
|
4226
|
+
const transformTracks = this._buildTransformAnimations();
|
|
4227
|
+
if ( transformTracks.length > 0 ) {
|
|
4228
|
+
|
|
4229
|
+
animations.push( new AnimationClip( 'TransformAnimation', - 1, transformTracks ) );
|
|
4230
|
+
|
|
4231
|
+
}
|
|
4232
|
+
|
|
4233
|
+
return animations;
|
|
4234
|
+
|
|
4235
|
+
}
|
|
4236
|
+
|
|
4237
|
+
_buildTransformAnimations() {
|
|
4238
|
+
|
|
4239
|
+
const tracks = [];
|
|
4240
|
+
|
|
4241
|
+
for ( const path in this.specsByPath ) {
|
|
4242
|
+
|
|
4243
|
+
const spec = this.specsByPath[ path ];
|
|
4244
|
+
if ( spec.specType !== SpecType.Prim ) continue;
|
|
4245
|
+
|
|
4246
|
+
const typeName = spec.fields?.typeName;
|
|
4247
|
+
if ( typeName !== 'Xform' && typeName !== 'Scope' && typeName !== 'Mesh' ) continue;
|
|
4248
|
+
|
|
4249
|
+
const objectName = path.split( '/' ).pop();
|
|
4250
|
+
|
|
4251
|
+
// Check for animated xformOp:orient
|
|
4252
|
+
const orientPath = path + '.xformOp:orient';
|
|
4253
|
+
const orientSpec = this.specsByPath[ orientPath ];
|
|
4254
|
+
if ( orientSpec?.fields?.timeSamples ) {
|
|
4255
|
+
|
|
4256
|
+
const { times, values } = orientSpec.fields.timeSamples;
|
|
4257
|
+
const keyframeTimes = [];
|
|
4258
|
+
const keyframeValues = [];
|
|
4259
|
+
|
|
4260
|
+
for ( let i = 0; i < times.length; i ++ ) {
|
|
4261
|
+
|
|
4262
|
+
keyframeTimes.push( times[ i ] / this.fps );
|
|
4263
|
+
|
|
4264
|
+
const q = values[ i ];
|
|
4265
|
+
keyframeValues.push( q[ 0 ], q[ 1 ], q[ 2 ], q[ 3 ] );
|
|
4266
|
+
|
|
4267
|
+
}
|
|
4268
|
+
|
|
4269
|
+
if ( keyframeTimes.length > 0 ) {
|
|
4270
|
+
|
|
4271
|
+
tracks.push( new QuaternionKeyframeTrack(
|
|
4272
|
+
objectName + '.quaternion',
|
|
4273
|
+
new Float32Array( keyframeTimes ),
|
|
4274
|
+
new Float32Array( keyframeValues )
|
|
4275
|
+
) );
|
|
4276
|
+
|
|
4277
|
+
}
|
|
4278
|
+
|
|
4279
|
+
}
|
|
4280
|
+
|
|
4281
|
+
// Check for animated xformOp:rotateXYZ
|
|
4282
|
+
const rotateXYZPath = path + '.xformOp:rotateXYZ';
|
|
4283
|
+
const rotateXYZSpec = this.specsByPath[ rotateXYZPath ];
|
|
4284
|
+
if ( rotateXYZSpec?.fields?.timeSamples ) {
|
|
4285
|
+
|
|
4286
|
+
const { times, values } = rotateXYZSpec.fields.timeSamples;
|
|
4287
|
+
const keyframeTimes = [];
|
|
4288
|
+
const keyframeValues = [];
|
|
4289
|
+
const tempEuler = new Euler();
|
|
4290
|
+
const tempQuat = new Quaternion();
|
|
4291
|
+
|
|
4292
|
+
for ( let i = 0; i < times.length; i ++ ) {
|
|
4293
|
+
|
|
4294
|
+
keyframeTimes.push( times[ i ] / this.fps );
|
|
4295
|
+
|
|
4296
|
+
const r = values[ i ];
|
|
4297
|
+
// USD rotateXYZ: matrix = Rx * Ry * Rz, use 'ZYX' order in Three.js
|
|
4298
|
+
tempEuler.set(
|
|
4299
|
+
r[ 0 ] * Math.PI / 180,
|
|
4300
|
+
r[ 1 ] * Math.PI / 180,
|
|
4301
|
+
r[ 2 ] * Math.PI / 180,
|
|
4302
|
+
'ZYX'
|
|
4303
|
+
);
|
|
4304
|
+
tempQuat.setFromEuler( tempEuler );
|
|
4305
|
+
keyframeValues.push( tempQuat.x, tempQuat.y, tempQuat.z, tempQuat.w );
|
|
4306
|
+
|
|
4307
|
+
}
|
|
4308
|
+
|
|
4309
|
+
if ( keyframeTimes.length > 0 ) {
|
|
4310
|
+
|
|
4311
|
+
tracks.push( new QuaternionKeyframeTrack(
|
|
4312
|
+
objectName + '.quaternion',
|
|
4313
|
+
new Float32Array( keyframeTimes ),
|
|
4314
|
+
new Float32Array( keyframeValues )
|
|
4315
|
+
) );
|
|
4316
|
+
|
|
4317
|
+
}
|
|
4318
|
+
|
|
4319
|
+
}
|
|
4320
|
+
|
|
4321
|
+
// Check for animated xformOp:translate
|
|
4322
|
+
const translatePath = path + '.xformOp:translate';
|
|
4323
|
+
const translateSpec = this.specsByPath[ translatePath ];
|
|
4324
|
+
if ( translateSpec?.fields?.timeSamples ) {
|
|
4325
|
+
|
|
4326
|
+
const { times, values } = translateSpec.fields.timeSamples;
|
|
4327
|
+
const keyframeTimes = [];
|
|
4328
|
+
const keyframeValues = [];
|
|
4329
|
+
|
|
4330
|
+
for ( let i = 0; i < times.length; i ++ ) {
|
|
4331
|
+
|
|
4332
|
+
keyframeTimes.push( times[ i ] / this.fps );
|
|
4333
|
+
|
|
4334
|
+
const t = values[ i ];
|
|
4335
|
+
keyframeValues.push( t[ 0 ], t[ 1 ], t[ 2 ] );
|
|
4336
|
+
|
|
4337
|
+
}
|
|
4338
|
+
|
|
4339
|
+
if ( keyframeTimes.length > 0 ) {
|
|
4340
|
+
|
|
4341
|
+
tracks.push( new VectorKeyframeTrack(
|
|
4342
|
+
objectName + '.position',
|
|
4343
|
+
new Float32Array( keyframeTimes ),
|
|
4344
|
+
new Float32Array( keyframeValues )
|
|
4345
|
+
) );
|
|
4346
|
+
|
|
4347
|
+
}
|
|
4348
|
+
|
|
4349
|
+
}
|
|
4350
|
+
|
|
4351
|
+
// Check for animated xformOp:scale
|
|
4352
|
+
const scalePath = path + '.xformOp:scale';
|
|
4353
|
+
const scaleSpec = this.specsByPath[ scalePath ];
|
|
4354
|
+
if ( scaleSpec?.fields?.timeSamples ) {
|
|
4355
|
+
|
|
4356
|
+
const { times, values } = scaleSpec.fields.timeSamples;
|
|
4357
|
+
const keyframeTimes = [];
|
|
4358
|
+
const keyframeValues = [];
|
|
4359
|
+
|
|
4360
|
+
for ( let i = 0; i < times.length; i ++ ) {
|
|
4361
|
+
|
|
4362
|
+
keyframeTimes.push( times[ i ] / this.fps );
|
|
4363
|
+
|
|
4364
|
+
const s = values[ i ];
|
|
4365
|
+
keyframeValues.push( s[ 0 ], s[ 1 ], s[ 2 ] );
|
|
4366
|
+
|
|
4367
|
+
}
|
|
4368
|
+
|
|
4369
|
+
if ( keyframeTimes.length > 0 ) {
|
|
4370
|
+
|
|
4371
|
+
tracks.push( new VectorKeyframeTrack(
|
|
4372
|
+
objectName + '.scale',
|
|
4373
|
+
new Float32Array( keyframeTimes ),
|
|
4374
|
+
new Float32Array( keyframeValues )
|
|
4375
|
+
) );
|
|
4376
|
+
|
|
4377
|
+
}
|
|
4378
|
+
|
|
4379
|
+
}
|
|
4380
|
+
|
|
4381
|
+
// Check for animated xformOp:transform (matrix animations)
|
|
4382
|
+
// These can have suffixes like xformOp:transform:transform
|
|
4383
|
+
const properties = spec.fields?.properties || [];
|
|
4384
|
+
for ( const prop of properties ) {
|
|
4385
|
+
|
|
4386
|
+
if ( ! prop.startsWith( 'xformOp:transform' ) ) continue;
|
|
4387
|
+
|
|
4388
|
+
const transformPath = path + '.' + prop;
|
|
4389
|
+
const transformSpec = this.specsByPath[ transformPath ];
|
|
4390
|
+
|
|
4391
|
+
if ( ! transformSpec?.fields?.timeSamples ) continue;
|
|
4392
|
+
|
|
4393
|
+
const { times, values } = transformSpec.fields.timeSamples;
|
|
4394
|
+
const positionTimes = [];
|
|
4395
|
+
const positionValues = [];
|
|
4396
|
+
const quaternionTimes = [];
|
|
4397
|
+
const quaternionValues = [];
|
|
4398
|
+
const scaleTimes = [];
|
|
4399
|
+
const scaleValues = [];
|
|
4400
|
+
|
|
4401
|
+
const matrix = new Matrix4();
|
|
4402
|
+
const position = new Vector3();
|
|
4403
|
+
const quaternion = new Quaternion();
|
|
4404
|
+
const scale = new Vector3();
|
|
4405
|
+
|
|
4406
|
+
for ( let i = 0; i < times.length; i ++ ) {
|
|
4407
|
+
|
|
4408
|
+
const m = values[ i ];
|
|
4409
|
+
if ( ! m || m.length < 16 ) continue;
|
|
4410
|
+
|
|
4411
|
+
const t = times[ i ] / this.fps;
|
|
4412
|
+
|
|
4413
|
+
// USD matrices are row-major, Three.js is column-major
|
|
4414
|
+
matrix.set(
|
|
4415
|
+
m[ 0 ], m[ 4 ], m[ 8 ], m[ 12 ],
|
|
4416
|
+
m[ 1 ], m[ 5 ], m[ 9 ], m[ 13 ],
|
|
4417
|
+
m[ 2 ], m[ 6 ], m[ 10 ], m[ 14 ],
|
|
4418
|
+
m[ 3 ], m[ 7 ], m[ 11 ], m[ 15 ]
|
|
4419
|
+
);
|
|
4420
|
+
|
|
4421
|
+
matrix.decompose( position, quaternion, scale );
|
|
4422
|
+
|
|
4423
|
+
positionTimes.push( t );
|
|
4424
|
+
positionValues.push( position.x, position.y, position.z );
|
|
4425
|
+
|
|
4426
|
+
quaternionTimes.push( t );
|
|
4427
|
+
quaternionValues.push( quaternion.x, quaternion.y, quaternion.z, quaternion.w );
|
|
4428
|
+
|
|
4429
|
+
scaleTimes.push( t );
|
|
4430
|
+
scaleValues.push( scale.x, scale.y, scale.z );
|
|
4431
|
+
|
|
4432
|
+
}
|
|
4433
|
+
|
|
4434
|
+
if ( positionTimes.length > 0 ) {
|
|
4435
|
+
|
|
4436
|
+
tracks.push( new VectorKeyframeTrack(
|
|
4437
|
+
objectName + '.position',
|
|
4438
|
+
new Float32Array( positionTimes ),
|
|
4439
|
+
new Float32Array( positionValues )
|
|
4440
|
+
) );
|
|
4441
|
+
|
|
4442
|
+
tracks.push( new QuaternionKeyframeTrack(
|
|
4443
|
+
objectName + '.quaternion',
|
|
4444
|
+
new Float32Array( quaternionTimes ),
|
|
4445
|
+
new Float32Array( quaternionValues )
|
|
4446
|
+
) );
|
|
4447
|
+
|
|
4448
|
+
tracks.push( new VectorKeyframeTrack(
|
|
4449
|
+
objectName + '.scale',
|
|
4450
|
+
new Float32Array( scaleTimes ),
|
|
4451
|
+
new Float32Array( scaleValues )
|
|
4452
|
+
) );
|
|
4453
|
+
|
|
4454
|
+
}
|
|
4455
|
+
|
|
4456
|
+
break; // Only process first transform op
|
|
4457
|
+
|
|
4458
|
+
}
|
|
4459
|
+
|
|
4460
|
+
}
|
|
4461
|
+
|
|
4462
|
+
return tracks;
|
|
4463
|
+
|
|
4464
|
+
}
|
|
4465
|
+
|
|
4466
|
+
_buildAnimationClip( path ) {
|
|
4467
|
+
|
|
4468
|
+
const attrs = this._getAttributes( path );
|
|
4469
|
+
const joints = attrs[ 'joints' ];
|
|
4470
|
+
|
|
4471
|
+
if ( ! joints || joints.length === 0 ) return null;
|
|
4472
|
+
|
|
4473
|
+
const tracks = [];
|
|
4474
|
+
|
|
4475
|
+
// Get rotation time samples
|
|
4476
|
+
const rotationsAttr = this._getTimeSampledAttribute( path, 'rotations' );
|
|
4477
|
+
if ( rotationsAttr && rotationsAttr.times && rotationsAttr.values ) {
|
|
4478
|
+
|
|
4479
|
+
const { times, values } = rotationsAttr;
|
|
4480
|
+
|
|
4481
|
+
for ( let jointIdx = 0; jointIdx < joints.length; jointIdx ++ ) {
|
|
4482
|
+
|
|
4483
|
+
const jointName = joints[ jointIdx ].split( '/' ).pop();
|
|
4484
|
+
const keyframeTimes = [];
|
|
4485
|
+
const keyframeValues = [];
|
|
4486
|
+
|
|
4487
|
+
for ( let t = 0; t < times.length; t ++ ) {
|
|
4488
|
+
|
|
4489
|
+
const quatData = values[ t ];
|
|
4490
|
+
if ( ! quatData || quatData.length < ( jointIdx + 1 ) * 4 ) continue;
|
|
4491
|
+
|
|
4492
|
+
keyframeTimes.push( times[ t ] / this.fps );
|
|
4493
|
+
|
|
4494
|
+
// USD GfQuatf stores imaginary (x,y,z) first, then real (w)
|
|
4495
|
+
// This matches Three.js quaternion order (x,y,z,w)
|
|
4496
|
+
const x = quatData[ jointIdx * 4 + 0 ];
|
|
4497
|
+
const y = quatData[ jointIdx * 4 + 1 ];
|
|
4498
|
+
const z = quatData[ jointIdx * 4 + 2 ];
|
|
4499
|
+
const w = quatData[ jointIdx * 4 + 3 ];
|
|
4500
|
+
keyframeValues.push( x, y, z, w );
|
|
4501
|
+
|
|
4502
|
+
}
|
|
4503
|
+
|
|
4504
|
+
if ( keyframeTimes.length > 0 ) {
|
|
4505
|
+
|
|
4506
|
+
tracks.push( new QuaternionKeyframeTrack(
|
|
4507
|
+
jointName + '.quaternion',
|
|
4508
|
+
new Float32Array( keyframeTimes ),
|
|
4509
|
+
new Float32Array( keyframeValues )
|
|
4510
|
+
) );
|
|
4511
|
+
|
|
4512
|
+
}
|
|
4513
|
+
|
|
4514
|
+
}
|
|
4515
|
+
|
|
4516
|
+
}
|
|
4517
|
+
|
|
4518
|
+
// Get translation time samples
|
|
4519
|
+
const translationsAttr = this._getTimeSampledAttribute( path, 'translations' );
|
|
4520
|
+
if ( translationsAttr && translationsAttr.times && translationsAttr.values ) {
|
|
4521
|
+
|
|
4522
|
+
const { times, values } = translationsAttr;
|
|
4523
|
+
|
|
4524
|
+
for ( let jointIdx = 0; jointIdx < joints.length; jointIdx ++ ) {
|
|
4525
|
+
|
|
4526
|
+
const jointName = joints[ jointIdx ].split( '/' ).pop();
|
|
4527
|
+
const keyframeTimes = [];
|
|
4528
|
+
const keyframeValues = [];
|
|
4529
|
+
|
|
4530
|
+
for ( let t = 0; t < times.length; t ++ ) {
|
|
4531
|
+
|
|
4532
|
+
const transData = values[ t ];
|
|
4533
|
+
if ( ! transData || transData.length < ( jointIdx + 1 ) * 3 ) continue;
|
|
4534
|
+
|
|
4535
|
+
keyframeTimes.push( times[ t ] / this.fps );
|
|
4536
|
+
keyframeValues.push(
|
|
4537
|
+
transData[ jointIdx * 3 + 0 ],
|
|
4538
|
+
transData[ jointIdx * 3 + 1 ],
|
|
4539
|
+
transData[ jointIdx * 3 + 2 ]
|
|
4540
|
+
);
|
|
4541
|
+
|
|
4542
|
+
}
|
|
4543
|
+
|
|
4544
|
+
if ( keyframeTimes.length > 0 ) {
|
|
4545
|
+
|
|
4546
|
+
tracks.push( new VectorKeyframeTrack(
|
|
4547
|
+
jointName + '.position',
|
|
4548
|
+
new Float32Array( keyframeTimes ),
|
|
4549
|
+
new Float32Array( keyframeValues )
|
|
4550
|
+
) );
|
|
4551
|
+
|
|
4552
|
+
}
|
|
4553
|
+
|
|
4554
|
+
}
|
|
4555
|
+
|
|
4556
|
+
}
|
|
4557
|
+
|
|
4558
|
+
// Get scale time samples
|
|
4559
|
+
const scalesAttr = this._getTimeSampledAttribute( path, 'scales' );
|
|
4560
|
+
if ( scalesAttr && scalesAttr.times && scalesAttr.values ) {
|
|
4561
|
+
|
|
4562
|
+
const { times, values } = scalesAttr;
|
|
4563
|
+
|
|
4564
|
+
for ( let jointIdx = 0; jointIdx < joints.length; jointIdx ++ ) {
|
|
4565
|
+
|
|
4566
|
+
const jointName = joints[ jointIdx ].split( '/' ).pop();
|
|
4567
|
+
const keyframeTimes = [];
|
|
4568
|
+
const keyframeValues = [];
|
|
4569
|
+
|
|
4570
|
+
for ( let t = 0; t < times.length; t ++ ) {
|
|
4571
|
+
|
|
4572
|
+
const scaleData = values[ t ];
|
|
4573
|
+
if ( ! scaleData || scaleData.length < ( jointIdx + 1 ) * 3 ) continue;
|
|
4574
|
+
|
|
4575
|
+
keyframeTimes.push( times[ t ] / this.fps );
|
|
4576
|
+
keyframeValues.push(
|
|
4577
|
+
scaleData[ jointIdx * 3 + 0 ],
|
|
4578
|
+
scaleData[ jointIdx * 3 + 1 ],
|
|
4579
|
+
scaleData[ jointIdx * 3 + 2 ]
|
|
4580
|
+
);
|
|
4581
|
+
|
|
4582
|
+
}
|
|
4583
|
+
|
|
4584
|
+
if ( keyframeTimes.length > 0 ) {
|
|
4585
|
+
|
|
4586
|
+
tracks.push( new VectorKeyframeTrack(
|
|
4587
|
+
jointName + '.scale',
|
|
4588
|
+
new Float32Array( keyframeTimes ),
|
|
4589
|
+
new Float32Array( keyframeValues )
|
|
4590
|
+
) );
|
|
4591
|
+
|
|
4592
|
+
}
|
|
4593
|
+
|
|
4594
|
+
}
|
|
4595
|
+
|
|
4596
|
+
}
|
|
4597
|
+
|
|
4598
|
+
if ( tracks.length === 0 ) return null;
|
|
4599
|
+
|
|
4600
|
+
const clipName = path.split( '/' ).pop();
|
|
4601
|
+
return new AnimationClip( clipName, - 1, tracks );
|
|
4602
|
+
|
|
4603
|
+
}
|
|
4604
|
+
|
|
4605
|
+
_getTimeSampledAttribute( primPath, attrName ) {
|
|
4606
|
+
|
|
4607
|
+
// Look for the attribute spec with time samples
|
|
4608
|
+
const attrPath = primPath + '.' + attrName;
|
|
4609
|
+
const attrSpec = this.specsByPath[ attrPath ];
|
|
4610
|
+
|
|
4611
|
+
if ( attrSpec && attrSpec.fields.timeSamples ) {
|
|
4612
|
+
|
|
4613
|
+
const timeSamples = attrSpec.fields.timeSamples;
|
|
4614
|
+
if ( timeSamples.times && timeSamples.values ) {
|
|
4615
|
+
|
|
4616
|
+
return timeSamples;
|
|
4617
|
+
|
|
4618
|
+
}
|
|
4619
|
+
|
|
4620
|
+
}
|
|
4621
|
+
|
|
4622
|
+
return null;
|
|
4623
|
+
|
|
4624
|
+
}
|
|
4625
|
+
|
|
4626
|
+
_flattenMatrixArray( matrices, numMatrices ) {
|
|
4627
|
+
|
|
4628
|
+
if ( ! matrices || matrices.length === 0 ) return null;
|
|
4629
|
+
|
|
4630
|
+
if ( typeof matrices[ 0 ] === 'number' ) return matrices;
|
|
4631
|
+
|
|
4632
|
+
const flatArray = [];
|
|
4633
|
+
|
|
4634
|
+
for ( let m = 0; m < numMatrices; m ++ ) {
|
|
4635
|
+
|
|
4636
|
+
for ( let row = 0; row < 4; row ++ ) {
|
|
4637
|
+
|
|
4638
|
+
const rowData = matrices[ m * 4 + row ];
|
|
4639
|
+
|
|
4640
|
+
if ( rowData && rowData.length === 4 ) {
|
|
4641
|
+
|
|
4642
|
+
flatArray.push( rowData[ 0 ], rowData[ 1 ], rowData[ 2 ], rowData[ 3 ] );
|
|
4643
|
+
|
|
4644
|
+
} else {
|
|
4645
|
+
|
|
4646
|
+
flatArray.push( row === 0 ? 1 : 0, row === 1 ? 1 : 0, row === 2 ? 1 : 0, row === 3 ? 1 : 0 );
|
|
4647
|
+
|
|
4648
|
+
}
|
|
4649
|
+
|
|
4650
|
+
}
|
|
4651
|
+
|
|
4652
|
+
}
|
|
4653
|
+
|
|
4654
|
+
return flatArray;
|
|
4655
|
+
|
|
4656
|
+
}
|
|
4657
|
+
|
|
4658
|
+
}
|
|
4659
|
+
|
|
4660
|
+
export { USDComposer, SpecType };
|