@needle-tools/three 0.169.20-experimental.0 → 0.183.2-canary.0
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 +1 -1
- package/README.md +5 -6
- package/build/three.cjs +54184 -56703
- package/build/three.core.js +59506 -0
- package/build/three.core.min.js +6 -0
- package/build/three.module.js +11645 -73000
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +648 -0
- package/build/three.tsl.min.js +6 -0
- package/build/three.webgpu.js +53912 -51652
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +53888 -51806
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
- package/examples/jsm/Addons.js +5 -15
- package/examples/jsm/animation/AnimationClipCreator.js +58 -6
- package/examples/jsm/animation/CCDIKSolver.js +152 -45
- package/examples/jsm/capabilities/WebGL.js +28 -29
- package/examples/jsm/capabilities/WebGPU.js +19 -17
- package/examples/jsm/controls/ArcballControls.js +474 -178
- package/examples/jsm/controls/DragControls.js +100 -58
- package/examples/jsm/controls/FirstPersonControls.js +116 -6
- package/examples/jsm/controls/FlyControls.js +50 -2
- package/examples/jsm/controls/MapControls.js +96 -8
- package/examples/jsm/controls/OrbitControls.js +496 -57
- package/examples/jsm/controls/PointerLockControls.js +115 -22
- package/examples/jsm/controls/TrackballControls.js +166 -14
- package/examples/jsm/controls/TransformControls.js +336 -26
- package/examples/jsm/csm/CSM.js +232 -18
- package/examples/jsm/csm/CSMFrustum.js +61 -4
- package/examples/jsm/csm/CSMHelper.js +50 -0
- package/examples/jsm/csm/CSMShader.js +13 -1
- package/examples/jsm/csm/CSMShadowNode.js +599 -0
- package/examples/jsm/curves/CurveExtras.js +303 -31
- package/examples/jsm/curves/NURBSCurve.js +91 -16
- package/examples/jsm/curves/NURBSSurface.js +52 -6
- package/examples/jsm/curves/NURBSUtils.js +102 -112
- package/examples/jsm/curves/NURBSVolume.js +24 -4
- package/examples/jsm/effects/AnaglyphEffect.js +134 -7
- package/examples/jsm/effects/AsciiEffect.js +69 -22
- package/examples/jsm/effects/OutlineEffect.js +61 -111
- package/examples/jsm/effects/ParallaxBarrierEffect.js +30 -0
- package/examples/jsm/effects/StereoEffect.js +31 -0
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/DebugEnvironment.js +50 -0
- package/examples/jsm/environments/RoomEnvironment.js +83 -42
- package/examples/jsm/exporters/DRACOExporter.js +56 -14
- package/examples/jsm/exporters/EXRExporter.js +40 -9
- package/examples/jsm/exporters/GLTFExporter.js +502 -169
- package/examples/jsm/exporters/OBJExporter.js +21 -1
- package/examples/jsm/exporters/PLYExporter.js +44 -12
- package/examples/jsm/exporters/STLExporter.js +27 -5
- package/examples/jsm/exporters/USDZExporter.js +781 -291
- package/examples/jsm/geometries/BoxLineGeometry.js +23 -0
- package/examples/jsm/geometries/ConvexGeometry.js +19 -0
- package/examples/jsm/geometries/DecalGeometry.js +91 -30
- package/examples/jsm/geometries/ParametricFunctions.js +100 -0
- package/examples/jsm/geometries/ParametricGeometry.js +38 -5
- package/examples/jsm/geometries/RoundedBoxGeometry.js +68 -7
- package/examples/jsm/geometries/TeapotGeometry.js +23 -38
- package/examples/jsm/geometries/TextGeometry.js +48 -29
- package/examples/jsm/gpgpu/BitonicSort.js +715 -0
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/LightProbeHelper.js +36 -0
- package/examples/jsm/helpers/LightProbeHelperGPU.js +38 -1
- package/examples/jsm/helpers/OctreeHelper.js +36 -0
- package/examples/jsm/helpers/PositionalAudioHelper.js +60 -0
- package/examples/jsm/helpers/RapierHelper.js +59 -0
- package/examples/jsm/helpers/RectAreaLightHelper.js +36 -3
- package/examples/jsm/helpers/TextureHelper.js +28 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +214 -0
- package/examples/jsm/helpers/VertexNormalsHelper.js +61 -2
- package/examples/jsm/helpers/VertexTangentsHelper.js +47 -2
- package/examples/jsm/helpers/ViewHelper.js +181 -9
- package/examples/jsm/inspector/Inspector.js +487 -0
- package/examples/jsm/inspector/RendererInspector.js +425 -0
- package/examples/jsm/inspector/tabs/Console.js +238 -0
- package/examples/jsm/inspector/tabs/Parameters.js +348 -0
- package/examples/jsm/inspector/tabs/Performance.js +268 -0
- package/examples/jsm/inspector/tabs/Viewer.js +166 -0
- package/examples/jsm/inspector/ui/Graph.js +95 -0
- package/examples/jsm/inspector/ui/Item.js +170 -0
- package/examples/jsm/inspector/ui/List.js +75 -0
- package/examples/jsm/inspector/ui/Profiler.js +1975 -0
- package/examples/jsm/inspector/ui/Style.js +1613 -0
- package/examples/jsm/inspector/ui/Tab.js +233 -0
- package/examples/jsm/inspector/ui/Values.js +439 -0
- package/examples/jsm/inspector/ui/utils.js +56 -0
- package/examples/jsm/interactive/HTMLMesh.js +43 -12
- package/examples/jsm/interactive/InteractiveGroup.js +170 -52
- package/examples/jsm/interactive/SelectionBox.js +106 -9
- package/examples/jsm/interactive/SelectionHelper.js +76 -30
- package/examples/jsm/libs/demuxer_mp4.js +109 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +76 -58
- package/examples/jsm/libs/motion-controllers.module.js +1 -1
- package/examples/jsm/lighting/TiledLighting.js +42 -0
- package/examples/jsm/lights/LightProbeGenerator.js +44 -7
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +50 -14
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +16 -0
- package/examples/jsm/lines/Line2.js +41 -4
- package/examples/jsm/lines/LineGeometry.js +80 -2
- package/examples/jsm/lines/LineMaterial.js +105 -5
- package/examples/jsm/lines/LineSegments2.js +54 -4
- package/examples/jsm/lines/LineSegmentsGeometry.js +65 -8
- package/examples/jsm/lines/Wireframe.js +41 -4
- package/examples/jsm/lines/WireframeGeometry2.js +27 -2
- package/examples/jsm/lines/webgpu/Line2.js +28 -2
- package/examples/jsm/lines/webgpu/LineSegments2.js +59 -24
- package/examples/jsm/lines/webgpu/Wireframe.js +86 -0
- package/examples/jsm/loaders/3DMLoader.js +78 -6
- package/examples/jsm/loaders/3MFLoader.js +148 -7
- package/examples/jsm/loaders/AMFLoader.js +34 -14
- package/examples/jsm/loaders/BVHLoader.js +59 -12
- package/examples/jsm/loaders/ColladaLoader.js +61 -4027
- package/examples/jsm/loaders/DDSLoader.js +68 -1
- package/examples/jsm/loaders/DRACOLoader.js +146 -22
- package/examples/jsm/loaders/EXRLoader.js +255 -34
- package/examples/jsm/loaders/FBXLoader.js +80 -42
- package/examples/jsm/loaders/FontLoader.js +83 -6
- package/examples/jsm/loaders/GCodeLoader.js +71 -14
- package/examples/jsm/loaders/GLTFLoader.js +381 -263
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +52 -3
- package/examples/jsm/loaders/HDRLoader.js +485 -0
- package/examples/jsm/loaders/IESLoader.js +42 -0
- package/examples/jsm/loaders/KMZLoader.js +39 -6
- package/examples/jsm/loaders/KTX2Loader.js +124 -48
- package/examples/jsm/loaders/KTXLoader.js +31 -10
- package/examples/jsm/loaders/LDrawLoader.js +192 -145
- package/examples/jsm/loaders/LUT3dlLoader.js +47 -10
- package/examples/jsm/loaders/LUTCubeLoader.js +46 -9
- package/examples/jsm/loaders/LUTImageLoader.js +79 -38
- package/examples/jsm/loaders/LWOLoader.js +54 -59
- package/examples/jsm/loaders/LottieLoader.js +54 -1
- package/examples/jsm/loaders/MD2Loader.js +37 -1
- package/examples/jsm/loaders/MDDLoader.js +57 -12
- package/examples/jsm/loaders/MTLLoader.js +60 -35
- package/examples/jsm/loaders/MaterialXLoader.js +268 -34
- package/examples/jsm/loaders/NRRDLoader.js +40 -8
- package/examples/jsm/loaders/OBJLoader.js +51 -2
- package/examples/jsm/loaders/PCDLoader.js +173 -21
- package/examples/jsm/loaders/PDBLoader.js +41 -2
- package/examples/jsm/loaders/PLYLoader.js +70 -39
- package/examples/jsm/loaders/PVRLoader.js +25 -6
- package/examples/jsm/loaders/RGBELoader.js +6 -438
- package/examples/jsm/loaders/STLLoader.js +48 -38
- package/examples/jsm/loaders/SVGLoader.js +119 -25
- package/examples/jsm/loaders/TDSLoader.js +92 -74
- package/examples/jsm/loaders/TGALoader.js +23 -2
- package/examples/jsm/loaders/TIFFLoader.js +23 -0
- package/examples/jsm/loaders/TTFLoader.js +50 -3
- package/examples/jsm/loaders/USDLoader.js +279 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -858
- package/examples/jsm/loaders/UltraHDRLoader.js +338 -166
- package/examples/jsm/loaders/VOXLoader.js +688 -87
- package/examples/jsm/loaders/VRMLLoader.js +121 -12
- package/examples/jsm/loaders/VTKLoader.js +77 -25
- package/examples/jsm/loaders/XYZLoader.js +36 -0
- package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
- package/examples/jsm/loaders/lwo/IFFParser.js +77 -77
- package/examples/jsm/loaders/usd/USDAParser.js +822 -0
- package/examples/jsm/loaders/usd/USDCParser.js +1852 -0
- package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +183 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +154 -0
- package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
- package/examples/jsm/math/Capsule.js +91 -14
- package/examples/jsm/math/ColorConverter.js +22 -0
- package/examples/jsm/math/ColorSpaces.js +74 -2
- package/examples/jsm/math/ConvexHull.js +517 -93
- package/examples/jsm/math/ImprovedNoise.js +32 -15
- package/examples/jsm/math/Lut.js +113 -0
- package/examples/jsm/math/MeshSurfaceSampler.js +78 -13
- package/examples/jsm/math/OBB.js +141 -29
- package/examples/jsm/math/Octree.js +283 -7
- package/examples/jsm/math/SimplexNoise.js +68 -42
- package/examples/jsm/misc/ConvexObjectBreaker.js +45 -25
- package/examples/jsm/misc/GPUComputationRenderer.js +96 -20
- package/examples/jsm/misc/Gyroscope.js +12 -0
- package/examples/jsm/misc/MD2Character.js +117 -2
- package/examples/jsm/misc/MD2CharacterComplex.js +175 -11
- package/examples/jsm/misc/MorphAnimMesh.js +44 -0
- package/examples/jsm/misc/MorphBlendMesh.js +103 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +100 -54
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +322 -0
- package/examples/jsm/misc/RollerCoaster.js +57 -0
- package/examples/jsm/misc/TubePainter.js +437 -40
- package/examples/jsm/misc/Volume.js +123 -76
- package/examples/jsm/misc/VolumeSlice.js +95 -49
- package/examples/jsm/modifiers/CurveModifier.js +66 -38
- package/examples/jsm/modifiers/CurveModifierGPU.js +42 -19
- package/examples/jsm/modifiers/EdgeSplitModifier.js +20 -0
- package/examples/jsm/modifiers/SimplifyModifier.js +24 -10
- package/examples/jsm/modifiers/TessellateModifier.js +35 -2
- package/examples/jsm/objects/GroundedSkybox.js +25 -6
- package/examples/jsm/objects/Lensflare.js +94 -2
- package/examples/jsm/objects/LensflareMesh.js +64 -10
- package/examples/jsm/objects/MarchingCubes.js +90 -5
- package/examples/jsm/objects/Reflector.js +76 -2
- package/examples/jsm/objects/ReflectorForSSRPass.js +41 -0
- package/examples/jsm/objects/Refractor.js +62 -0
- package/examples/jsm/objects/ShadowMesh.js +54 -4
- package/examples/jsm/objects/Sky.js +106 -16
- package/examples/jsm/objects/SkyMesh.js +211 -38
- package/examples/jsm/objects/Water.js +49 -8
- package/examples/jsm/objects/Water2.js +49 -7
- package/examples/jsm/objects/Water2Mesh.js +50 -9
- package/examples/jsm/objects/WaterMesh.js +136 -43
- package/examples/jsm/physics/AmmoPhysics.js +60 -7
- package/examples/jsm/physics/JoltPhysics.js +65 -12
- package/examples/jsm/physics/RapierPhysics.js +217 -21
- package/examples/jsm/postprocessing/AfterimagePass.js +110 -29
- package/examples/jsm/postprocessing/BloomPass.js +128 -26
- package/examples/jsm/postprocessing/BokehPass.js +99 -22
- package/examples/jsm/postprocessing/ClearPass.js +54 -3
- package/examples/jsm/postprocessing/CubeTexturePass.js +82 -21
- package/examples/jsm/postprocessing/DotScreenPass.js +59 -10
- package/examples/jsm/postprocessing/EffectComposer.js +140 -6
- package/examples/jsm/postprocessing/FXAAPass.js +40 -0
- package/examples/jsm/postprocessing/FilmPass.js +54 -5
- package/examples/jsm/postprocessing/GTAOPass.js +202 -57
- package/examples/jsm/postprocessing/GlitchPass.js +86 -34
- package/examples/jsm/postprocessing/HalftonePass.js +65 -10
- package/examples/jsm/postprocessing/LUTPass.js +38 -8
- package/examples/jsm/postprocessing/MaskPass.js +91 -0
- package/examples/jsm/postprocessing/OutlinePass.js +272 -135
- package/examples/jsm/postprocessing/OutputPass.js +65 -14
- package/examples/jsm/postprocessing/Pass.js +100 -4
- package/examples/jsm/postprocessing/RenderPass.js +94 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +124 -45
- package/examples/jsm/postprocessing/RenderTransitionPass.js +120 -21
- package/examples/jsm/postprocessing/SAOPass.js +128 -55
- package/examples/jsm/postprocessing/SMAAPass.js +106 -75
- package/examples/jsm/postprocessing/SSAARenderPass.js +118 -35
- package/examples/jsm/postprocessing/SSAOPass.js +173 -60
- package/examples/jsm/postprocessing/SSRPass.js +268 -53
- package/examples/jsm/postprocessing/SavePass.js +69 -16
- package/examples/jsm/postprocessing/ShaderPass.js +65 -7
- package/examples/jsm/postprocessing/TAARenderPass.js +79 -24
- package/examples/jsm/postprocessing/TexturePass.js +72 -8
- package/examples/jsm/postprocessing/UnrealBloomPass.js +168 -59
- package/examples/jsm/renderers/CSS2DRenderer.js +98 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +111 -7
- package/examples/jsm/renderers/Projector.js +288 -32
- package/examples/jsm/renderers/SVGRenderer.js +323 -61
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +3 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +1 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +5 -1
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +12 -5
- package/examples/jsm/shaders/AfterimageShader.js +8 -3
- package/examples/jsm/shaders/BasicShader.js +8 -1
- package/examples/jsm/shaders/BleachBypassShader.js +10 -3
- package/examples/jsm/shaders/BlendShader.js +8 -1
- package/examples/jsm/shaders/BokehShader.js +9 -3
- package/examples/jsm/shaders/BokehShader2.js +11 -4
- package/examples/jsm/shaders/BrightnessContrastShader.js +10 -4
- package/examples/jsm/shaders/ColorCorrectionShader.js +8 -1
- package/examples/jsm/shaders/ColorifyShader.js +8 -1
- package/examples/jsm/shaders/ConvolutionShader.js +9 -38
- package/examples/jsm/shaders/CopyShader.js +8 -1
- package/examples/jsm/shaders/DOFMipMapShader.js +10 -3
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +10 -1
- package/examples/jsm/shaders/DigitalGlitch.js +10 -7
- package/examples/jsm/shaders/DotScreenShader.js +8 -3
- package/examples/jsm/shaders/ExposureShader.js +8 -1
- package/examples/jsm/shaders/FXAAShader.js +233 -221
- package/examples/jsm/shaders/FilmShader.js +13 -0
- package/examples/jsm/shaders/FocusShader.js +8 -3
- package/examples/jsm/shaders/FreiChenShader.js +10 -3
- package/examples/jsm/shaders/GTAOShader.js +55 -45
- package/examples/jsm/shaders/GammaCorrectionShader.js +11 -2
- package/examples/jsm/shaders/HalftoneShader.js +24 -4
- package/examples/jsm/shaders/HorizontalBlurShader.js +12 -3
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +9 -2
- package/examples/jsm/shaders/HueSaturationShader.js +10 -3
- package/examples/jsm/shaders/KaleidoShader.js +11 -4
- package/examples/jsm/shaders/LuminosityHighPassShader.js +8 -4
- package/examples/jsm/shaders/LuminosityShader.js +8 -2
- package/examples/jsm/shaders/MirrorShader.js +10 -4
- package/examples/jsm/shaders/NormalMapShader.js +7 -2
- package/examples/jsm/shaders/OutputShader.js +19 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +30 -17
- package/examples/jsm/shaders/RGBShiftShader.js +8 -1
- package/examples/jsm/shaders/SAOShader.js +27 -5
- package/examples/jsm/shaders/SMAAShader.js +24 -1
- package/examples/jsm/shaders/SSAOShader.js +37 -6
- package/examples/jsm/shaders/SSRShader.js +32 -6
- package/examples/jsm/shaders/SepiaShader.js +8 -3
- package/examples/jsm/shaders/SobelOperatorShader.js +9 -3
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +13 -8
- package/examples/jsm/shaders/TechnicolorShader.js +10 -4
- package/examples/jsm/shaders/ToonShader.js +29 -6
- package/examples/jsm/shaders/TriangleBlurShader.js +9 -4
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +19 -6
- package/examples/jsm/shaders/VelocityShader.js +8 -1
- package/examples/jsm/shaders/VerticalBlurShader.js +9 -2
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +8 -1
- package/examples/jsm/shaders/VignetteShader.js +8 -3
- package/examples/jsm/shaders/VolumeShader.js +11 -2
- package/examples/jsm/shaders/WaterRefractionShader.js +11 -0
- package/examples/jsm/textures/FlakesTexture.js +14 -0
- package/examples/jsm/transpiler/AST.js +436 -31
- package/examples/jsm/transpiler/GLSLDecoder.js +380 -135
- package/examples/jsm/transpiler/Linker.js +327 -0
- package/examples/jsm/transpiler/ShaderToyDecoder.js +3 -1
- package/examples/jsm/transpiler/TSLEncoder.js +363 -97
- package/examples/jsm/transpiler/Transpiler.js +50 -1
- package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
- package/examples/jsm/transpiler/WGSLEncoder.js +839 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +244 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +549 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +282 -0
- package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
- package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +11 -4
- package/examples/jsm/tsl/display/BloomNode.js +534 -0
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +207 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +334 -0
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +554 -0
- package/examples/jsm/tsl/display/DotScreenNode.js +104 -0
- package/examples/jsm/tsl/display/FXAANode.js +365 -0
- package/examples/jsm/tsl/display/FilmNode.js +101 -0
- package/examples/jsm/tsl/display/GTAONode.js +571 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +389 -0
- package/examples/jsm/tsl/display/GodraysNode.js +624 -0
- package/examples/jsm/tsl/display/LensflareNode.js +279 -0
- package/examples/jsm/tsl/display/Lut3DNode.js +109 -0
- package/examples/jsm/tsl/display/MotionBlur.js +33 -0
- package/examples/jsm/tsl/display/OutlineNode.js +762 -0
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +89 -0
- package/examples/jsm/tsl/display/PixelationPassNode.js +335 -0
- package/examples/jsm/tsl/display/RGBShiftNode.js +96 -0
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +768 -0
- package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +120 -49
- package/examples/jsm/tsl/display/SSGINode.js +642 -0
- package/examples/jsm/tsl/display/SSRNode.js +656 -0
- package/examples/jsm/tsl/display/SSSNode.js +490 -0
- package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +9 -2
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +61 -19
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +192 -0
- package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +48 -12
- package/examples/jsm/tsl/display/TRAANode.js +726 -0
- package/examples/jsm/tsl/display/TransitionNode.js +141 -0
- package/examples/jsm/tsl/display/boxBlur.js +65 -0
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/display/hashBlur.js +54 -0
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +442 -0
- package/examples/jsm/tsl/math/Bayer.js +73 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.js +456 -0
- package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +212 -0
- package/examples/jsm/tsl/utils/Raymarching.js +70 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +91 -29
- package/examples/jsm/utils/CameraUtils.js +15 -6
- package/examples/jsm/utils/GeometryCompressionUtils.js +23 -30
- package/examples/jsm/utils/GeometryUtils.js +32 -27
- package/examples/jsm/utils/LDrawUtils.js +14 -5
- package/examples/jsm/utils/SceneOptimizer.js +458 -0
- package/examples/jsm/utils/SceneUtils.js +53 -3
- package/examples/jsm/utils/ShadowMapViewer.js +72 -33
- package/examples/jsm/utils/ShadowMapViewerGPU.js +61 -29
- package/examples/jsm/utils/SkeletonUtils.js +48 -0
- package/examples/jsm/utils/SortUtils.js +17 -5
- package/examples/jsm/utils/UVsDebug.js +12 -4
- package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +16 -0
- package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +20 -2
- package/examples/jsm/utils/WorkerPool.js +67 -2
- package/examples/jsm/webxr/ARButton.js +19 -0
- package/examples/jsm/webxr/OculusHandModel.js +84 -0
- package/examples/jsm/webxr/OculusHandPointerModel.js +148 -22
- package/examples/jsm/webxr/Text2D.js +20 -6
- package/examples/jsm/webxr/VRButton.js +31 -0
- package/examples/jsm/webxr/XRButton.js +23 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +94 -3
- package/examples/jsm/webxr/XREstimatedLight.js +35 -4
- package/examples/jsm/webxr/XRHandMeshModel.js +37 -0
- package/examples/jsm/webxr/XRHandModelFactory.js +96 -6
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +44 -0
- package/examples/jsm/webxr/XRPlanes.js +18 -0
- package/package.json +29 -37
- package/src/Three.Core.js +198 -0
- package/src/Three.Legacy.js +0 -21
- package/src/Three.TSL.js +641 -0
- package/src/Three.WebGPU.Nodes.js +14 -186
- package/src/Three.WebGPU.js +16 -186
- package/src/Three.js +2 -197
- package/src/animation/AnimationAction.js +263 -31
- package/src/animation/AnimationClip.js +162 -7
- package/src/animation/AnimationMixer.js +105 -15
- package/src/animation/AnimationObjectGroup.js +45 -21
- package/src/animation/AnimationUtils.js +163 -24
- package/src/animation/KeyframeTrack.js +191 -17
- package/src/animation/PropertyBinding.js +91 -16
- package/src/animation/PropertyMixer.js +72 -5
- package/src/animation/tracks/BooleanKeyframeTrack.js +33 -6
- package/src/animation/tracks/ColorKeyframeTrack.js +26 -5
- package/src/animation/tracks/NumberKeyframeTrack.js +26 -2
- package/src/animation/tracks/QuaternionKeyframeTrack.js +30 -1
- package/src/animation/tracks/StringKeyframeTrack.js +33 -2
- package/src/animation/tracks/VectorKeyframeTrack.js +26 -2
- package/src/audio/Audio.js +386 -8
- package/src/audio/AudioAnalyser.js +58 -1
- package/src/audio/AudioContext.js +15 -0
- package/src/audio/AudioListener.js +94 -13
- package/src/audio/PositionalAudio.js +107 -0
- package/src/cameras/ArrayCamera.js +37 -0
- package/src/cameras/Camera.js +61 -0
- package/src/cameras/CubeCamera.js +86 -0
- package/src/cameras/OrthographicCamera.js +110 -1
- package/src/cameras/PerspectiveCamera.js +174 -35
- package/src/cameras/StereoCamera.js +48 -2
- package/src/constants.js +1546 -11
- package/src/core/BufferAttribute.js +417 -3
- package/src/core/BufferGeometry.js +407 -22
- package/src/core/Clock.js +69 -8
- package/src/core/EventDispatcher.js +52 -8
- package/src/core/GLBufferAttribute.js +113 -2
- package/src/core/InstancedBufferAttribute.js +29 -0
- package/src/core/InstancedBufferGeometry.js +20 -0
- package/src/core/InstancedInterleavedBuffer.js +26 -0
- package/src/core/InterleavedBuffer.js +141 -7
- package/src/core/InterleavedBufferAttribute.js +200 -2
- package/src/core/Layers.js +71 -10
- package/src/core/Object3D.js +673 -26
- package/src/core/Raycaster.js +136 -2
- package/src/core/RenderTarget.js +256 -27
- package/src/core/RenderTarget3D.js +48 -0
- package/src/core/Timer.js +184 -0
- package/src/core/Uniform.js +29 -0
- package/src/core/UniformsGroup.js +84 -2
- package/src/extras/Controls.js +89 -1
- package/src/extras/DataUtils.js +50 -9
- package/src/extras/Earcut.js +18 -779
- package/src/extras/ImageUtils.js +22 -14
- package/src/extras/PMREMGenerator.js +316 -67
- package/src/extras/ShapeUtils.js +24 -2
- package/src/extras/TextureUtils.js +101 -15
- package/src/extras/core/Curve.js +156 -55
- package/src/extras/core/CurvePath.js +63 -22
- package/src/extras/core/Interpolations.js +34 -2
- package/src/extras/core/Path.js +134 -1
- package/src/extras/core/Shape.js +66 -3
- package/src/extras/core/ShapePath.js +80 -4
- package/src/extras/curves/ArcCurve.js +22 -0
- package/src/extras/curves/CatmullRomCurve3.js +89 -18
- package/src/extras/curves/CubicBezierCurve.js +67 -0
- package/src/extras/curves/CubicBezierCurve3.js +50 -0
- package/src/extras/curves/EllipseCurve.js +102 -0
- package/src/extras/curves/LineCurve.js +36 -0
- package/src/extras/curves/LineCurve3.js +36 -0
- package/src/extras/curves/QuadraticBezierCurve.js +59 -0
- package/src/extras/curves/QuadraticBezierCurve3.js +43 -0
- package/src/extras/curves/SplineCurve.js +48 -0
- package/src/extras/lib/earcut.js +685 -0
- package/src/geometries/BoxGeometry.js +39 -0
- package/src/geometries/CapsuleGeometry.js +196 -11
- package/src/geometries/CircleGeometry.js +41 -0
- package/src/geometries/ConeGeometry.js +39 -0
- package/src/geometries/CylinderGeometry.js +42 -2
- package/src/geometries/DodecahedronGeometry.js +33 -0
- package/src/geometries/EdgesGeometry.js +30 -2
- package/src/geometries/ExtrudeGeometry.js +148 -52
- package/src/geometries/IcosahedronGeometry.js +33 -0
- package/src/geometries/LatheGeometry.js +44 -3
- package/src/geometries/OctahedronGeometry.js +33 -0
- package/src/geometries/PlaneGeometry.js +35 -0
- package/src/geometries/PolyhedronGeometry.js +30 -1
- package/src/geometries/RingGeometry.js +37 -0
- package/src/geometries/ShapeGeometry.js +38 -0
- package/src/geometries/SphereGeometry.js +38 -0
- package/src/geometries/TetrahedronGeometry.js +33 -0
- package/src/geometries/TorusGeometry.js +44 -3
- package/src/geometries/TorusKnotGeometry.js +39 -0
- package/src/geometries/TubeGeometry.js +50 -0
- package/src/geometries/WireframeGeometry.js +32 -0
- package/src/helpers/ArrowHelper.js +62 -5
- package/src/helpers/AxesHelper.js +28 -0
- package/src/helpers/Box3Helper.js +28 -0
- package/src/helpers/BoxHelper.js +43 -7
- package/src/helpers/CameraHelper.js +103 -27
- package/src/helpers/DirectionalLightHelper.js +55 -0
- package/src/helpers/GridHelper.js +26 -0
- package/src/helpers/HemisphereLightHelper.js +42 -0
- package/src/helpers/PlaneHelper.js +33 -0
- package/src/helpers/PointLightHelper.js +43 -24
- package/src/helpers/PolarGridHelper.js +30 -0
- package/src/helpers/SkeletonHelper.js +73 -7
- package/src/helpers/SpotLightHelper.js +43 -0
- package/src/lights/AmbientLight.js +25 -0
- package/src/lights/DirectionalLight.js +70 -0
- package/src/lights/DirectionalLightShadow.js +15 -0
- package/src/lights/HemisphereLight.js +42 -0
- package/src/lights/Light.js +37 -11
- package/src/lights/LightProbe.js +37 -9
- package/src/lights/LightShadow.js +202 -7
- package/src/lights/PointLight.js +74 -0
- package/src/lights/PointLightShadow.js +15 -80
- package/src/lights/RectAreaLight.js +59 -0
- package/src/lights/SpotLight.js +124 -1
- package/src/lights/SpotLightShadow.js +33 -3
- package/src/lights/webgpu/IESSpotLight.js +22 -0
- package/src/lights/webgpu/ProjectorLight.js +46 -0
- package/src/loaders/AnimationLoader.js +34 -2
- package/src/loaders/AudioLoader.js +34 -2
- package/src/loaders/BufferGeometryLoader.js +38 -13
- package/src/loaders/Cache.js +75 -2
- package/src/loaders/CompressedTextureLoader.js +36 -3
- package/src/loaders/CubeTextureLoader.js +45 -0
- package/src/loaders/DataTextureLoader.js +45 -4
- package/src/loaders/FileLoader.js +85 -5
- package/src/loaders/ImageBitmapLoader.js +113 -11
- package/src/loaders/ImageLoader.js +85 -8
- package/src/loaders/Loader.js +150 -0
- package/src/loaders/LoaderUtils.js +18 -36
- package/src/loaders/LoadingManager.js +187 -0
- package/src/loaders/MaterialLoader.js +62 -3
- package/src/loaders/ObjectLoader.js +131 -31
- package/src/loaders/TextureLoader.js +33 -0
- package/src/loaders/nodes/NodeLoader.js +68 -4
- package/src/loaders/nodes/NodeMaterialLoader.js +45 -0
- package/src/loaders/nodes/NodeObjectLoader.js +61 -0
- package/src/materials/LineBasicMaterial.js +74 -1
- package/src/materials/LineDashedMaterial.js +52 -1
- package/src/materials/Material.js +502 -8
- package/src/materials/MeshBasicMaterial.js +168 -2
- package/src/materials/MeshDepthMaterial.js +94 -0
- package/src/materials/MeshDistanceMaterial.js +76 -0
- package/src/materials/MeshLambertMaterial.js +283 -0
- package/src/materials/MeshMatcapMaterial.js +164 -0
- package/src/materials/MeshNormalMaterial.js +114 -0
- package/src/materials/MeshPhongMaterial.js +298 -0
- package/src/materials/MeshPhysicalMaterial.js +296 -4
- package/src/materials/MeshStandardMaterial.js +300 -2
- package/src/materials/MeshToonMaterial.js +219 -0
- package/src/materials/PointsMaterial.js +89 -0
- package/src/materials/RawShaderMaterial.js +25 -0
- package/src/materials/ShaderMaterial.js +234 -6
- package/src/materials/ShadowMaterial.js +54 -0
- package/src/materials/SpriteMaterial.js +82 -0
- package/src/materials/nodes/Line2NodeMaterial.js +158 -53
- package/src/materials/nodes/LineBasicNodeMaterial.js +17 -2
- package/src/materials/nodes/LineDashedNodeMaterial.js +81 -6
- package/src/materials/nodes/MeshBasicNodeMaterial.js +59 -2
- package/src/materials/nodes/MeshLambertNodeMaterial.js +35 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +23 -3
- package/src/materials/nodes/MeshNormalNodeMaterial.js +27 -4
- package/src/materials/nodes/MeshPhongNodeMaterial.js +64 -1
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +276 -3
- package/src/materials/nodes/MeshSSSNodeMaterial.js +98 -10
- package/src/materials/nodes/MeshStandardNodeMaterial.js +83 -4
- package/src/materials/nodes/MeshToonNodeMaterial.js +28 -0
- package/src/materials/nodes/NodeMaterial.js +789 -74
- package/src/materials/nodes/NodeMaterials.js +0 -1
- package/src/materials/nodes/PointsNodeMaterial.js +180 -11
- package/src/materials/nodes/ShadowNodeMaterial.js +38 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +86 -23
- package/src/materials/nodes/VolumeNodeMaterial.js +57 -84
- package/src/materials/nodes/manager/NodeMaterialObserver.js +329 -12
- package/src/math/Box2.js +177 -0
- package/src/math/Box3.js +271 -0
- package/src/math/Color.js +355 -11
- package/src/math/ColorManagement.js +158 -92
- package/src/math/Cylindrical.js +65 -6
- package/src/math/Euler.js +139 -5
- package/src/math/Frustum.js +108 -9
- package/src/math/FrustumArray.js +258 -0
- package/src/math/Interpolant.js +87 -8
- package/src/math/Line3.js +221 -2
- package/src/math/MathUtils.js +408 -20
- package/src/math/Matrix2.js +70 -0
- package/src/math/Matrix3.js +229 -4
- package/src/math/Matrix4.js +489 -94
- package/src/math/Plane.js +164 -2
- package/src/math/Quaternion.js +322 -90
- package/src/math/Ray.js +162 -0
- package/src/math/Sphere.js +175 -0
- package/src/math/Spherical.js +73 -11
- package/src/math/SphericalHarmonics3.js +112 -14
- package/src/math/Triangle.js +206 -2
- package/src/math/Vector2.js +396 -10
- package/src/math/Vector3.js +550 -15
- package/src/math/Vector4.js +415 -9
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/math/interpolants/CubicInterpolant.js +10 -1
- package/src/math/interpolants/DiscreteInterpolant.js +10 -2
- package/src/math/interpolants/LinearInterpolant.js +13 -0
- package/src/math/interpolants/QuaternionLinearInterpolant.js +10 -1
- package/src/nodes/Nodes.js +91 -88
- package/src/nodes/TSL.js +32 -38
- package/src/nodes/accessors/AccessorsUtils.js +37 -9
- package/src/nodes/accessors/Arrays.js +68 -0
- package/src/nodes/accessors/BatchNode.js +49 -14
- package/src/nodes/accessors/Bitangent.js +82 -13
- package/src/nodes/accessors/BufferAttributeNode.js +269 -8
- package/src/nodes/accessors/BufferNode.js +91 -2
- package/src/nodes/accessors/BuiltinNode.js +63 -0
- package/src/nodes/accessors/Camera.js +400 -10
- package/src/nodes/accessors/ClippingNode.js +149 -45
- package/src/nodes/accessors/CubeTextureNode.js +137 -7
- package/src/nodes/accessors/InstanceNode.js +245 -40
- package/src/nodes/accessors/InstancedMeshNode.js +50 -0
- package/src/nodes/accessors/Lights.js +88 -0
- package/src/nodes/accessors/MaterialNode.js +355 -13
- package/src/nodes/accessors/MaterialProperties.js +57 -1
- package/src/nodes/accessors/MaterialReferenceNode.js +52 -14
- package/src/nodes/accessors/ModelNode.js +117 -5
- package/src/nodes/accessors/ModelViewProjectionNode.js +10 -39
- package/src/nodes/accessors/MorphNode.js +73 -26
- package/src/nodes/accessors/Normal.js +174 -19
- package/src/nodes/accessors/Object3DNode.js +146 -12
- package/src/nodes/accessors/PointUVNode.js +25 -0
- package/src/nodes/accessors/Position.js +119 -7
- package/src/nodes/accessors/ReferenceBaseNode.js +190 -4
- package/src/nodes/accessors/ReferenceNode.js +223 -8
- package/src/nodes/accessors/ReflectVector.js +29 -3
- package/src/nodes/accessors/RendererReferenceNode.js +45 -2
- package/src/nodes/accessors/SceneProperties.js +53 -0
- package/src/nodes/accessors/SkinningNode.js +180 -43
- package/src/nodes/accessors/StorageBufferNode.js +278 -26
- package/src/nodes/accessors/StorageTextureNode.js +205 -12
- package/src/nodes/accessors/Tangent.js +48 -10
- package/src/nodes/accessors/TangentUtils.js +46 -0
- package/src/nodes/accessors/Texture3DNode.js +104 -11
- package/src/nodes/accessors/TextureBicubic.js +31 -4
- package/src/nodes/accessors/TextureNode.js +564 -52
- package/src/nodes/accessors/TextureSizeNode.js +42 -1
- package/src/nodes/accessors/UV.js +9 -1
- package/src/nodes/accessors/UniformArrayNode.js +226 -34
- package/src/nodes/accessors/UserDataNode.js +46 -2
- package/src/nodes/accessors/VelocityNode.js +93 -3
- package/src/nodes/accessors/VertexColorNode.js +39 -4
- package/src/nodes/code/CodeNode.js +101 -8
- package/src/nodes/code/ExpressionNode.js +29 -2
- package/src/nodes/code/FunctionCallNode.js +98 -10
- package/src/nodes/code/FunctionNode.js +69 -2
- package/src/nodes/core/ArrayNode.js +174 -0
- package/src/nodes/core/AssignNode.js +80 -9
- package/src/nodes/core/AttributeNode.js +47 -4
- package/src/nodes/core/BypassNode.js +47 -3
- package/src/nodes/core/ConstNode.js +32 -0
- package/src/nodes/core/ContextNode.js +220 -14
- package/src/nodes/core/IndexNode.js +72 -7
- package/src/nodes/core/InputNode.js +50 -1
- package/src/nodes/core/InspectorNode.js +128 -0
- package/src/nodes/core/IsolateNode.js +133 -0
- package/src/nodes/core/LightingModel.js +65 -5
- package/src/nodes/core/MRTNode.js +113 -2
- package/src/nodes/core/Node.js +595 -36
- package/src/nodes/core/NodeAttribute.js +38 -0
- package/src/nodes/core/NodeBuilder.js +1840 -121
- package/src/nodes/core/NodeCache.js +41 -2
- package/src/nodes/core/NodeCode.js +31 -0
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeFrame.js +153 -24
- package/src/nodes/core/NodeFunction.js +48 -1
- package/src/nodes/core/NodeFunctionInput.js +44 -0
- package/src/nodes/core/NodeParser.js +13 -1
- package/src/nodes/core/NodeUniform.js +53 -1
- package/src/nodes/core/NodeUtils.js +201 -51
- package/src/nodes/core/NodeVar.js +47 -1
- package/src/nodes/core/NodeVarying.js +47 -1
- package/src/nodes/core/OutputStructNode.js +54 -12
- package/src/nodes/core/ParameterNode.js +60 -2
- package/src/nodes/core/PropertyNode.js +286 -7
- package/src/nodes/core/StackNode.js +337 -20
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +134 -0
- package/src/nodes/core/StructType.js +13 -0
- package/src/nodes/core/StructTypeNode.js +126 -6
- package/src/nodes/core/SubBuildNode.js +89 -0
- package/src/nodes/core/TempNode.js +31 -5
- package/src/nodes/core/UniformGroupNode.js +85 -7
- package/src/nodes/core/UniformNode.js +163 -16
- package/src/nodes/core/VarNode.js +317 -10
- package/src/nodes/core/VaryingNode.js +115 -13
- package/src/nodes/core/constants.js +40 -0
- package/src/nodes/display/BlendModes.js +171 -0
- package/src/nodes/display/BumpMapNode.js +38 -2
- package/src/nodes/display/ColorAdjustment.js +118 -6
- package/src/nodes/display/ColorSpaceFunctions.js +22 -6
- package/src/nodes/display/ColorSpaceNode.js +97 -47
- package/src/nodes/display/FrontFacingNode.js +64 -7
- package/src/nodes/display/NormalMapNode.js +101 -54
- package/src/nodes/display/PassNode.js +690 -33
- package/src/nodes/display/RenderOutputNode.js +94 -4
- package/src/nodes/display/ScreenNode.js +138 -27
- package/src/nodes/display/ToneMappingFunctions.js +62 -10
- package/src/nodes/display/ToneMappingNode.js +88 -8
- package/src/nodes/display/ToonOutlinePassNode.js +84 -4
- package/src/nodes/display/ViewportDepthNode.js +227 -10
- package/src/nodes/display/ViewportDepthTextureNode.js +39 -5
- package/src/nodes/display/ViewportSharedTextureNode.js +35 -1
- package/src/nodes/display/ViewportTextureNode.js +171 -7
- package/src/nodes/fog/Fog.js +97 -0
- package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +45 -1
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +1 -1
- package/src/nodes/functions/BasicLightingModel.js +28 -6
- package/src/nodes/functions/PhongLightingModel.js +36 -6
- package/src/nodes/functions/PhysicalLightingModel.js +336 -91
- package/src/nodes/functions/ShadowMaskModel.js +30 -3
- package/src/nodes/functions/ToonLightingModel.js +21 -2
- package/src/nodes/functions/VolumetricLightingModel.js +183 -0
- package/src/nodes/functions/material/getAlphaHashThreshold.js +68 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +10 -4
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +37 -0
- package/src/nodes/geometry/RangeNode.js +97 -8
- package/src/nodes/gpgpu/AtomicFunctionNode.js +198 -23
- package/src/nodes/gpgpu/BarrierNode.js +52 -3
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +135 -6
- package/src/nodes/gpgpu/ComputeNode.js +212 -16
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +143 -9
- package/src/nodes/lighting/AONode.js +18 -0
- package/src/nodes/lighting/AmbientLightNode.js +10 -0
- package/src/nodes/lighting/AnalyticLightNode.js +186 -399
- package/src/nodes/lighting/BasicEnvironmentNode.js +19 -0
- package/src/nodes/lighting/BasicLightMapNode.js +17 -0
- package/src/nodes/lighting/DirectionalLightNode.js +12 -11
- package/src/nodes/lighting/EnvironmentNode.js +59 -19
- package/src/nodes/lighting/HemisphereLightNode.js +33 -2
- package/src/nodes/lighting/IESSpotLightNode.js +13 -1
- package/src/nodes/lighting/IrradianceNode.js +17 -0
- package/src/nodes/lighting/LightProbeNode.js +20 -0
- package/src/nodes/lighting/LightUtils.js +11 -3
- package/src/nodes/lighting/LightingContextNode.js +52 -4
- package/src/nodes/lighting/LightingNode.js +15 -6
- package/src/nodes/lighting/LightsNode.js +238 -35
- package/src/nodes/lighting/PointLightNode.js +60 -25
- package/src/nodes/lighting/PointShadowNode.js +325 -0
- package/src/nodes/lighting/ProjectorLightNode.js +91 -0
- package/src/nodes/lighting/RectAreaLightNode.js +50 -14
- package/src/nodes/lighting/ShadowBaseNode.js +81 -0
- package/src/nodes/lighting/ShadowFilterNode.js +264 -0
- package/src/nodes/lighting/ShadowNode.js +867 -0
- package/src/nodes/lighting/SpotLightNode.js +99 -18
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +166 -2
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/ConditionalNode.js +110 -21
- package/src/nodes/math/Hash.js +8 -0
- package/src/nodes/math/MathNode.js +820 -97
- package/src/nodes/math/MathUtils.js +47 -1
- package/src/nodes/math/OperatorNode.js +517 -84
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/TriNoise3D.js +17 -7
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/parsers/GLSLNodeFunction.js +16 -0
- package/src/nodes/parsers/GLSLNodeParser.js +11 -0
- package/src/nodes/pmrem/PMREMNode.js +180 -23
- package/src/nodes/pmrem/PMREMUtils.js +114 -5
- package/src/nodes/procedural/Checker.js +8 -0
- package/src/nodes/shapes/Shapes.js +33 -0
- package/src/nodes/tsl/TSLBase.js +10 -4
- package/src/nodes/tsl/TSLCore.js +732 -160
- package/src/nodes/utils/ArrayElementNode.js +55 -4
- package/src/nodes/utils/ConvertNode.js +31 -0
- package/src/nodes/utils/CubeMapNode.js +79 -2
- package/src/nodes/utils/DebugNode.js +83 -0
- package/src/nodes/utils/Discard.js +18 -2
- package/src/nodes/utils/EquirectUV.js +27 -0
- package/src/nodes/utils/EventNode.js +118 -0
- package/src/nodes/utils/FlipNode.js +38 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +91 -22
- package/src/nodes/utils/JoinNode.js +57 -4
- package/src/nodes/utils/LoopNode.js +193 -55
- package/src/nodes/utils/MatcapUV.js +22 -0
- package/src/nodes/utils/MaxMipLevelNode.js +49 -1
- package/src/nodes/utils/MemberNode.js +120 -0
- package/src/nodes/utils/Oscillators.js +41 -0
- package/src/nodes/utils/Packing.js +30 -1
- package/src/nodes/utils/PostProcessingUtils.js +154 -0
- package/src/nodes/utils/RTTNode.js +165 -9
- package/src/nodes/utils/ReflectorNode.js +407 -21
- package/src/nodes/utils/RemapNode.js +81 -2
- package/src/nodes/utils/RotateNode.js +41 -1
- package/src/nodes/utils/SampleNode.js +91 -0
- package/src/nodes/utils/SetNode.js +44 -1
- package/src/nodes/utils/SplitNode.js +66 -3
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/SpriteUtils.js +16 -0
- package/src/nodes/utils/StorageArrayElementNode.js +56 -3
- package/src/nodes/utils/Timer.js +26 -0
- package/src/nodes/utils/TriplanarTextures.js +65 -0
- package/src/nodes/utils/UVUtils.js +48 -0
- package/src/nodes/utils/ViewportUtils.js +12 -0
- package/src/objects/BatchedMesh.js +798 -309
- package/src/objects/Bone.js +24 -0
- package/src/objects/ClippingGroup.js +68 -0
- package/src/objects/Group.js +24 -0
- package/src/objects/InstancedMesh.js +131 -2
- package/src/objects/LOD.js +99 -5
- package/src/objects/Line.js +90 -7
- package/src/objects/LineLoop.js +20 -0
- package/src/objects/LineSegments.js +20 -1
- package/src/objects/Mesh.js +84 -0
- package/src/objects/Points.js +60 -0
- package/src/objects/Skeleton.js +120 -5
- package/src/objects/SkinnedMesh.js +102 -6
- package/src/objects/Sprite.js +65 -1
- package/src/renderers/WebGL3DRenderTarget.js +26 -0
- package/src/renderers/WebGLArrayRenderTarget.js +26 -0
- package/src/renderers/WebGLCubeRenderTarget.js +41 -5
- package/src/renderers/WebGLRenderTarget.js +19 -0
- package/src/renderers/WebGLRenderer.js +1016 -278
- package/src/renderers/common/Animation.js +123 -14
- package/src/renderers/common/Attributes.js +41 -1
- package/src/renderers/common/Backend.js +623 -44
- package/src/renderers/common/Background.js +99 -16
- package/src/renderers/common/BindGroup.js +37 -2
- package/src/renderers/common/Binding.js +46 -0
- package/src/renderers/common/Bindings.js +211 -20
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/Buffer.js +89 -0
- package/src/renderers/common/BufferUtils.js +25 -0
- package/src/renderers/common/BundleGroup.js +57 -0
- package/src/renderers/common/CanvasTarget.js +341 -0
- package/src/renderers/common/ChainMap.js +73 -10
- package/src/renderers/common/ClippingContext.js +172 -87
- package/src/renderers/common/Color4.js +40 -0
- package/src/renderers/common/ComputePipeline.js +24 -0
- package/src/renderers/common/Constants.js +2 -1
- package/src/renderers/common/CubeRenderTarget.js +77 -7
- package/src/renderers/common/DataMap.js +37 -1
- package/src/renderers/common/Geometries.js +163 -14
- package/src/renderers/common/IndirectStorageBufferAttribute.js +38 -0
- package/src/renderers/common/Info.js +81 -36
- package/src/renderers/common/InspectorBase.js +146 -0
- package/src/renderers/common/Lighting.js +57 -0
- package/src/renderers/common/Pipeline.js +22 -0
- package/src/renderers/common/Pipelines.js +150 -7
- package/src/renderers/common/PostProcessing.js +22 -84
- package/src/renderers/common/ProgrammableStage.js +60 -2
- package/src/renderers/common/QuadMesh.js +63 -6
- package/src/renderers/common/RenderBundle.js +14 -8
- package/src/renderers/common/RenderBundles.js +40 -10
- package/src/renderers/common/RenderContext.js +219 -4
- package/src/renderers/common/RenderContexts.js +54 -17
- package/src/renderers/common/RenderList.js +233 -24
- package/src/renderers/common/RenderLists.js +46 -6
- package/src/renderers/common/RenderObject.js +548 -46
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +133 -15
- package/src/renderers/common/RenderPipeline.js +216 -6
- package/src/renderers/common/Renderer.js +2155 -332
- package/src/renderers/common/RendererUtils.js +200 -0
- package/src/renderers/common/SampledTexture.js +99 -39
- package/src/renderers/common/Sampler.js +148 -1
- package/src/renderers/common/Storage3DTexture.js +100 -0
- package/src/renderers/common/StorageArrayTexture.js +84 -0
- package/src/renderers/common/StorageBuffer.js +38 -2
- package/src/renderers/common/StorageBufferAttribute.js +31 -2
- package/src/renderers/common/StorageInstancedBufferAttribute.js +31 -2
- package/src/renderers/common/StorageTexture.js +65 -0
- package/src/renderers/common/Textures.js +273 -57
- package/src/renderers/common/TimestampQueryPool.js +163 -0
- package/src/renderers/common/Uniform.js +233 -3
- package/src/renderers/common/UniformBuffer.js +19 -0
- package/src/renderers/common/UniformsGroup.js +235 -26
- package/src/renderers/common/XRManager.js +1677 -0
- package/src/renderers/common/XRRenderTarget.js +91 -0
- package/src/renderers/common/extras/PMREMGenerator.js +371 -108
- package/src/renderers/common/nodes/NodeBuilderState.js +100 -6
- package/src/renderers/common/nodes/NodeLibrary.js +95 -17
- package/src/renderers/common/nodes/NodeManager.js +852 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +84 -8
- package/src/renderers/common/nodes/NodeSampler.js +41 -1
- package/src/renderers/common/nodes/NodeStorageBuffer.js +48 -3
- package/src/renderers/common/nodes/NodeUniform.js +285 -2
- package/src/renderers/common/nodes/NodeUniformBuffer.js +81 -0
- package/src/renderers/common/nodes/NodeUniformsGroup.js +31 -18
- package/src/renderers/shaders/DFGLUTData.js +49 -0
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -12
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +5 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +154 -59
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +230 -181
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk.js +3 -3
- package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +14 -2
- package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +7 -5
- package/src/renderers/shaders/UniformsLib.js +2 -7
- package/src/renderers/shaders/UniformsUtils.js +21 -2
- package/src/renderers/webgl/WebGLAttributes.js +4 -0
- package/src/renderers/webgl/WebGLBackground.js +30 -5
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLCapabilities.js +7 -14
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLExtensions.js +2 -25
- package/src/renderers/webgl/WebGLGeometries.js +10 -35
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLInfo.js +3 -1
- package/src/renderers/webgl/WebGLLights.js +18 -1
- package/src/renderers/webgl/WebGLMaterials.js +12 -0
- package/src/renderers/webgl/WebGLObjects.js +3 -1
- package/src/renderers/webgl/WebGLOutput.js +267 -0
- package/src/renderers/webgl/WebGLProgram.js +87 -148
- package/src/renderers/webgl/WebGLPrograms.js +53 -51
- package/src/renderers/webgl/WebGLRenderLists.js +15 -0
- package/src/renderers/webgl/WebGLShadowMap.js +204 -28
- package/src/renderers/webgl/WebGLState.js +88 -56
- package/src/renderers/webgl/WebGLTextures.js +293 -59
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUniformsGroups.js +5 -3
- package/src/renderers/webgl/WebGLUtils.js +7 -5
- package/src/renderers/webgl-fallback/WebGLBackend.js +1416 -293
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +5 -10
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +785 -92
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +62 -1
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +28 -0
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +3 -3
- package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +45 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +584 -20
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +468 -80
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +396 -0
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +72 -24
- package/src/renderers/webgpu/WebGPUBackend.js +1517 -428
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +31 -4
- package/src/renderers/webgpu/WebGPURenderer.js +55 -4
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +23 -16
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +37 -42
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +1335 -241
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +32 -4
- package/src/renderers/webgpu/nodes/WGSLNodeParser.js +11 -0
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +144 -20
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +460 -116
- package/src/renderers/webgpu/utils/WebGPUConstants.js +17 -4
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +283 -69
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +225 -178
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +583 -191
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +310 -0
- package/src/renderers/webgpu/utils/WebGPUUtils.js +150 -28
- package/src/renderers/webxr/WebXRController.js +87 -2
- package/src/renderers/webxr/WebXRDepthSensing.js +52 -7
- package/src/renderers/webxr/WebXRManager.js +275 -15
- package/src/scenes/Fog.js +60 -0
- package/src/scenes/FogExp2.js +51 -0
- package/src/scenes/Scene.js +88 -0
- package/src/textures/CanvasTexture.js +28 -0
- package/src/textures/CompressedArrayTexture.js +57 -0
- package/src/textures/CompressedCubeTexture.js +29 -0
- package/src/textures/CompressedTexture.js +64 -6
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/CubeTexture.js +52 -4
- package/src/textures/Data3DTexture.js +79 -2
- package/src/textures/DataArrayTexture.js +93 -0
- package/src/textures/DataTexture.js +65 -0
- package/src/textures/DepthTexture.js +59 -11
- package/src/textures/ExternalTexture.js +56 -0
- package/src/textures/FramebufferTexture.js +62 -0
- package/src/textures/Source.js +106 -4
- package/src/textures/Texture.js +488 -6
- package/src/textures/VideoFrameTexture.js +72 -0
- package/src/textures/VideoTexture.js +78 -6
- package/src/utils.js +322 -3
- package/examples/jsm/animation/MMDAnimationHelper.js +0 -1207
- package/examples/jsm/animation/MMDPhysics.js +0 -1406
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/examples/jsm/effects/PeppersGhostEffect.js +0 -153
- package/examples/jsm/exporters/MMDExporter.js +0 -217
- package/examples/jsm/geometries/InstancedPointsGeometry.js +0 -174
- package/examples/jsm/geometries/ParametricGeometries.js +0 -254
- package/examples/jsm/libs/mmdparser.module.js +0 -11530
- package/examples/jsm/loaders/GLTFLoaderAnimationPointer.js +0 -729
- package/examples/jsm/loaders/MMDLoader.js +0 -2295
- package/examples/jsm/loaders/RGBMLoader.js +0 -1081
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -432
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -144
- package/examples/jsm/misc/Timer.js +0 -128
- package/examples/jsm/objects/InstancedPoints.js +0 -21
- package/examples/jsm/shaders/GodRaysShader.js +0 -321
- package/examples/jsm/shaders/MMDToonShader.js +0 -134
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +0 -156
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +0 -24
- package/src/nodes/accessors/SceneNode.js +0 -55
- package/src/nodes/code/ScriptableNode.js +0 -505
- package/src/nodes/code/ScriptableValueNode.js +0 -170
- package/src/nodes/core/CacheNode.js +0 -50
- package/src/nodes/core/UniformGroup.js +0 -13
- package/src/nodes/display/AfterImageNode.js +0 -158
- package/src/nodes/display/AnaglyphPassNode.js +0 -67
- package/src/nodes/display/AnamorphicNode.js +0 -151
- package/src/nodes/display/BlendMode.js +0 -54
- package/src/nodes/display/BloomNode.js +0 -341
- package/src/nodes/display/DenoiseNode.js +0 -204
- package/src/nodes/display/DepthOfFieldNode.js +0 -124
- package/src/nodes/display/DotScreenNode.js +0 -66
- package/src/nodes/display/FXAANode.js +0 -332
- package/src/nodes/display/FilmNode.js +0 -56
- package/src/nodes/display/GTAONode.js +0 -331
- package/src/nodes/display/GaussianBlurNode.js +0 -213
- package/src/nodes/display/Lut3DNode.js +0 -57
- package/src/nodes/display/MotionBlur.js +0 -25
- package/src/nodes/display/ParallaxBarrierPassNode.js +0 -58
- package/src/nodes/display/PixelationPassNode.js +0 -213
- package/src/nodes/display/PosterizeNode.js +0 -33
- package/src/nodes/display/RGBShiftNode.js +0 -53
- package/src/nodes/display/StereoCompositePassNode.js +0 -110
- package/src/nodes/display/TransitionNode.js +0 -80
- package/src/nodes/fog/FogExp2Node.js +0 -35
- package/src/nodes/fog/FogNode.js +0 -50
- package/src/nodes/fog/FogRangeNode.js +0 -36
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -30
- package/src/nodes/utils/EquirectUVNode.js +0 -36
- package/src/nodes/utils/MatcapUVNode.js +0 -33
- package/src/nodes/utils/OscNode.js +0 -85
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -45
- package/src/nodes/utils/TimerNode.js +0 -97
- package/src/nodes/utils/TriplanarTexturesNode.js +0 -64
- package/src/renderers/common/nodes/Nodes.js +0 -534
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -136
|
@@ -9,85 +9,252 @@ import {
|
|
|
9
9
|
zipSync,
|
|
10
10
|
} from '../libs/fflate.module.js';
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
class USDNode {
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
constructor( name, type = '', metadata = [], properties = [] ) {
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
this.name = name;
|
|
17
|
+
this.type = type;
|
|
18
|
+
this.metadata = metadata;
|
|
19
|
+
this.properties = properties;
|
|
20
|
+
this.children = [];
|
|
17
21
|
|
|
18
|
-
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
addMetadata( key, value ) {
|
|
25
|
+
|
|
26
|
+
this.metadata.push( { key, value } );
|
|
19
27
|
|
|
20
28
|
}
|
|
21
29
|
|
|
22
|
-
|
|
30
|
+
addProperty( property, metadata = [] ) {
|
|
23
31
|
|
|
24
|
-
|
|
25
|
-
ar: {
|
|
26
|
-
anchoring: { type: 'plane' },
|
|
27
|
-
planeAnchoring: { alignment: 'horizontal' }
|
|
28
|
-
},
|
|
29
|
-
includeAnchoringProperties: true,
|
|
30
|
-
quickLookCompatible: false,
|
|
31
|
-
maxTextureSize: 1024,
|
|
32
|
-
}, options );
|
|
32
|
+
this.properties.push( { property, metadata } );
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
const modelFileName = 'model.usda';
|
|
34
|
+
}
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
files[ modelFileName ] = null;
|
|
36
|
+
addChild( child ) {
|
|
39
37
|
|
|
40
|
-
|
|
38
|
+
this.children.push( child );
|
|
41
39
|
|
|
42
|
-
|
|
40
|
+
}
|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
const textures = {};
|
|
42
|
+
toString( indent = 0 ) {
|
|
46
43
|
|
|
47
|
-
|
|
44
|
+
const pad = '\t'.repeat( indent );
|
|
48
45
|
|
|
49
|
-
|
|
46
|
+
const formattedMetadata = this.metadata.map( ( item ) => {
|
|
50
47
|
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
const key = item.key;
|
|
49
|
+
const value = item.value;
|
|
53
50
|
|
|
54
|
-
|
|
51
|
+
if ( Array.isArray( value ) ) {
|
|
55
52
|
|
|
56
|
-
|
|
53
|
+
const lines = [];
|
|
54
|
+
lines.push( `${key} = {` );
|
|
55
|
+
value.forEach( ( line ) => {
|
|
57
56
|
|
|
58
|
-
|
|
57
|
+
lines.push( `${pad}\t\t${line}` );
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
} );
|
|
60
|
+
lines.push( `${pad}\t}` );
|
|
61
|
+
return lines.join( '\n' );
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
} else {
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
return `${key} = ${value}`;
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
}
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
} );
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
const meta = formattedMetadata.length
|
|
72
|
+
? ` (\n${formattedMetadata
|
|
73
|
+
.map( ( l ) => `${pad}\t${l}` )
|
|
74
|
+
.join( '\n' )}\n${pad})`
|
|
75
|
+
: '';
|
|
72
76
|
|
|
73
|
-
|
|
77
|
+
const properties = this.properties.map( ( l ) => {
|
|
74
78
|
|
|
75
|
-
|
|
79
|
+
const property = l.property;
|
|
80
|
+
const metadata = l.metadata.length
|
|
81
|
+
? ` (\n${l.metadata.map( ( m ) => `${pad}\t\t${m}` ).join( '\n' )}\n${pad}\t)`
|
|
82
|
+
: '';
|
|
83
|
+
return `${pad}\t${property}${metadata}`;
|
|
76
84
|
|
|
77
|
-
|
|
85
|
+
} );
|
|
86
|
+
const children = this.children.map( ( c ) => c.toString( indent + 1 ) );
|
|
87
|
+
|
|
88
|
+
const bodyLines = [];
|
|
78
89
|
|
|
79
|
-
|
|
90
|
+
if ( properties.length > 0 ) {
|
|
80
91
|
|
|
81
|
-
|
|
92
|
+
bodyLines.push( ...properties );
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if ( children.length > 0 ) {
|
|
97
|
+
|
|
98
|
+
if ( properties.length > 0 ) {
|
|
99
|
+
|
|
100
|
+
bodyLines.push( '' );
|
|
82
101
|
|
|
83
102
|
}
|
|
84
103
|
|
|
85
|
-
|
|
104
|
+
for ( let i = 0; i < children.length; i ++ ) {
|
|
86
105
|
|
|
106
|
+
bodyLines.push( children[ i ] );
|
|
107
|
+
if ( i < children.length - 1 ) {
|
|
108
|
+
|
|
109
|
+
bodyLines.push( '' );
|
|
110
|
+
|
|
111
|
+
}
|
|
87
112
|
|
|
88
|
-
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const bodyContent = bodyLines.join( '\n' );
|
|
118
|
+
|
|
119
|
+
const type = this.type ? this.type + ' ' : '';
|
|
120
|
+
|
|
121
|
+
return `${pad}def ${type}"${this.name}"${meta}\n${pad}{\n${bodyContent}\n${pad}}`;
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* An exporter for USDZ.
|
|
129
|
+
*
|
|
130
|
+
* ```js
|
|
131
|
+
* const exporter = new USDZExporter();
|
|
132
|
+
* const arraybuffer = await exporter.parseAsync( scene );
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @three_import import { USDZExporter } from 'three/addons/exporters/USDZExporter.js';
|
|
136
|
+
*/
|
|
137
|
+
class USDZExporter {
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Constructs a new USDZ exporter.
|
|
141
|
+
*/
|
|
142
|
+
constructor() {
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* A reference to a texture utils module.
|
|
146
|
+
*
|
|
147
|
+
* @type {?(WebGLTextureUtils|WebGPUTextureUtils)}
|
|
148
|
+
* @default null
|
|
149
|
+
*/
|
|
150
|
+
this.textureUtils = null;
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Sets the texture utils for this exporter. Only relevant when compressed textures have to be exported.
|
|
156
|
+
*
|
|
157
|
+
* Depending on whether you use {@link WebGLRenderer} or {@link WebGPURenderer}, you must inject the
|
|
158
|
+
* corresponding texture utils {@link WebGLTextureUtils} or {@link WebGPUTextureUtils}.
|
|
159
|
+
*
|
|
160
|
+
* @param {WebGLTextureUtils|WebGPUTextureUtils} utils - The texture utils.
|
|
161
|
+
*/
|
|
162
|
+
setTextureUtils( utils ) {
|
|
163
|
+
|
|
164
|
+
this.textureUtils = utils;
|
|
165
|
+
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Parse the given 3D object and generates the USDZ output.
|
|
170
|
+
*
|
|
171
|
+
* @param {Object3D} scene - The 3D object to export.
|
|
172
|
+
* @param {USDZExporter~OnDone} onDone - A callback function that is executed when the export has finished.
|
|
173
|
+
* @param {USDZExporter~OnError} onError - A callback function that is executed when an error happens.
|
|
174
|
+
* @param {USDZExporter~Options} options - The export options.
|
|
175
|
+
*/
|
|
176
|
+
parse( scene, onDone, onError, options ) {
|
|
177
|
+
|
|
178
|
+
this.parseAsync( scene, options ).then( onDone ).catch( onError );
|
|
179
|
+
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Async version of {@link USDZExporter#parse}.
|
|
184
|
+
*
|
|
185
|
+
* @async
|
|
186
|
+
* @param {Object3D} scene - The 3D object to export.
|
|
187
|
+
* @param {USDZExporter~Options} options - The export options.
|
|
188
|
+
* @return {Promise<ArrayBuffer>} A Promise that resolved with the exported USDZ data.
|
|
189
|
+
*/
|
|
190
|
+
async parseAsync( scene, options = {} ) {
|
|
191
|
+
|
|
192
|
+
options = Object.assign(
|
|
193
|
+
{
|
|
194
|
+
ar: {
|
|
195
|
+
anchoring: { type: 'plane' },
|
|
196
|
+
planeAnchoring: { alignment: 'horizontal' },
|
|
197
|
+
},
|
|
198
|
+
includeAnchoringProperties: true,
|
|
199
|
+
onlyVisible: true,
|
|
200
|
+
quickLookCompatible: false,
|
|
201
|
+
maxTextureSize: 1024,
|
|
202
|
+
},
|
|
203
|
+
options
|
|
204
|
+
);
|
|
89
205
|
|
|
90
|
-
|
|
206
|
+
const usedNames = new Set();
|
|
207
|
+
|
|
208
|
+
const files = {};
|
|
209
|
+
const modelFileName = 'model.usda';
|
|
210
|
+
|
|
211
|
+
// model file should be first in USDZ archive so we init it here
|
|
212
|
+
files[ modelFileName ] = null;
|
|
213
|
+
|
|
214
|
+
const root = new USDNode( 'Root', 'Xform' );
|
|
215
|
+
const scenesNode = new USDNode( 'Scenes', 'Scope' );
|
|
216
|
+
scenesNode.addMetadata( 'kind', '"sceneLibrary"' );
|
|
217
|
+
root.addChild( scenesNode );
|
|
218
|
+
|
|
219
|
+
const sceneName = 'Scene';
|
|
220
|
+
const sceneNode = new USDNode( sceneName, 'Xform' );
|
|
221
|
+
sceneNode.addMetadata( 'customData', [
|
|
222
|
+
'bool preliminary_collidesWithEnvironment = 0',
|
|
223
|
+
`string sceneName = "${sceneName}"`,
|
|
224
|
+
] );
|
|
225
|
+
sceneNode.addMetadata( 'sceneName', `"${sceneName}"` );
|
|
226
|
+
if ( options.includeAnchoringProperties ) {
|
|
227
|
+
|
|
228
|
+
sceneNode.addProperty(
|
|
229
|
+
`token preliminary:anchoring:type = "${options.ar.anchoring.type}"`
|
|
230
|
+
);
|
|
231
|
+
sceneNode.addProperty(
|
|
232
|
+
`token preliminary:planeAnchoring:alignment = "${options.ar.planeAnchoring.alignment}"`
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
scenesNode.addChild( sceneNode );
|
|
238
|
+
|
|
239
|
+
let output;
|
|
240
|
+
|
|
241
|
+
const materials = {};
|
|
242
|
+
const textures = {};
|
|
243
|
+
|
|
244
|
+
buildHierarchy( scene, sceneNode, materials, usedNames, files, options );
|
|
245
|
+
|
|
246
|
+
const materialsNode = buildMaterials(
|
|
247
|
+
materials,
|
|
248
|
+
textures,
|
|
249
|
+
options.quickLookCompatible
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
output =
|
|
253
|
+
buildHeader() +
|
|
254
|
+
'\n' +
|
|
255
|
+
root.toString() +
|
|
256
|
+
'\n\n' +
|
|
257
|
+
materialsNode.toString();
|
|
91
258
|
|
|
92
259
|
files[ modelFileName ] = strToU8( output );
|
|
93
260
|
output = null;
|
|
@@ -98,14 +265,32 @@ class USDZExporter {
|
|
|
98
265
|
|
|
99
266
|
if ( texture.isCompressedTexture === true ) {
|
|
100
267
|
|
|
101
|
-
|
|
268
|
+
if ( this.textureUtils === null ) {
|
|
269
|
+
|
|
270
|
+
throw new Error(
|
|
271
|
+
'THREE.USDZExporter: setTextureUtils() must be called to process compressed textures.'
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
} else {
|
|
275
|
+
|
|
276
|
+
texture = await this.textureUtils.decompress( texture );
|
|
277
|
+
|
|
278
|
+
}
|
|
102
279
|
|
|
103
280
|
}
|
|
104
281
|
|
|
105
|
-
const canvas = imageToCanvas(
|
|
106
|
-
|
|
282
|
+
const canvas = imageToCanvas(
|
|
283
|
+
texture.image,
|
|
284
|
+
texture.flipY,
|
|
285
|
+
options.maxTextureSize
|
|
286
|
+
);
|
|
287
|
+
const blob = await new Promise( ( resolve ) =>
|
|
288
|
+
canvas.toBlob( resolve, 'image/png', 1 )
|
|
289
|
+
);
|
|
107
290
|
|
|
108
|
-
files[ `textures/Texture_${
|
|
291
|
+
files[ `textures/Texture_${id}.png` ] = new Uint8Array(
|
|
292
|
+
await blob.arrayBuffer()
|
|
293
|
+
);
|
|
109
294
|
|
|
110
295
|
}
|
|
111
296
|
|
|
@@ -142,12 +327,53 @@ class USDZExporter {
|
|
|
142
327
|
|
|
143
328
|
}
|
|
144
329
|
|
|
330
|
+
function getName( object, namesSet ) {
|
|
331
|
+
|
|
332
|
+
let name = object.name;
|
|
333
|
+
name = name.replace( /[^A-Za-z0-9_]/g, '' );
|
|
334
|
+
if ( /^[0-9]/.test( name ) ) {
|
|
335
|
+
|
|
336
|
+
name = '_' + name;
|
|
337
|
+
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if ( name === '' ) {
|
|
341
|
+
|
|
342
|
+
if ( object.isCamera ) {
|
|
343
|
+
|
|
344
|
+
name = 'Camera';
|
|
345
|
+
|
|
346
|
+
} else {
|
|
347
|
+
|
|
348
|
+
name = 'Object';
|
|
349
|
+
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
if ( namesSet.has( name ) ) {
|
|
355
|
+
|
|
356
|
+
name = name + '_' + object.id;
|
|
357
|
+
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
namesSet.add( name );
|
|
361
|
+
|
|
362
|
+
return name;
|
|
363
|
+
|
|
364
|
+
}
|
|
365
|
+
|
|
145
366
|
function imageToCanvas( image, flipY, maxTextureSize ) {
|
|
146
367
|
|
|
147
|
-
if (
|
|
148
|
-
( typeof
|
|
149
|
-
|
|
150
|
-
( typeof
|
|
368
|
+
if (
|
|
369
|
+
( typeof HTMLImageElement !== 'undefined' &&
|
|
370
|
+
image instanceof HTMLImageElement ) ||
|
|
371
|
+
( typeof HTMLCanvasElement !== 'undefined' &&
|
|
372
|
+
image instanceof HTMLCanvasElement ) ||
|
|
373
|
+
( typeof OffscreenCanvas !== 'undefined' &&
|
|
374
|
+
image instanceof OffscreenCanvas ) ||
|
|
375
|
+
( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap )
|
|
376
|
+
) {
|
|
151
377
|
|
|
152
378
|
const scale = maxTextureSize / Math.max( image.width, image.height );
|
|
153
379
|
|
|
@@ -172,7 +398,9 @@ function imageToCanvas( image, flipY, maxTextureSize ) {
|
|
|
172
398
|
|
|
173
399
|
} else {
|
|
174
400
|
|
|
175
|
-
throw new Error(
|
|
401
|
+
throw new Error(
|
|
402
|
+
'THREE.USDZExporter: No valid image data found. Unable to process texture.'
|
|
403
|
+
);
|
|
176
404
|
|
|
177
405
|
}
|
|
178
406
|
|
|
@@ -193,79 +421,140 @@ function buildHeader() {
|
|
|
193
421
|
metersPerUnit = 1
|
|
194
422
|
upAxis = "Y"
|
|
195
423
|
)
|
|
196
|
-
|
|
197
424
|
`;
|
|
198
425
|
|
|
199
426
|
}
|
|
200
427
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
428
|
+
// Xform
|
|
429
|
+
|
|
430
|
+
function buildHierarchy( object, parentNode, materials, usedNames, files, options ) {
|
|
431
|
+
|
|
432
|
+
for ( let i = 0, l = object.children.length; i < l; i ++ ) {
|
|
433
|
+
|
|
434
|
+
const child = object.children[ i ];
|
|
435
|
+
|
|
436
|
+
if ( child.visible === false && options.onlyVisible === true ) continue;
|
|
437
|
+
|
|
438
|
+
let childNode;
|
|
439
|
+
|
|
440
|
+
if ( child.isMesh ) {
|
|
441
|
+
|
|
442
|
+
const geometry = child.geometry;
|
|
443
|
+
const material = child.material;
|
|
444
|
+
|
|
445
|
+
if ( material.isMeshStandardMaterial ) {
|
|
446
|
+
|
|
447
|
+
const geometryFileName = 'geometries/Geometry_' + geometry.id + '.usda';
|
|
448
|
+
|
|
449
|
+
if ( ! ( geometryFileName in files ) ) {
|
|
450
|
+
|
|
451
|
+
const meshObject = buildMeshObject( geometry );
|
|
452
|
+
files[ geometryFileName ] = strToU8(
|
|
453
|
+
buildHeader() + '\n' + meshObject.toString()
|
|
454
|
+
);
|
|
455
|
+
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
if ( ! ( material.uuid in materials ) ) {
|
|
459
|
+
|
|
460
|
+
materials[ material.uuid ] = material;
|
|
461
|
+
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
childNode = buildMesh(
|
|
465
|
+
child,
|
|
466
|
+
geometry,
|
|
467
|
+
materials[ material.uuid ],
|
|
468
|
+
usedNames
|
|
469
|
+
);
|
|
470
|
+
|
|
471
|
+
} else {
|
|
472
|
+
|
|
473
|
+
console.warn(
|
|
474
|
+
'THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)',
|
|
475
|
+
child
|
|
476
|
+
);
|
|
477
|
+
|
|
217
478
|
}
|
|
218
|
-
sceneName = "Scene"
|
|
219
|
-
)
|
|
220
|
-
{${alignment}
|
|
221
|
-
`;
|
|
222
479
|
|
|
223
|
-
}
|
|
480
|
+
} else if ( child.isCamera ) {
|
|
481
|
+
|
|
482
|
+
childNode = buildCamera( child, usedNames );
|
|
224
483
|
|
|
225
|
-
|
|
484
|
+
} else {
|
|
485
|
+
|
|
486
|
+
childNode = buildXform( child, usedNames );
|
|
226
487
|
|
|
227
|
-
return `
|
|
228
488
|
}
|
|
489
|
+
|
|
490
|
+
if ( childNode ) {
|
|
491
|
+
|
|
492
|
+
parentNode.addChild( childNode );
|
|
493
|
+
buildHierarchy( child, childNode, materials, usedNames, files, options );
|
|
494
|
+
|
|
495
|
+
}
|
|
496
|
+
|
|
229
497
|
}
|
|
498
|
+
|
|
230
499
|
}
|
|
231
500
|
|
|
232
|
-
|
|
501
|
+
function buildXform( object, usedNames ) {
|
|
233
502
|
|
|
234
|
-
|
|
503
|
+
const name = getName( object, usedNames );
|
|
235
504
|
|
|
236
|
-
|
|
505
|
+
if ( object.matrix.determinant() < 0 ) {
|
|
237
506
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
507
|
+
console.warn(
|
|
508
|
+
'THREE.USDZExporter: USDZ does not support negative scales',
|
|
509
|
+
object
|
|
510
|
+
);
|
|
241
511
|
|
|
242
|
-
}
|
|
512
|
+
}
|
|
243
513
|
|
|
244
|
-
|
|
514
|
+
const node = new USDNode( name, 'Xform' );
|
|
515
|
+
|
|
516
|
+
if ( object.pivot !== null ) {
|
|
245
517
|
|
|
246
|
-
|
|
518
|
+
// Export with pivot using separate transform ops
|
|
519
|
+
const p = object.position;
|
|
520
|
+
const q = object.quaternion;
|
|
521
|
+
const s = object.scale;
|
|
522
|
+
const piv = object.pivot;
|
|
247
523
|
|
|
248
|
-
|
|
249
|
-
|
|
524
|
+
node.addProperty( `float3 xformOp:translate = (${p.x.toPrecision( PRECISION )}, ${p.y.toPrecision( PRECISION )}, ${p.z.toPrecision( PRECISION )})` );
|
|
525
|
+
node.addProperty( `float3 xformOp:translate:pivot = (${piv.x.toPrecision( PRECISION )}, ${piv.y.toPrecision( PRECISION )}, ${piv.z.toPrecision( PRECISION )})` );
|
|
526
|
+
node.addProperty( `quatf xformOp:orient = (${q.w.toPrecision( PRECISION )}, ${q.x.toPrecision( PRECISION )}, ${q.y.toPrecision( PRECISION )}, ${q.z.toPrecision( PRECISION )})` );
|
|
527
|
+
node.addProperty( `float3 xformOp:scale = (${s.x.toPrecision( PRECISION )}, ${s.y.toPrecision( PRECISION )}, ${s.z.toPrecision( PRECISION )})` );
|
|
528
|
+
node.addProperty( 'uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:translate:pivot", "xformOp:orient", "xformOp:scale", "!invert!xformOp:translate:pivot"]' );
|
|
250
529
|
|
|
251
|
-
|
|
530
|
+
} else {
|
|
252
531
|
|
|
253
|
-
|
|
532
|
+
// Export as single transform matrix
|
|
533
|
+
const transform = buildMatrix( object.matrix );
|
|
534
|
+
node.addProperty( `matrix4d xformOp:transform = ${transform}` );
|
|
535
|
+
node.addProperty( 'uniform token[] xformOpOrder = ["xformOp:transform"]' );
|
|
254
536
|
|
|
255
537
|
}
|
|
256
538
|
|
|
257
|
-
return
|
|
258
|
-
prepend references = @./geometries/Geometry_${ geometry.id }.usda@</Geometry>
|
|
259
|
-
prepend apiSchemas = ["MaterialBindingAPI"]
|
|
260
|
-
)
|
|
261
|
-
{
|
|
262
|
-
matrix4d xformOp:transform = ${ transform }
|
|
263
|
-
uniform token[] xformOpOrder = ["xformOp:transform"]
|
|
539
|
+
return node;
|
|
264
540
|
|
|
265
|
-
rel material:binding = </Materials/Material_${ material.id }>
|
|
266
541
|
}
|
|
267
542
|
|
|
268
|
-
|
|
543
|
+
function buildMesh( object, geometry, material, usedNames ) {
|
|
544
|
+
|
|
545
|
+
const node = buildXform( object, usedNames );
|
|
546
|
+
|
|
547
|
+
node.addMetadata(
|
|
548
|
+
'prepend references',
|
|
549
|
+
`@./geometries/Geometry_${geometry.id}.usda@</Geometry>`
|
|
550
|
+
);
|
|
551
|
+
node.addMetadata( 'prepend apiSchemas', '["MaterialBindingAPI"]' );
|
|
552
|
+
|
|
553
|
+
node.addProperty(
|
|
554
|
+
`rel material:binding = </Materials/Material_${material.id}>`
|
|
555
|
+
);
|
|
556
|
+
|
|
557
|
+
return node;
|
|
269
558
|
|
|
270
559
|
}
|
|
271
560
|
|
|
@@ -273,13 +562,18 @@ function buildMatrix( matrix ) {
|
|
|
273
562
|
|
|
274
563
|
const array = matrix.elements;
|
|
275
564
|
|
|
276
|
-
return `( ${
|
|
565
|
+
return `( ${buildMatrixRow( array, 0 )}, ${buildMatrixRow(
|
|
566
|
+
array,
|
|
567
|
+
4
|
|
568
|
+
)}, ${buildMatrixRow( array, 8 )}, ${buildMatrixRow( array, 12 )} )`;
|
|
277
569
|
|
|
278
570
|
}
|
|
279
571
|
|
|
280
572
|
function buildMatrixRow( array, offset ) {
|
|
281
573
|
|
|
282
|
-
return `(${
|
|
574
|
+
return `(${array[ offset + 0 ]}, ${array[ offset + 1 ]}, ${array[ offset + 2 ]}, ${
|
|
575
|
+
array[ offset + 3 ]
|
|
576
|
+
})`;
|
|
283
577
|
|
|
284
578
|
}
|
|
285
579
|
|
|
@@ -287,43 +581,81 @@ function buildMatrixRow( array, offset ) {
|
|
|
287
581
|
|
|
288
582
|
function buildMeshObject( geometry ) {
|
|
289
583
|
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
`;
|
|
584
|
+
const node = new USDNode( 'Geometry' );
|
|
585
|
+
|
|
586
|
+
const meshNode = buildMeshNode( geometry );
|
|
587
|
+
node.addChild( meshNode );
|
|
588
|
+
|
|
589
|
+
return node;
|
|
297
590
|
|
|
298
591
|
}
|
|
299
592
|
|
|
300
|
-
function
|
|
593
|
+
function buildMeshNode( geometry ) {
|
|
301
594
|
|
|
302
595
|
const name = 'Geometry';
|
|
303
596
|
const attributes = geometry.attributes;
|
|
304
597
|
const count = attributes.position.count;
|
|
305
598
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
int[] faceVertexCounts = [${
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
${
|
|
316
|
-
|
|
599
|
+
const node = new USDNode( name, 'Mesh' );
|
|
600
|
+
|
|
601
|
+
node.addProperty(
|
|
602
|
+
`int[] faceVertexCounts = [${buildMeshVertexCount( geometry )}]`
|
|
603
|
+
);
|
|
604
|
+
node.addProperty(
|
|
605
|
+
`int[] faceVertexIndices = [${buildMeshVertexIndices( geometry )}]`
|
|
606
|
+
);
|
|
607
|
+
node.addProperty(
|
|
608
|
+
`normal3f[] normals = [${buildVector3Array( attributes.normal, count )}]`,
|
|
609
|
+
[ 'interpolation = "vertex"' ]
|
|
610
|
+
);
|
|
611
|
+
node.addProperty(
|
|
612
|
+
`point3f[] points = [${buildVector3Array( attributes.position, count )}]`
|
|
613
|
+
);
|
|
614
|
+
|
|
615
|
+
for ( let i = 0; i < 4; i ++ ) {
|
|
616
|
+
|
|
617
|
+
const id = i > 0 ? i : '';
|
|
618
|
+
const attribute = attributes[ 'uv' + id ];
|
|
619
|
+
if ( attribute !== undefined ) {
|
|
620
|
+
|
|
621
|
+
node.addProperty(
|
|
622
|
+
`texCoord2f[] primvars:st${id} = [${buildVector2Array( attribute )}]`,
|
|
623
|
+
[ 'interpolation = "vertex"' ]
|
|
624
|
+
);
|
|
625
|
+
|
|
626
|
+
}
|
|
627
|
+
|
|
317
628
|
}
|
|
318
|
-
|
|
629
|
+
|
|
630
|
+
const colorAttribute = attributes.color;
|
|
631
|
+
if ( colorAttribute !== undefined ) {
|
|
632
|
+
|
|
633
|
+
node.addProperty(
|
|
634
|
+
`color3f[] primvars:displayColor = [${buildVector3Array(
|
|
635
|
+
colorAttribute,
|
|
636
|
+
count
|
|
637
|
+
)}]`,
|
|
638
|
+
[ 'interpolation = "vertex"' ]
|
|
639
|
+
);
|
|
640
|
+
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
node.addProperty( 'uniform token subdivisionScheme = "none"' );
|
|
644
|
+
|
|
645
|
+
return node;
|
|
319
646
|
|
|
320
647
|
}
|
|
321
648
|
|
|
322
649
|
function buildMeshVertexCount( geometry ) {
|
|
323
650
|
|
|
324
|
-
const count =
|
|
651
|
+
const count =
|
|
652
|
+
geometry.index !== null
|
|
653
|
+
? geometry.index.count
|
|
654
|
+
: geometry.attributes.position.count;
|
|
325
655
|
|
|
326
|
-
return Array( count / 3 )
|
|
656
|
+
return Array( count / 3 )
|
|
657
|
+
.fill( 3 )
|
|
658
|
+
.join( ', ' );
|
|
327
659
|
|
|
328
660
|
}
|
|
329
661
|
|
|
@@ -373,7 +705,11 @@ function buildVector3Array( attribute, count ) {
|
|
|
373
705
|
const y = attribute.getY( i );
|
|
374
706
|
const z = attribute.getZ( i );
|
|
375
707
|
|
|
376
|
-
array.push(
|
|
708
|
+
array.push(
|
|
709
|
+
`(${x.toPrecision( PRECISION )}, ${y.toPrecision(
|
|
710
|
+
PRECISION
|
|
711
|
+
)}, ${z.toPrecision( PRECISION )})`
|
|
712
|
+
);
|
|
377
713
|
|
|
378
714
|
}
|
|
379
715
|
|
|
@@ -390,7 +726,9 @@ function buildVector2Array( attribute ) {
|
|
|
390
726
|
const x = attribute.getX( i );
|
|
391
727
|
const y = attribute.getY( i );
|
|
392
728
|
|
|
393
|
-
array.push(
|
|
729
|
+
array.push(
|
|
730
|
+
`(${x.toPrecision( PRECISION )}, ${1 - y.toPrecision( PRECISION )})`
|
|
731
|
+
);
|
|
394
732
|
|
|
395
733
|
}
|
|
396
734
|
|
|
@@ -398,65 +736,23 @@ function buildVector2Array( attribute ) {
|
|
|
398
736
|
|
|
399
737
|
}
|
|
400
738
|
|
|
401
|
-
function buildPrimvars( attributes ) {
|
|
402
|
-
|
|
403
|
-
let string = '';
|
|
404
|
-
|
|
405
|
-
for ( let i = 0; i < 4; i ++ ) {
|
|
406
|
-
|
|
407
|
-
const id = ( i > 0 ? i : '' );
|
|
408
|
-
const attribute = attributes[ 'uv' + id ];
|
|
409
|
-
|
|
410
|
-
if ( attribute !== undefined ) {
|
|
411
|
-
|
|
412
|
-
string += `
|
|
413
|
-
texCoord2f[] primvars:st${ id } = [${ buildVector2Array( attribute )}] (
|
|
414
|
-
interpolation = "vertex"
|
|
415
|
-
)`;
|
|
416
|
-
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
// vertex colors
|
|
422
|
-
|
|
423
|
-
const colorAttribute = attributes.color;
|
|
424
|
-
|
|
425
|
-
if ( colorAttribute !== undefined ) {
|
|
426
|
-
|
|
427
|
-
const count = colorAttribute.count;
|
|
428
|
-
|
|
429
|
-
string += `
|
|
430
|
-
color3f[] primvars:displayColor = [${buildVector3Array( colorAttribute, count )}] (
|
|
431
|
-
interpolation = "vertex"
|
|
432
|
-
)`;
|
|
433
|
-
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
return string;
|
|
437
|
-
|
|
438
|
-
}
|
|
439
|
-
|
|
440
739
|
// Materials
|
|
441
740
|
|
|
442
741
|
function buildMaterials( materials, textures, quickLookCompatible = false ) {
|
|
443
742
|
|
|
444
|
-
const
|
|
743
|
+
const materialsNode = new USDNode( 'Materials' );
|
|
445
744
|
|
|
446
745
|
for ( const uuid in materials ) {
|
|
447
746
|
|
|
448
747
|
const material = materials[ uuid ];
|
|
449
748
|
|
|
450
|
-
|
|
749
|
+
materialsNode.addChild(
|
|
750
|
+
buildMaterial( material, textures, quickLookCompatible )
|
|
751
|
+
);
|
|
451
752
|
|
|
452
753
|
}
|
|
453
754
|
|
|
454
|
-
return
|
|
455
|
-
{
|
|
456
|
-
${ array.join( '' ) }
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
`;
|
|
755
|
+
return materialsNode;
|
|
460
756
|
|
|
461
757
|
}
|
|
462
758
|
|
|
@@ -464,11 +760,9 @@ function buildMaterial( material, textures, quickLookCompatible = false ) {
|
|
|
464
760
|
|
|
465
761
|
// https://graphics.pixar.com/usd/docs/UsdPreviewSurface-Proposal.html
|
|
466
762
|
|
|
467
|
-
const
|
|
468
|
-
const inputs = [];
|
|
469
|
-
const samplers = [];
|
|
763
|
+
const materialNode = new USDNode( `Material_${material.id}`, 'Material' );
|
|
470
764
|
|
|
471
|
-
function
|
|
765
|
+
function buildTextureNodes( texture, mapType, color ) {
|
|
472
766
|
|
|
473
767
|
const id = texture.source.id + '_' + texture.flipY;
|
|
474
768
|
|
|
@@ -479,7 +773,7 @@ function buildMaterial( material, textures, quickLookCompatible = false ) {
|
|
|
479
773
|
const WRAPPINGS = {
|
|
480
774
|
1000: 'repeat', // RepeatWrapping
|
|
481
775
|
1001: 'clamp', // ClampToEdgeWrapping
|
|
482
|
-
1002: 'mirror' // MirroredRepeatWrapping
|
|
776
|
+
1002: 'mirror', // MirroredRepeatWrapping
|
|
483
777
|
};
|
|
484
778
|
|
|
485
779
|
const repeat = texture.repeat.clone();
|
|
@@ -514,135 +808,255 @@ function buildMaterial( material, textures, quickLookCompatible = false ) {
|
|
|
514
808
|
|
|
515
809
|
}
|
|
516
810
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
811
|
+
const primvarReaderNode = new USDNode( `PrimvarReader_${mapType}`, 'Shader' );
|
|
812
|
+
primvarReaderNode.addProperty(
|
|
813
|
+
'uniform token info:id = "UsdPrimvarReader_float2"'
|
|
814
|
+
);
|
|
815
|
+
primvarReaderNode.addProperty( 'float2 inputs:fallback = (0.0, 0.0)' );
|
|
816
|
+
primvarReaderNode.addProperty( `string inputs:varname = "${uv}"` );
|
|
817
|
+
primvarReaderNode.addProperty( 'float2 outputs:result' );
|
|
818
|
+
|
|
819
|
+
const transform2dNode = new USDNode( `Transform2d_${mapType}`, 'Shader' );
|
|
820
|
+
transform2dNode.addProperty( 'uniform token info:id = "UsdTransform2d"' );
|
|
821
|
+
transform2dNode.addProperty(
|
|
822
|
+
`float2 inputs:in.connect = </Materials/Material_${material.id}/PrimvarReader_${mapType}.outputs:result>`
|
|
823
|
+
);
|
|
824
|
+
transform2dNode.addProperty(
|
|
825
|
+
`float inputs:rotation = ${( rotation * ( 180 / Math.PI ) ).toFixed(
|
|
826
|
+
PRECISION
|
|
827
|
+
)}`
|
|
828
|
+
);
|
|
829
|
+
transform2dNode.addProperty(
|
|
830
|
+
`float2 inputs:scale = ${buildVector2( repeat )}`
|
|
831
|
+
);
|
|
832
|
+
transform2dNode.addProperty(
|
|
833
|
+
`float2 inputs:translation = ${buildVector2( offset )}`
|
|
834
|
+
);
|
|
835
|
+
transform2dNode.addProperty( 'float2 outputs:result' );
|
|
836
|
+
|
|
837
|
+
const textureNode = new USDNode(
|
|
838
|
+
`Texture_${texture.id}_${mapType}`,
|
|
839
|
+
'Shader'
|
|
840
|
+
);
|
|
841
|
+
textureNode.addProperty( 'uniform token info:id = "UsdUVTexture"' );
|
|
842
|
+
textureNode.addProperty( `asset inputs:file = @textures/Texture_${id}.png@` );
|
|
843
|
+
textureNode.addProperty(
|
|
844
|
+
`float2 inputs:st.connect = </Materials/Material_${material.id}/Transform2d_${mapType}.outputs:result>`
|
|
845
|
+
);
|
|
846
|
+
|
|
847
|
+
if ( color !== undefined ) {
|
|
848
|
+
|
|
849
|
+
textureNode.addProperty( `float4 inputs:scale = ${buildColor4( color )}` );
|
|
850
|
+
|
|
524
851
|
}
|
|
525
852
|
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
float2 inputs:scale = ${ buildVector2( repeat ) }
|
|
532
|
-
float2 inputs:translation = ${ buildVector2( offset ) }
|
|
533
|
-
float2 outputs:result
|
|
853
|
+
if ( mapType === 'normal' ) {
|
|
854
|
+
|
|
855
|
+
textureNode.addProperty( 'float4 inputs:scale = (2, 2, 2, 1)' );
|
|
856
|
+
textureNode.addProperty( 'float4 inputs:bias = (-1, -1, -1, 0)' );
|
|
857
|
+
|
|
534
858
|
}
|
|
535
859
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
token inputs:
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
860
|
+
textureNode.addProperty(
|
|
861
|
+
`token inputs:sourceColorSpace = "${
|
|
862
|
+
texture.colorSpace === NoColorSpace ? 'raw' : 'sRGB'
|
|
863
|
+
}"`
|
|
864
|
+
);
|
|
865
|
+
textureNode.addProperty(
|
|
866
|
+
`token inputs:wrapS = "${WRAPPINGS[ texture.wrapS ]}"`
|
|
867
|
+
);
|
|
868
|
+
textureNode.addProperty(
|
|
869
|
+
`token inputs:wrapT = "${WRAPPINGS[ texture.wrapT ]}"`
|
|
870
|
+
);
|
|
871
|
+
textureNode.addProperty( 'float outputs:r' );
|
|
872
|
+
textureNode.addProperty( 'float outputs:g' );
|
|
873
|
+
textureNode.addProperty( 'float outputs:b' );
|
|
874
|
+
textureNode.addProperty( 'float3 outputs:rgb' );
|
|
875
|
+
|
|
876
|
+
if ( material.transparent || material.alphaTest > 0.0 ) {
|
|
877
|
+
|
|
878
|
+
textureNode.addProperty( 'float outputs:a' );
|
|
551
879
|
|
|
552
|
-
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
return [ primvarReaderNode, transform2dNode, textureNode ];
|
|
553
883
|
|
|
884
|
+
}
|
|
554
885
|
|
|
555
886
|
if ( material.side === DoubleSide ) {
|
|
556
887
|
|
|
557
|
-
console.warn(
|
|
888
|
+
console.warn(
|
|
889
|
+
'THREE.USDZExporter: USDZ does not support double sided materials',
|
|
890
|
+
material
|
|
891
|
+
);
|
|
558
892
|
|
|
559
893
|
}
|
|
560
894
|
|
|
895
|
+
const previewSurfaceNode = new USDNode( 'PreviewSurface', 'Shader' );
|
|
896
|
+
previewSurfaceNode.addProperty( 'uniform token info:id = "UsdPreviewSurface"' );
|
|
897
|
+
|
|
561
898
|
if ( material.map?.image ) {
|
|
562
899
|
|
|
563
|
-
|
|
900
|
+
previewSurfaceNode.addProperty(
|
|
901
|
+
`color3f inputs:diffuseColor.connect = </Materials/Material_${material.id}/Texture_${material.map.id}_diffuse.outputs:rgb>`
|
|
902
|
+
);
|
|
564
903
|
|
|
565
904
|
if ( material.transparent ) {
|
|
566
905
|
|
|
567
|
-
|
|
906
|
+
previewSurfaceNode.addProperty(
|
|
907
|
+
`float inputs:opacity.connect = </Materials/Material_${material.id}/Texture_${material.map.id}_diffuse.outputs:a>`
|
|
908
|
+
);
|
|
568
909
|
|
|
569
910
|
} else if ( material.alphaTest > 0.0 ) {
|
|
570
911
|
|
|
571
|
-
|
|
572
|
-
|
|
912
|
+
previewSurfaceNode.addProperty(
|
|
913
|
+
`float inputs:opacity.connect = </Materials/Material_${material.id}/Texture_${material.map.id}_diffuse.outputs:a>`
|
|
914
|
+
);
|
|
915
|
+
previewSurfaceNode.addProperty(
|
|
916
|
+
`float inputs:opacityThreshold = ${material.alphaTest}`
|
|
917
|
+
);
|
|
573
918
|
|
|
574
919
|
}
|
|
575
920
|
|
|
576
|
-
|
|
921
|
+
const textureNodes = buildTextureNodes(
|
|
922
|
+
material.map,
|
|
923
|
+
'diffuse',
|
|
924
|
+
material.color
|
|
925
|
+
);
|
|
926
|
+
textureNodes.forEach( ( node ) => materialNode.addChild( node ) );
|
|
577
927
|
|
|
578
928
|
} else {
|
|
579
929
|
|
|
580
|
-
|
|
930
|
+
previewSurfaceNode.addProperty(
|
|
931
|
+
`color3f inputs:diffuseColor = ${buildColor( material.color )}`
|
|
932
|
+
);
|
|
581
933
|
|
|
582
934
|
}
|
|
583
935
|
|
|
584
936
|
if ( material.emissiveMap?.image ) {
|
|
585
937
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
938
|
+
previewSurfaceNode.addProperty(
|
|
939
|
+
`color3f inputs:emissiveColor.connect = </Materials/Material_${material.id}/Texture_${material.emissiveMap.id}_emissive.outputs:rgb>`
|
|
940
|
+
);
|
|
941
|
+
|
|
942
|
+
const emissiveColor = new Color(
|
|
943
|
+
material.emissive.r * material.emissiveIntensity,
|
|
944
|
+
material.emissive.g * material.emissiveIntensity,
|
|
945
|
+
material.emissive.b * material.emissiveIntensity
|
|
946
|
+
);
|
|
947
|
+
const textureNodes = buildTextureNodes(
|
|
948
|
+
material.emissiveMap,
|
|
949
|
+
'emissive',
|
|
950
|
+
emissiveColor
|
|
951
|
+
);
|
|
952
|
+
textureNodes.forEach( ( node ) => materialNode.addChild( node ) );
|
|
589
953
|
|
|
590
954
|
} else if ( material.emissive.getHex() > 0 ) {
|
|
591
955
|
|
|
592
|
-
|
|
956
|
+
previewSurfaceNode.addProperty(
|
|
957
|
+
`color3f inputs:emissiveColor = ${buildColor( material.emissive )}`
|
|
958
|
+
);
|
|
593
959
|
|
|
594
960
|
}
|
|
595
961
|
|
|
596
962
|
if ( material.normalMap?.image ) {
|
|
597
963
|
|
|
598
|
-
|
|
964
|
+
previewSurfaceNode.addProperty(
|
|
965
|
+
`normal3f inputs:normal.connect = </Materials/Material_${material.id}/Texture_${material.normalMap.id}_normal.outputs:rgb>`
|
|
966
|
+
);
|
|
599
967
|
|
|
600
|
-
|
|
968
|
+
const textureNodes = buildTextureNodes( material.normalMap, 'normal' );
|
|
969
|
+
textureNodes.forEach( ( node ) => materialNode.addChild( node ) );
|
|
601
970
|
|
|
602
971
|
}
|
|
603
972
|
|
|
604
973
|
if ( material.aoMap?.image ) {
|
|
605
974
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
975
|
+
previewSurfaceNode.addProperty(
|
|
976
|
+
`float inputs:occlusion.connect = </Materials/Material_${material.id}/Texture_${material.aoMap.id}_occlusion.outputs:r>`
|
|
977
|
+
);
|
|
978
|
+
|
|
979
|
+
const aoColor = new Color(
|
|
980
|
+
material.aoMapIntensity,
|
|
981
|
+
material.aoMapIntensity,
|
|
982
|
+
material.aoMapIntensity
|
|
983
|
+
);
|
|
984
|
+
const textureNodes = buildTextureNodes(
|
|
985
|
+
material.aoMap,
|
|
986
|
+
'occlusion',
|
|
987
|
+
aoColor
|
|
988
|
+
);
|
|
989
|
+
textureNodes.forEach( ( node ) => materialNode.addChild( node ) );
|
|
609
990
|
|
|
610
991
|
}
|
|
611
992
|
|
|
612
993
|
if ( material.roughnessMap?.image && material.roughness === 1 ) {
|
|
613
994
|
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
995
|
+
previewSurfaceNode.addProperty(
|
|
996
|
+
`float inputs:roughness.connect = </Materials/Material_${material.id}/Texture_${material.roughnessMap.id}_roughness.outputs:g>`
|
|
997
|
+
);
|
|
998
|
+
|
|
999
|
+
const roughnessColor = new Color(
|
|
1000
|
+
material.roughness,
|
|
1001
|
+
material.roughness,
|
|
1002
|
+
material.roughness
|
|
1003
|
+
);
|
|
1004
|
+
const textureNodes = buildTextureNodes(
|
|
1005
|
+
material.roughnessMap,
|
|
1006
|
+
'roughness',
|
|
1007
|
+
roughnessColor
|
|
1008
|
+
);
|
|
1009
|
+
textureNodes.forEach( ( node ) => materialNode.addChild( node ) );
|
|
617
1010
|
|
|
618
1011
|
} else {
|
|
619
1012
|
|
|
620
|
-
|
|
1013
|
+
previewSurfaceNode.addProperty(
|
|
1014
|
+
`float inputs:roughness = ${material.roughness}`
|
|
1015
|
+
);
|
|
621
1016
|
|
|
622
1017
|
}
|
|
623
1018
|
|
|
624
1019
|
if ( material.metalnessMap?.image && material.metalness === 1 ) {
|
|
625
1020
|
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
1021
|
+
previewSurfaceNode.addProperty(
|
|
1022
|
+
`float inputs:metallic.connect = </Materials/Material_${material.id}/Texture_${material.metalnessMap.id}_metallic.outputs:b>`
|
|
1023
|
+
);
|
|
1024
|
+
|
|
1025
|
+
const metalnessColor = new Color(
|
|
1026
|
+
material.metalness,
|
|
1027
|
+
material.metalness,
|
|
1028
|
+
material.metalness
|
|
1029
|
+
);
|
|
1030
|
+
const textureNodes = buildTextureNodes(
|
|
1031
|
+
material.metalnessMap,
|
|
1032
|
+
'metallic',
|
|
1033
|
+
metalnessColor
|
|
1034
|
+
);
|
|
1035
|
+
textureNodes.forEach( ( node ) => materialNode.addChild( node ) );
|
|
629
1036
|
|
|
630
1037
|
} else {
|
|
631
1038
|
|
|
632
|
-
|
|
1039
|
+
previewSurfaceNode.addProperty(
|
|
1040
|
+
`float inputs:metallic = ${material.metalness}`
|
|
1041
|
+
);
|
|
633
1042
|
|
|
634
1043
|
}
|
|
635
1044
|
|
|
636
1045
|
if ( material.alphaMap?.image ) {
|
|
637
1046
|
|
|
638
|
-
|
|
639
|
-
|
|
1047
|
+
previewSurfaceNode.addProperty(
|
|
1048
|
+
`float inputs:opacity.connect = </Materials/Material_${material.id}/Texture_${material.alphaMap.id}_opacity.outputs:r>`
|
|
1049
|
+
);
|
|
1050
|
+
previewSurfaceNode.addProperty( 'float inputs:opacityThreshold = 0.0001' );
|
|
640
1051
|
|
|
641
|
-
|
|
1052
|
+
const textureNodes = buildTextureNodes( material.alphaMap, 'opacity' );
|
|
1053
|
+
textureNodes.forEach( ( node ) => materialNode.addChild( node ) );
|
|
642
1054
|
|
|
643
1055
|
} else {
|
|
644
1056
|
|
|
645
|
-
|
|
1057
|
+
previewSurfaceNode.addProperty(
|
|
1058
|
+
`float inputs:opacity = ${material.opacity}`
|
|
1059
|
+
);
|
|
646
1060
|
|
|
647
1061
|
}
|
|
648
1062
|
|
|
@@ -650,115 +1064,191 @@ function buildMaterial( material, textures, quickLookCompatible = false ) {
|
|
|
650
1064
|
|
|
651
1065
|
if ( material.clearcoatMap !== null ) {
|
|
652
1066
|
|
|
653
|
-
|
|
654
|
-
|
|
1067
|
+
previewSurfaceNode.addProperty(
|
|
1068
|
+
`float inputs:clearcoat.connect = </Materials/Material_${material.id}/Texture_${material.clearcoatMap.id}_clearcoat.outputs:r>`
|
|
1069
|
+
);
|
|
1070
|
+
|
|
1071
|
+
const clearcoatColor = new Color(
|
|
1072
|
+
material.clearcoat,
|
|
1073
|
+
material.clearcoat,
|
|
1074
|
+
material.clearcoat
|
|
1075
|
+
);
|
|
1076
|
+
const textureNodes = buildTextureNodes(
|
|
1077
|
+
material.clearcoatMap,
|
|
1078
|
+
'clearcoat',
|
|
1079
|
+
clearcoatColor
|
|
1080
|
+
);
|
|
1081
|
+
textureNodes.forEach( ( node ) => materialNode.addChild( node ) );
|
|
655
1082
|
|
|
656
1083
|
} else {
|
|
657
1084
|
|
|
658
|
-
|
|
1085
|
+
previewSurfaceNode.addProperty(
|
|
1086
|
+
`float inputs:clearcoat = ${material.clearcoat}`
|
|
1087
|
+
);
|
|
659
1088
|
|
|
660
1089
|
}
|
|
661
1090
|
|
|
662
1091
|
if ( material.clearcoatRoughnessMap !== null ) {
|
|
663
1092
|
|
|
664
|
-
|
|
665
|
-
|
|
1093
|
+
previewSurfaceNode.addProperty(
|
|
1094
|
+
`float inputs:clearcoatRoughness.connect = </Materials/Material_${material.id}/Texture_${material.clearcoatRoughnessMap.id}_clearcoatRoughness.outputs:g>`
|
|
1095
|
+
);
|
|
1096
|
+
|
|
1097
|
+
const clearcoatRoughnessColor = new Color(
|
|
1098
|
+
material.clearcoatRoughness,
|
|
1099
|
+
material.clearcoatRoughness,
|
|
1100
|
+
material.clearcoatRoughness
|
|
1101
|
+
);
|
|
1102
|
+
const textureNodes = buildTextureNodes(
|
|
1103
|
+
material.clearcoatRoughnessMap,
|
|
1104
|
+
'clearcoatRoughness',
|
|
1105
|
+
clearcoatRoughnessColor
|
|
1106
|
+
);
|
|
1107
|
+
textureNodes.forEach( ( node ) => materialNode.addChild( node ) );
|
|
666
1108
|
|
|
667
1109
|
} else {
|
|
668
1110
|
|
|
669
|
-
|
|
1111
|
+
previewSurfaceNode.addProperty(
|
|
1112
|
+
`float inputs:clearcoatRoughness = ${material.clearcoatRoughness}`
|
|
1113
|
+
);
|
|
670
1114
|
|
|
671
1115
|
}
|
|
672
1116
|
|
|
673
|
-
|
|
1117
|
+
previewSurfaceNode.addProperty( `float inputs:ior = ${material.ior}` );
|
|
674
1118
|
|
|
675
1119
|
}
|
|
676
1120
|
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
{
|
|
680
|
-
def Shader "PreviewSurface"
|
|
681
|
-
{
|
|
682
|
-
uniform token info:id = "UsdPreviewSurface"
|
|
683
|
-
${ inputs.join( '\n' ) }
|
|
684
|
-
int inputs:useSpecularWorkflow = 0
|
|
685
|
-
token outputs:surface
|
|
686
|
-
}
|
|
1121
|
+
previewSurfaceNode.addProperty( 'int inputs:useSpecularWorkflow = 0' );
|
|
1122
|
+
previewSurfaceNode.addProperty( 'token outputs:surface' );
|
|
687
1123
|
|
|
688
|
-
|
|
1124
|
+
materialNode.addChild( previewSurfaceNode );
|
|
689
1125
|
|
|
690
|
-
|
|
1126
|
+
materialNode.addProperty(
|
|
1127
|
+
`token outputs:surface.connect = </Materials/Material_${material.id}/PreviewSurface.outputs:surface>`
|
|
1128
|
+
);
|
|
691
1129
|
|
|
692
|
-
|
|
693
|
-
`;
|
|
1130
|
+
return materialNode;
|
|
694
1131
|
|
|
695
1132
|
}
|
|
696
1133
|
|
|
697
1134
|
function buildColor( color ) {
|
|
698
1135
|
|
|
699
|
-
return `(${
|
|
1136
|
+
return `(${color.r}, ${color.g}, ${color.b})`;
|
|
700
1137
|
|
|
701
1138
|
}
|
|
702
1139
|
|
|
703
1140
|
function buildColor4( color ) {
|
|
704
1141
|
|
|
705
|
-
return `(${
|
|
1142
|
+
return `(${color.r}, ${color.g}, ${color.b}, 1.0)`;
|
|
706
1143
|
|
|
707
1144
|
}
|
|
708
1145
|
|
|
709
1146
|
function buildVector2( vector ) {
|
|
710
1147
|
|
|
711
|
-
return `(${
|
|
1148
|
+
return `(${vector.x}, ${vector.y})`;
|
|
712
1149
|
|
|
713
1150
|
}
|
|
714
1151
|
|
|
1152
|
+
function buildCamera( camera, usedNames ) {
|
|
715
1153
|
|
|
716
|
-
|
|
1154
|
+
const name = getName( camera, usedNames );
|
|
717
1155
|
|
|
718
|
-
const
|
|
1156
|
+
const transform = buildMatrix( camera.matrix );
|
|
719
1157
|
|
|
720
|
-
|
|
1158
|
+
if ( camera.matrix.determinant() < 0 ) {
|
|
721
1159
|
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
1160
|
+
console.warn(
|
|
1161
|
+
'THREE.USDZExporter: USDZ does not support negative scales',
|
|
1162
|
+
camera
|
|
1163
|
+
);
|
|
725
1164
|
|
|
726
1165
|
}
|
|
727
1166
|
|
|
1167
|
+
const node = new USDNode( name, 'Camera' );
|
|
1168
|
+
node.addProperty( `matrix4d xformOp:transform = ${transform}` );
|
|
1169
|
+
node.addProperty( 'uniform token[] xformOpOrder = ["xformOp:transform"]' );
|
|
1170
|
+
|
|
1171
|
+
const projection = camera.isOrthographicCamera
|
|
1172
|
+
? 'orthographic'
|
|
1173
|
+
: 'perspective';
|
|
1174
|
+
node.addProperty( `token projection = "${projection}"` );
|
|
1175
|
+
|
|
1176
|
+
const clippingRange = `(${camera.near.toPrecision(
|
|
1177
|
+
PRECISION
|
|
1178
|
+
)}, ${camera.far.toPrecision( PRECISION )})`;
|
|
1179
|
+
node.addProperty( `float2 clippingRange = ${clippingRange}` );
|
|
1180
|
+
|
|
1181
|
+
let horizontalAperture;
|
|
728
1182
|
if ( camera.isOrthographicCamera ) {
|
|
729
1183
|
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
1184
|
+
horizontalAperture = (
|
|
1185
|
+
( Math.abs( camera.left ) + Math.abs( camera.right ) ) *
|
|
1186
|
+
10
|
|
1187
|
+
).toPrecision( PRECISION );
|
|
734
1188
|
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
1189
|
+
} else {
|
|
1190
|
+
|
|
1191
|
+
horizontalAperture = camera.getFilmWidth().toPrecision( PRECISION );
|
|
1192
|
+
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
node.addProperty( `float horizontalAperture = ${horizontalAperture}` );
|
|
1196
|
+
|
|
1197
|
+
let verticalAperture;
|
|
1198
|
+
if ( camera.isOrthographicCamera ) {
|
|
1199
|
+
|
|
1200
|
+
verticalAperture = (
|
|
1201
|
+
( Math.abs( camera.top ) + Math.abs( camera.bottom ) ) *
|
|
1202
|
+
10
|
|
1203
|
+
).toPrecision( PRECISION );
|
|
742
1204
|
|
|
743
1205
|
} else {
|
|
744
1206
|
|
|
745
|
-
|
|
746
|
-
{
|
|
747
|
-
matrix4d xformOp:transform = ${ transform }
|
|
748
|
-
uniform token[] xformOpOrder = ["xformOp:transform"]
|
|
749
|
-
|
|
750
|
-
float2 clippingRange = (${ camera.near.toPrecision( PRECISION ) }, ${ camera.far.toPrecision( PRECISION ) })
|
|
751
|
-
float focalLength = ${ camera.getFocalLength().toPrecision( PRECISION ) }
|
|
752
|
-
float focusDistance = ${ camera.focus.toPrecision( PRECISION ) }
|
|
753
|
-
float horizontalAperture = ${ camera.getFilmWidth().toPrecision( PRECISION ) }
|
|
754
|
-
token projection = "perspective"
|
|
755
|
-
float verticalAperture = ${ camera.getFilmHeight().toPrecision( PRECISION ) }
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
`;
|
|
1207
|
+
verticalAperture = camera.getFilmHeight().toPrecision( PRECISION );
|
|
759
1208
|
|
|
760
1209
|
}
|
|
761
1210
|
|
|
1211
|
+
node.addProperty( `float verticalAperture = ${verticalAperture}` );
|
|
1212
|
+
|
|
1213
|
+
if ( camera.isPerspectiveCamera ) {
|
|
1214
|
+
|
|
1215
|
+
const focalLength = camera.getFocalLength().toPrecision( PRECISION );
|
|
1216
|
+
node.addProperty( `float focalLength = ${focalLength}` );
|
|
1217
|
+
|
|
1218
|
+
const focusDistance = camera.focus.toPrecision( PRECISION );
|
|
1219
|
+
node.addProperty( `float focusDistance = ${focusDistance}` );
|
|
1220
|
+
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
return node;
|
|
1224
|
+
|
|
762
1225
|
}
|
|
763
1226
|
|
|
1227
|
+
/**
|
|
1228
|
+
* Export options of `USDZExporter`.
|
|
1229
|
+
*
|
|
1230
|
+
* @typedef {Object} USDZExporter~Options
|
|
1231
|
+
* @property {number} [maxTextureSize=1024] - The maximum texture size that is going to be exported.
|
|
1232
|
+
* @property {boolean} [includeAnchoringProperties=true] - Whether to include anchoring properties or not.
|
|
1233
|
+
* @property {boolean} [onlyVisible=true] - Export only visible 3D objects.
|
|
1234
|
+
* @property {Object} [ar] - If `includeAnchoringProperties` is set to `true`, the anchoring type and alignment
|
|
1235
|
+
* can be configured via `ar.anchoring.type` and `ar.planeAnchoring.alignment`.
|
|
1236
|
+
* @property {boolean} [quickLookCompatible=false] - Whether to make the exported USDZ compatible to QuickLook
|
|
1237
|
+
* which means the asset is modified to accommodate the bugs FB10036297 and FB11442287 (Apple Feedback).
|
|
1238
|
+
**/
|
|
1239
|
+
|
|
1240
|
+
/**
|
|
1241
|
+
* onDone callback of `USDZExporter`.
|
|
1242
|
+
*
|
|
1243
|
+
* @callback USDZExporter~OnDone
|
|
1244
|
+
* @param {ArrayBuffer} result - The generated USDZ.
|
|
1245
|
+
*/
|
|
1246
|
+
|
|
1247
|
+
/**
|
|
1248
|
+
* onError callback of `USDZExporter`.
|
|
1249
|
+
*
|
|
1250
|
+
* @callback USDZExporter~OnError
|
|
1251
|
+
* @param {Error} error - The error object.
|
|
1252
|
+
*/
|
|
1253
|
+
|
|
764
1254
|
export { USDZExporter };
|