@needle-tools/three 0.146.10 → 0.153.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/build/three.cjs +39486 -20286
- package/build/three.js +39471 -20270
- package/build/three.min.js +3 -2
- package/build/three.module.js +6717 -5427
- package/build/three.module.min.js +6 -0
- package/examples/jsm/animation/AnimationClipCreator.js +5 -3
- package/examples/jsm/cameras/CinematicCamera.js +1 -2
- package/examples/jsm/capabilities/WebGPU.js +17 -5
- package/examples/jsm/controls/ArcballControls.js +1828 -1821
- package/examples/jsm/controls/MapControls.js +28 -0
- package/examples/jsm/controls/OrbitControls.js +26 -53
- package/examples/jsm/controls/PointerLockControls.js +70 -65
- package/examples/jsm/controls/TrackballControls.js +18 -4
- package/examples/jsm/controls/TransformControls.js +0 -1
- package/examples/jsm/csm/CSM.js +11 -5
- package/examples/jsm/csm/CSMShader.js +7 -6
- package/examples/jsm/effects/AnaglyphEffect.js +6 -20
- package/examples/jsm/effects/AsciiEffect.js +3 -6
- package/examples/jsm/effects/OutlineEffect.js +1 -15
- package/examples/jsm/effects/ParallaxBarrierEffect.js +3 -0
- package/examples/jsm/exporters/DRACOExporter.js +53 -11
- package/examples/jsm/exporters/EXRExporter.js +3 -9
- package/examples/jsm/exporters/GLTFExporter.js +561 -154
- package/examples/jsm/exporters/KTX2Exporter.js +34 -23
- package/examples/jsm/exporters/MMDExporter.js +1 -1
- package/examples/jsm/exporters/PLYExporter.js +8 -1
- package/examples/jsm/exporters/STLExporter.js +8 -4
- package/examples/jsm/exporters/USDZExporter.js +305 -792
- package/examples/jsm/geometries/ConvexGeometry.js +0 -6
- package/examples/jsm/geometries/ParametricGeometry.js +10 -0
- package/examples/jsm/helpers/OctreeHelper.js +1 -0
- package/examples/jsm/helpers/ViewHelper.js +71 -57
- package/examples/jsm/interactive/HTMLMesh.js +16 -3
- package/examples/jsm/interactive/InteractiveGroup.js +1 -1
- package/examples/{js → jsm}/libs/basis/README.md +4 -4
- package/examples/jsm/libs/draco/draco_decoder.js +34 -0
- package/examples/jsm/libs/draco/draco_decoder.wasm +0 -0
- package/examples/jsm/libs/draco/draco_wasm_wrapper.js +117 -0
- package/examples/jsm/libs/draco/gltf/draco_decoder.js +33 -0
- package/examples/jsm/libs/draco/gltf/draco_decoder.wasm +0 -0
- package/examples/jsm/libs/draco/gltf/draco_wasm_wrapper.js +116 -0
- package/examples/jsm/libs/lil-gui.module.min.js +2 -2
- package/examples/jsm/libs/tween.module.js +803 -0
- package/examples/jsm/lights/IESSpotLight.js +25 -0
- package/examples/jsm/lights/LightProbeGenerator.js +11 -9
- package/examples/jsm/lines/LineSegments2.js +16 -10
- package/examples/jsm/loaders/3DMLoader.js +8 -5
- package/examples/jsm/loaders/3MFLoader.js +12 -11
- package/examples/jsm/loaders/AMFLoader.js +2 -3
- package/examples/jsm/loaders/BVHLoader.js +2 -2
- package/examples/jsm/loaders/ColladaLoader.js +15 -16
- package/examples/jsm/loaders/DRACOLoader.js +69 -18
- package/examples/jsm/loaders/EXRLoader.js +23 -24
- package/examples/jsm/loaders/FBXLoader.js +34 -50
- package/examples/jsm/loaders/GCodeLoader.js +1 -2
- package/examples/jsm/loaders/GLTFLoader.js +417 -895
- package/examples/jsm/loaders/GLTFLoaderAnimationPointer.js +684 -0
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +4 -4
- package/examples/jsm/loaders/IESLoader.js +337 -0
- package/examples/jsm/loaders/KMZLoader.js +4 -4
- package/examples/jsm/loaders/KTX2Loader.js +145 -69
- package/examples/jsm/loaders/LDrawLoader.js +20 -18
- package/examples/jsm/loaders/LWOLoader.js +12 -29
- package/examples/jsm/loaders/LottieLoader.js +3 -1
- package/examples/jsm/loaders/MMDLoader.js +49 -18
- package/examples/jsm/loaders/MTLLoader.js +2 -2
- package/examples/jsm/loaders/MaterialXLoader.js +9 -3
- package/examples/jsm/loaders/NRRDLoader.js +33 -5
- package/examples/jsm/loaders/OBJLoader.js +1 -1
- package/examples/jsm/loaders/PCDLoader.js +26 -12
- package/examples/jsm/loaders/PDBLoader.js +7 -2
- package/examples/jsm/loaders/PLYLoader.js +254 -109
- package/examples/jsm/loaders/RGBELoader.js +3 -3
- package/examples/jsm/loaders/STLLoader.js +9 -5
- package/examples/jsm/loaders/SVGLoader.js +36 -27
- package/examples/jsm/loaders/TTFLoader.js +1 -8
- package/examples/jsm/loaders/TiltLoader.js +13 -7
- package/examples/jsm/loaders/USDZLoader.js +6 -6
- package/examples/jsm/loaders/VOXLoader.js +8 -2
- package/examples/jsm/loaders/VRMLLoader.js +44 -16
- package/examples/jsm/loaders/VTKLoader.js +19 -10
- package/examples/jsm/loaders/XYZLoader.js +9 -3
- package/examples/jsm/loaders/lwo/IFFParser.js +19 -19
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -3
- package/examples/jsm/math/ConvexHull.js +3 -3
- package/examples/jsm/math/Lut.js +5 -4
- package/examples/jsm/math/MeshSurfaceSampler.js +7 -9
- package/examples/jsm/math/Octree.js +1 -1
- package/examples/jsm/misc/ConvexObjectBreaker.js +2 -8
- package/examples/jsm/misc/GPUComputationRenderer.js +6 -5
- package/examples/jsm/misc/MD2Character.js +2 -2
- package/examples/jsm/misc/MD2CharacterComplex.js +2 -2
- package/examples/jsm/misc/ProgressiveLightMap.js +12 -10
- package/examples/jsm/misc/RollerCoaster.js +7 -1
- package/examples/jsm/misc/Volume.js +20 -5
- package/examples/jsm/misc/VolumeSlice.js +3 -1
- package/examples/jsm/modifiers/CurveModifier.js +1 -0
- package/examples/jsm/modifiers/TessellateModifier.js +19 -19
- package/examples/jsm/nodes/Nodes.js +144 -335
- package/examples/jsm/nodes/accessors/BitangentNode.js +43 -16
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +86 -0
- package/examples/jsm/nodes/accessors/BufferNode.js +6 -0
- package/examples/jsm/nodes/accessors/CameraNode.js +12 -2
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +27 -33
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +58 -0
- package/examples/jsm/nodes/accessors/InstanceNode.js +41 -26
- package/examples/jsm/nodes/accessors/MaterialNode.js +155 -38
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +16 -0
- package/examples/jsm/nodes/accessors/ModelNode.js +11 -0
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +13 -14
- package/examples/jsm/nodes/accessors/NormalNode.js +35 -19
- package/examples/jsm/nodes/accessors/Object3DNode.js +32 -12
- package/examples/jsm/nodes/accessors/PointUVNode.js +6 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +38 -23
- package/examples/jsm/nodes/accessors/ReferenceNode.js +21 -14
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +11 -7
- package/examples/jsm/nodes/accessors/SkinningNode.js +43 -40
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +6 -0
- package/examples/jsm/nodes/accessors/TangentNode.js +28 -20
- package/examples/jsm/nodes/accessors/TextureNode.js +80 -12
- package/examples/jsm/nodes/accessors/UVNode.js +6 -0
- package/examples/jsm/nodes/accessors/UserDataNode.js +6 -0
- package/examples/jsm/nodes/code/CodeNode.js +75 -0
- package/examples/jsm/nodes/code/ExpressionNode.js +37 -0
- package/examples/jsm/nodes/{core → code}/FunctionCallNode.js +15 -1
- package/examples/jsm/nodes/{core → code}/FunctionNode.js +8 -7
- package/examples/jsm/nodes/code/ScriptableNode.js +488 -0
- package/examples/jsm/nodes/code/ScriptableValueNode.js +167 -0
- package/examples/jsm/nodes/core/ArrayUniformNode.js +3 -0
- package/examples/jsm/nodes/core/AttributeNode.js +17 -9
- package/examples/jsm/nodes/core/BypassNode.js +9 -2
- package/examples/jsm/nodes/core/CacheNode.js +46 -0
- package/examples/jsm/nodes/core/ConstNode.js +3 -0
- package/examples/jsm/nodes/core/ContextNode.js +8 -1
- package/examples/jsm/nodes/core/InputNode.js +26 -5
- package/examples/jsm/nodes/core/InstanceIndexNode.js +26 -2
- package/examples/jsm/nodes/core/LightingModel.js +16 -0
- package/examples/jsm/nodes/core/Node.js +129 -35
- package/examples/jsm/nodes/core/NodeAttribute.js +2 -1
- package/examples/jsm/nodes/core/NodeBuilder.js +271 -121
- package/examples/jsm/nodes/core/NodeCache.js +26 -0
- package/examples/jsm/nodes/core/NodeFrame.js +56 -5
- package/examples/jsm/nodes/core/NodeUtils.js +115 -28
- package/examples/jsm/nodes/core/PropertyNode.js +19 -2
- package/examples/jsm/nodes/core/StackNode.js +99 -0
- package/examples/jsm/nodes/core/TempNode.js +11 -3
- package/examples/jsm/nodes/core/UniformNode.js +16 -1
- package/examples/jsm/nodes/core/VarNode.js +21 -29
- package/examples/jsm/nodes/core/VaryingNode.js +15 -2
- package/examples/jsm/nodes/core/constants.js +6 -0
- package/examples/jsm/nodes/display/BlendModeNode.js +25 -11
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +30 -14
- package/examples/jsm/nodes/display/ColorSpaceNode.js +39 -27
- package/examples/jsm/nodes/display/FrontFacingNode.js +7 -1
- package/examples/jsm/nodes/display/NormalMapNode.js +31 -18
- package/examples/jsm/nodes/display/PosterizeNode.js +10 -3
- package/examples/jsm/nodes/display/ToneMappingNode.js +101 -11
- package/examples/jsm/nodes/display/ViewportNode.js +27 -18
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +30 -0
- package/examples/jsm/nodes/display/ViewportTextureNode.js +67 -0
- package/examples/jsm/nodes/fog/FogExp2Node.js +35 -0
- package/examples/jsm/nodes/fog/FogNode.js +12 -6
- package/examples/jsm/nodes/fog/FogRangeNode.js +12 -5
- package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +30 -0
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -13
- package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +8 -6
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +4 -4
- package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +3 -3
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +7 -5
- package/examples/jsm/nodes/functions/PhongLightingModel.js +28 -0
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +35 -36
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +4 -3
- package/examples/jsm/nodes/functions/material/getRoughness.js +4 -4
- package/examples/jsm/nodes/geometry/RangeNode.js +50 -55
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +9 -2
- package/examples/jsm/nodes/lighting/AONode.js +5 -3
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +27 -0
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +114 -5
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +43 -0
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +121 -35
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +15 -10
- package/examples/jsm/nodes/lighting/IESSpotLightNode.js +39 -0
- package/examples/jsm/nodes/lighting/LightNode.js +57 -0
- package/examples/jsm/nodes/lighting/LightUtils.js +17 -0
- package/examples/jsm/nodes/lighting/LightingContextNode.js +30 -8
- package/examples/jsm/nodes/lighting/LightingNode.js +3 -1
- package/examples/jsm/nodes/lighting/LightsNode.js +18 -10
- package/examples/jsm/nodes/lighting/PointLightNode.js +71 -0
- package/examples/jsm/nodes/lighting/SpotLightNode.js +92 -0
- package/examples/jsm/nodes/loaders/NodeLoader.js +5 -4
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +4 -20
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +6 -9
- package/examples/jsm/nodes/materials/Materials.js +11 -55
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +5 -11
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +48 -0
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +74 -0
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +6 -6
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +21 -96
- package/examples/jsm/nodes/materials/NodeMaterial.js +284 -62
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +7 -1
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +29 -25
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +31 -22
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +1 -1
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +2 -1
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +2 -1
- package/examples/jsm/nodes/math/CondNode.js +43 -17
- package/examples/jsm/nodes/math/MathNode.js +178 -73
- package/examples/jsm/nodes/math/OperatorNode.js +52 -2
- package/examples/jsm/nodes/procedural/CheckerNode.js +14 -6
- package/examples/jsm/nodes/shadernode/ShaderNode.js +186 -63
- package/examples/jsm/nodes/utils/ArrayElementNode.js +4 -2
- package/examples/jsm/nodes/utils/ConvertNode.js +19 -1
- package/examples/jsm/nodes/utils/DiscardNode.js +26 -0
- package/examples/jsm/nodes/utils/EquirectUVNode.js +10 -4
- package/examples/jsm/nodes/utils/JoinNode.js +4 -1
- package/examples/jsm/nodes/utils/LoopNode.js +186 -0
- package/examples/jsm/nodes/utils/MatcapUVNode.js +11 -4
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +18 -5
- package/examples/jsm/nodes/utils/OscNode.js +21 -14
- package/examples/jsm/nodes/utils/PackingNode.js +55 -0
- package/examples/jsm/nodes/utils/RemapNode.js +13 -5
- package/examples/jsm/nodes/utils/RotateUVNode.js +18 -7
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +37 -0
- package/examples/jsm/nodes/utils/SplitNode.js +7 -5
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +15 -30
- package/examples/jsm/nodes/utils/TimerNode.js +16 -6
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +21 -10
- package/examples/jsm/objects/GroundProjectedSkybox.js +172 -0
- package/examples/jsm/objects/Lensflare.js +3 -4
- package/examples/jsm/objects/MarchingCubes.js +5 -1
- package/examples/jsm/objects/Reflector.js +7 -4
- package/examples/jsm/objects/Refractor.js +4 -4
- package/examples/jsm/objects/ShadowMesh.js +3 -3
- package/examples/jsm/objects/Water.js +2 -1
- package/examples/jsm/physics/AmmoPhysics.js +27 -28
- package/examples/jsm/physics/RapierPhysics.js +199 -0
- package/examples/jsm/postprocessing/AfterimagePass.js +3 -2
- package/examples/jsm/postprocessing/BloomPass.js +7 -4
- package/examples/jsm/postprocessing/BokehPass.js +3 -8
- package/examples/jsm/postprocessing/DotScreenPass.js +1 -2
- package/examples/jsm/postprocessing/EffectComposer.js +5 -95
- package/examples/jsm/postprocessing/FilmPass.js +1 -2
- package/examples/jsm/postprocessing/GlitchPass.js +0 -2
- package/examples/jsm/postprocessing/HalftonePass.js +0 -6
- package/examples/jsm/postprocessing/OutlinePass.js +7 -7
- package/examples/jsm/postprocessing/OutputPass.js +72 -0
- package/examples/jsm/postprocessing/Pass.js +2 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +4 -3
- package/examples/jsm/postprocessing/SAOPass.js +4 -26
- package/examples/jsm/postprocessing/SMAAPass.js +5 -8
- package/examples/jsm/postprocessing/SSAARenderPass.js +15 -6
- package/examples/jsm/postprocessing/SSAOPass.js +4 -14
- package/examples/jsm/postprocessing/SSRPass.js +3 -7
- package/examples/jsm/postprocessing/SavePass.js +2 -3
- package/examples/jsm/postprocessing/ShaderPass.js +1 -0
- package/examples/jsm/postprocessing/TAARenderPass.js +3 -2
- package/examples/jsm/postprocessing/TexturePass.js +0 -2
- package/examples/jsm/postprocessing/UnrealBloomPass.js +4 -11
- package/examples/jsm/renderers/CSS2DRenderer.js +6 -1
- package/examples/jsm/renderers/CSS3DRenderer.js +27 -5
- package/examples/jsm/renderers/{webgpu/WebGPUAnimation.js → common/Animation.js} +4 -4
- package/examples/jsm/renderers/common/Attributes.js +75 -0
- package/examples/jsm/renderers/common/Backend.js +160 -0
- package/examples/jsm/renderers/common/Background.js +133 -0
- package/examples/jsm/renderers/common/Binding.js +11 -0
- package/examples/jsm/renderers/common/Bindings.js +169 -0
- package/examples/jsm/renderers/common/Buffer.js +38 -0
- package/examples/jsm/renderers/{webgpu/WebGPUBufferUtils.js → common/BufferUtils.js} +2 -2
- package/examples/jsm/renderers/common/ChainMap.js +89 -0
- package/examples/jsm/renderers/common/ComputePipeline.js +17 -0
- package/examples/jsm/renderers/common/Constants.js +14 -0
- package/examples/jsm/renderers/common/CubeRenderTarget.js +65 -0
- package/examples/jsm/renderers/common/DataMap.js +54 -0
- package/examples/jsm/renderers/common/Geometries.js +215 -0
- package/examples/jsm/renderers/{webgpu/WebGPUInfo.js → common/Info.js} +2 -3
- package/examples/jsm/renderers/common/Pipeline.js +13 -0
- package/examples/jsm/renderers/common/Pipelines.js +309 -0
- package/examples/jsm/renderers/common/ProgrammableStage.js +18 -0
- package/examples/jsm/renderers/common/RenderContext.js +37 -0
- package/examples/jsm/renderers/common/RenderContexts.js +38 -0
- package/examples/jsm/renderers/{webgpu/WebGPURenderLists.js → common/RenderList.js} +26 -47
- package/examples/jsm/renderers/common/RenderLists.js +38 -0
- package/examples/jsm/renderers/common/RenderObject.js +95 -0
- package/examples/jsm/renderers/common/RenderObjects.js +92 -0
- package/examples/jsm/renderers/common/RenderPipeline.js +16 -0
- package/examples/jsm/renderers/common/RenderTarget.js +15 -0
- package/examples/jsm/renderers/common/Renderer.js +822 -0
- package/examples/jsm/renderers/common/SampledTexture.js +80 -0
- package/examples/jsm/renderers/common/Sampler.js +18 -0
- package/examples/jsm/renderers/common/StorageBuffer.js +17 -0
- package/examples/jsm/renderers/common/Textures.js +206 -0
- package/examples/jsm/renderers/{webgpu/WebGPUUniform.js → common/Uniform.js} +13 -9
- package/examples/jsm/renderers/common/UniformBuffer.js +15 -0
- package/examples/jsm/renderers/{webgpu/WebGPUUniformsGroup.js → common/UniformsGroup.js} +13 -13
- package/examples/jsm/renderers/common/nodes/NodeRender.js +302 -0
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeSampledTexture.js → common/nodes/NodeSampledTexture.js} +4 -4
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeSampler.js → common/nodes/NodeSampler.js} +3 -3
- package/examples/jsm/renderers/{webgpu/nodes/WebGPUNodeUniform.js → common/nodes/NodeUniform.js} +1 -1
- package/examples/jsm/renderers/common/nodes/Nodes.js +319 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +35 -31
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +765 -0
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +15 -987
- package/examples/jsm/renderers/webgpu/nodes/{WebGPUNodeBuilder.js → WGSLNodeBuilder.js} +117 -90
- package/examples/jsm/{nodes/parsers → renderers/webgpu/nodes}/WGSLNodeFunction.js +2 -2
- package/examples/jsm/{nodes/parsers → renderers/webgpu/nodes}/WGSLNodeParser.js +1 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +251 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +145 -0
- package/examples/jsm/renderers/webgpu/{constants.js → utils/WebGPUConstants.js} +73 -12
- package/examples/jsm/renderers/webgpu/{WebGPURenderPipeline.js → utils/WebGPUPipelineUtils.js} +135 -285
- package/examples/jsm/renderers/webgpu/{WebGPUTextureUtils.js → utils/WebGPUTextureMipmapUtils.js} +5 -25
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +855 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +88 -0
- package/examples/jsm/shaders/BleachBypassShader.js +2 -0
- package/examples/jsm/shaders/BokehShader2.js +3 -0
- package/examples/jsm/shaders/ColorifyShader.js +2 -0
- package/examples/jsm/shaders/ConvolutionShader.js +2 -0
- package/examples/jsm/shaders/CopyShader.js +2 -0
- package/examples/jsm/shaders/DotScreenShader.js +2 -0
- package/examples/jsm/shaders/ExposureShader.js +44 -0
- package/examples/jsm/shaders/FilmShader.js +2 -0
- package/examples/jsm/shaders/GammaCorrectionShader.js +2 -0
- package/examples/jsm/shaders/HorizontalBlurShader.js +2 -0
- package/examples/jsm/shaders/MMDToonShader.js +15 -4
- package/examples/jsm/shaders/OutputShader.js +61 -0
- package/examples/jsm/shaders/RGBShiftShader.js +4 -2
- package/examples/jsm/shaders/SepiaShader.js +2 -0
- package/examples/jsm/shaders/ToonShader.js +13 -5
- package/examples/jsm/shaders/VelocityShader.js +1 -1
- package/examples/jsm/shaders/VerticalBlurShader.js +2 -0
- package/examples/jsm/shaders/VignetteShader.js +2 -0
- package/examples/jsm/shaders/WaterRefractionShader.js +5 -2
- package/examples/jsm/utils/BufferGeometryUtils.js +54 -36
- package/examples/jsm/utils/LDrawUtils.js +4 -4
- package/examples/jsm/utils/PackedPhongMaterial.js +5 -78
- package/examples/jsm/utils/SceneUtils.js +8 -4
- package/examples/jsm/utils/SkeletonUtils.js +27 -210
- package/examples/jsm/utils/TextureUtils.js +41 -40
- package/examples/jsm/webxr/VRButton.js +1 -2
- package/examples/jsm/webxr/XRButton.js +198 -0
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +1 -0
- package/examples/jsm/webxr/XRPlanes.js +100 -0
- package/package.json +34 -87
- package/src/Three.Legacy.js +19 -110
- package/src/Three.js +4 -3
- package/src/animation/AnimationUtils.js +13 -1
- package/src/audio/Audio.js +7 -2
- package/src/audio/PositionalAudio.js +8 -0
- package/src/cameras/Camera.js +5 -0
- package/src/cameras/CubeCamera.js +76 -13
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/constants.js +22 -2
- package/src/core/BufferAttribute.js +150 -9
- package/src/core/BufferGeometry.js +4 -10
- package/src/core/GLBufferAttribute.js +2 -0
- package/src/core/InterleavedBufferAttribute.js +5 -5
- package/src/core/Object3D.js +37 -8
- package/src/extras/DataUtils.js +7 -1
- package/src/extras/ImageUtils.js +2 -2
- package/src/extras/PMREMGenerator.js +5 -5
- package/src/extras/core/Curve.js +1 -1
- package/src/extras/curves/LineCurve.js +6 -4
- package/src/extras/curves/LineCurve3.js +13 -0
- package/src/geometries/BoxGeometry.js +10 -0
- package/src/geometries/CircleGeometry.js +11 -1
- package/src/geometries/ConeGeometry.js +1 -1
- package/src/geometries/CylinderGeometry.js +11 -1
- package/src/geometries/EdgesGeometry.js +10 -0
- package/src/geometries/ExtrudeGeometry.js +11 -1
- package/src/geometries/LatheGeometry.js +10 -0
- package/src/geometries/PlaneGeometry.js +10 -0
- package/src/geometries/PolyhedronGeometry.js +11 -1
- package/src/geometries/RingGeometry.js +11 -1
- package/src/geometries/ShapeGeometry.js +11 -1
- package/src/geometries/SphereGeometry.js +12 -2
- package/src/geometries/TorusGeometry.js +11 -1
- package/src/geometries/TorusKnotGeometry.js +10 -0
- package/src/geometries/TubeGeometry.js +10 -0
- package/src/geometries/WireframeGeometry.js +10 -0
- package/src/helpers/Box3Helper.js +1 -2
- package/src/lights/DirectionalLight.js +1 -1
- package/src/lights/HemisphereLight.js +1 -1
- package/src/lights/SpotLight.js +1 -1
- package/src/loaders/AudioLoader.js +14 -8
- package/src/loaders/CubeTextureLoader.js +2 -0
- package/src/loaders/DataTextureLoader.js +5 -1
- package/src/loaders/MaterialLoader.js +8 -0
- package/src/loaders/ObjectLoader.js +10 -2
- package/src/materials/LineBasicMaterial.js +4 -0
- package/src/materials/Material.js +16 -4
- package/src/materials/MeshDistanceMaterial.js +0 -9
- package/src/materials/MeshPhysicalMaterial.js +32 -6
- package/src/materials/ShaderMaterial.js +6 -1
- package/src/math/Box2.js +3 -2
- package/src/math/Box3.js +49 -64
- package/src/math/Color.js +88 -66
- package/src/math/ColorManagement.js +75 -16
- package/src/math/Euler.js +2 -11
- package/src/math/Frustum.js +29 -5
- package/src/math/MathUtils.js +43 -1
- package/src/math/Matrix3.js +26 -6
- package/src/math/Matrix4.js +74 -19
- package/src/math/Plane.js +2 -2
- package/src/math/Quaternion.js +6 -0
- package/src/math/Ray.js +7 -7
- package/src/math/Triangle.js +37 -7
- package/src/math/Vector2.js +16 -0
- package/src/math/Vector3.js +10 -0
- package/src/math/interpolants/CubicInterpolant.js +1 -2
- package/src/objects/InstancedMesh.js +82 -1
- package/src/objects/Mesh.js +108 -76
- package/src/objects/Skeleton.js +1 -1
- package/src/objects/SkinnedMesh.js +123 -8
- package/src/objects/Sprite.js +1 -1
- package/src/renderers/WebGLCubeRenderTarget.js +12 -3
- package/src/renderers/WebGLMultipleRenderTargets.js +4 -2
- package/src/renderers/WebGLRenderTarget.js +14 -2
- package/src/renderers/WebGLRenderer.js +1433 -1236
- package/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +0 -271
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +5 -5
- package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js +2 -10
- package/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js +5 -5
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +32 -0
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +26 -3
- package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +10 -2
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +11 -11
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +39 -13
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +306 -10
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -10
- package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js +10 -2
- package/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +32 -10
- package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +5 -13
- package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +7 -7
- package/src/renderers/shaders/ShaderChunk/output_fragment.glsl.js +1 -2
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +11 -5
- package/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +4 -11
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +39 -34
- package/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +5 -5
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +101 -16
- package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +113 -1
- package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +134 -6
- package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +116 -1
- package/src/renderers/shaders/ShaderChunk.js +0 -6
- package/src/renderers/shaders/ShaderLib/background.glsl.js +0 -8
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +5 -0
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -4
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +0 -3
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +3 -3
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -3
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +16 -12
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -3
- package/src/renderers/shaders/ShaderLib/points.glsl.js +13 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +5 -0
- package/src/renderers/shaders/ShaderLib.js +18 -4
- package/src/renderers/shaders/UniformsLib.js +27 -15
- package/src/renderers/shaders/UniformsUtils.js +12 -3
- package/src/renderers/webgl/WebGLBackground.js +23 -12
- package/src/renderers/webgl/WebGLBindingStates.js +13 -5
- package/src/renderers/webgl/WebGLCapabilities.js +1 -2
- package/src/renderers/webgl/WebGLClipping.js +7 -3
- package/src/renderers/webgl/WebGLGeometries.js +12 -0
- package/src/renderers/webgl/WebGLInfo.js +0 -1
- package/src/renderers/webgl/WebGLLights.js +2 -2
- package/src/renderers/webgl/WebGLMaterials.js +123 -234
- package/src/renderers/webgl/WebGLMorphtargets.js +1 -1
- package/src/renderers/webgl/WebGLProgram.js +130 -48
- package/src/renderers/webgl/WebGLPrograms.js +210 -130
- package/src/renderers/webgl/WebGLRenderStates.js +2 -2
- package/src/renderers/webgl/WebGLShadowMap.js +40 -27
- package/src/renderers/webgl/WebGLState.js +23 -9
- package/src/renderers/webgl/WebGLTextures.js +39 -19
- package/src/renderers/webgl/WebGLUniformsGroups.js +74 -33
- package/src/renderers/webgl/WebGLUtils.js +41 -29
- package/src/renderers/webxr/WebXRController.js +3 -0
- package/src/renderers/webxr/WebXRManager.js +85 -141
- package/src/scenes/Scene.js +4 -6
- package/src/textures/CompressedTexture.js +2 -2
- package/src/textures/CubeTexture.js +2 -2
- package/src/textures/DataTexture.js +2 -2
- package/src/textures/DepthTexture.js +22 -0
- package/src/textures/FramebufferTexture.js +1 -3
- package/src/textures/Source.js +4 -0
- package/src/textures/Texture.js +43 -13
- package/src/utils.js +13 -1
- package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff +0 -0
- package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff2 +0 -0
- package/examples/fonts/open-sans/open-sans.css +0 -9
- package/examples/fonts/tabler-icons/fonts/tabler-icons.eot +0 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.svg +0 -3966
- package/examples/fonts/tabler-icons/fonts/tabler-icons.ttf +0 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.woff +0 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.woff2 +0 -0
- package/examples/fonts/tabler-icons/tabler-icons.min.css +0 -4
- package/examples/js/animation/AnimationClipCreator.js +0 -89
- package/examples/js/animation/CCDIKSolver.js +0 -416
- package/examples/js/animation/MMDAnimationHelper.js +0 -1046
- package/examples/js/animation/MMDPhysics.js +0 -1174
- package/examples/js/cameras/CinematicCamera.js +0 -168
- package/examples/js/controls/ArcballControls.js +0 -2770
- package/examples/js/controls/DragControls.js +0 -205
- package/examples/js/controls/FirstPersonControls.js +0 -312
- package/examples/js/controls/FlyControls.js +0 -321
- package/examples/js/controls/OrbitControls.js +0 -1065
- package/examples/js/controls/PointerLockControls.js +0 -144
- package/examples/js/controls/TrackballControls.js +0 -729
- package/examples/js/controls/TransformControls.js +0 -1301
- package/examples/js/csm/CSM.js +0 -347
- package/examples/js/csm/CSMFrustum.js +0 -127
- package/examples/js/csm/CSMHelper.js +0 -165
- package/examples/js/csm/CSMShader.js +0 -253
- package/examples/js/curves/CurveExtras.js +0 -348
- package/examples/js/curves/NURBSCurve.js +0 -63
- package/examples/js/curves/NURBSSurface.js +0 -48
- package/examples/js/curves/NURBSUtils.js +0 -439
- package/examples/js/effects/AnaglyphEffect.js +0 -86
- package/examples/js/effects/AsciiEffect.js +0 -260
- package/examples/js/effects/OutlineEffect.js +0 -450
- package/examples/js/effects/ParallaxBarrierEffect.js +0 -62
- package/examples/js/effects/PeppersGhostEffect.js +0 -139
- package/examples/js/effects/StereoEffect.js +0 -46
- package/examples/js/environments/DebugEnvironment.js +0 -53
- package/examples/js/environments/RoomEnvironment.js +0 -124
- package/examples/js/exporters/ColladaExporter.js +0 -487
- package/examples/js/exporters/DRACOExporter.js +0 -212
- package/examples/js/exporters/EXRExporter.js +0 -455
- package/examples/js/exporters/GLTFExporter.js +0 -2425
- package/examples/js/exporters/MMDExporter.js +0 -187
- package/examples/js/exporters/OBJExporter.js +0 -260
- package/examples/js/exporters/PLYExporter.js +0 -427
- package/examples/js/exporters/STLExporter.js +0 -188
- package/examples/js/exporters/USDZExporter.js +0 -608
- package/examples/js/geometries/BoxLineGeometry.js +0 -59
- package/examples/js/geometries/ConvexGeometry.js +0 -53
- package/examples/js/geometries/DecalGeometry.js +0 -324
- package/examples/js/geometries/LightningStrike.js +0 -861
- package/examples/js/geometries/ParametricGeometries.js +0 -216
- package/examples/js/geometries/ParametricGeometry.js +0 -121
- package/examples/js/geometries/RoundedBoxGeometry.js +0 -142
- package/examples/js/geometries/TeapotGeometry.js +0 -335
- package/examples/js/geometries/TextGeometry.js +0 -53
- package/examples/js/helpers/LightProbeHelper.js +0 -48
- package/examples/js/helpers/OctreeHelper.js +0 -76
- package/examples/js/helpers/PositionalAudioHelper.js +0 -91
- package/examples/js/helpers/RectAreaLightHelper.js +0 -73
- package/examples/js/helpers/VertexNormalsHelper.js +0 -74
- package/examples/js/helpers/VertexTangentsHelper.js +0 -68
- package/examples/js/helpers/ViewHelper.js +0 -281
- package/examples/js/interactive/HTMLMesh.js +0 -497
- package/examples/js/interactive/InteractiveGroup.js +0 -95
- package/examples/js/interactive/SelectionBox.js +0 -195
- package/examples/js/interactive/SelectionHelper.js +0 -83
- package/examples/js/libs/chevrotain.min.js +0 -3
- package/examples/js/libs/draco/draco_decoder.js +0 -52
- package/examples/js/libs/draco/draco_decoder.wasm +0 -0
- package/examples/js/libs/draco/draco_wasm_wrapper.js +0 -104
- package/examples/js/libs/draco/gltf/draco_decoder.js +0 -48
- package/examples/js/libs/draco/gltf/draco_decoder.wasm +0 -0
- package/examples/js/libs/draco/gltf/draco_wasm_wrapper.js +0 -104
- package/examples/js/libs/fflate.min.js +0 -7
- package/examples/js/libs/ktx-parse.umd.js +0 -1
- package/examples/js/libs/meshopt_decoder.js +0 -188
- package/examples/js/libs/opentype.min.js +0 -1
- package/examples/js/libs/stats.min.js +0 -5
- package/examples/js/lights/LightProbeGenerator.js +0 -221
- package/examples/js/lights/RectAreaLightUniformsLib.js +0 -60
- package/examples/js/lines/Line2.js +0 -19
- package/examples/js/lines/LineGeometry.js +0 -69
- package/examples/js/lines/LineMaterial.js +0 -635
- package/examples/js/lines/LineSegments2.js +0 -311
- package/examples/js/lines/LineSegmentsGeometry.js +0 -198
- package/examples/js/lines/Wireframe.js +0 -47
- package/examples/js/lines/WireframeGeometry2.js +0 -20
- package/examples/js/loaders/3DMLoader.js +0 -1273
- package/examples/js/loaders/3MFLoader.js +0 -1306
- package/examples/js/loaders/AMFLoader.js +0 -504
- package/examples/js/loaders/BVHLoader.js +0 -395
- package/examples/js/loaders/BasisTextureLoader.js +0 -706
- package/examples/js/loaders/ColladaLoader.js +0 -3663
- package/examples/js/loaders/DDSLoader.js +0 -244
- package/examples/js/loaders/DRACOLoader.js +0 -511
- package/examples/js/loaders/EXRLoader.js +0 -2039
- package/examples/js/loaders/FBXLoader.js +0 -3680
- package/examples/js/loaders/FontLoader.js +0 -160
- package/examples/js/loaders/GCodeLoader.js +0 -255
- package/examples/js/loaders/GLTFLoader.js +0 -4108
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -87
- package/examples/js/loaders/KMZLoader.js +0 -121
- package/examples/js/loaders/KTXLoader.js +0 -159
- package/examples/js/loaders/LDrawLoader.js +0 -2263
- package/examples/js/loaders/LUT3dlLoader.js +0 -135
- package/examples/js/loaders/LUTCubeLoader.js +0 -132
- package/examples/js/loaders/LWOLoader.js +0 -901
- package/examples/js/loaders/LogLuvLoader.js +0 -715
- package/examples/js/loaders/LottieLoader.js +0 -62
- package/examples/js/loaders/MD2Loader.js +0 -248
- package/examples/js/loaders/MDDLoader.js +0 -91
- package/examples/js/loaders/MMDLoader.js +0 -1915
- package/examples/js/loaders/MTLLoader.js +0 -472
- package/examples/js/loaders/MaterialXLoader.js +0 -392
- package/examples/js/loaders/NRRDLoader.js +0 -609
- package/examples/js/loaders/OBJLoader.js +0 -789
- package/examples/js/loaders/PCDLoader.js +0 -413
- package/examples/js/loaders/PDBLoader.js +0 -317
- package/examples/js/loaders/PLYLoader.js +0 -532
- package/examples/js/loaders/PRWMLoader.js +0 -249
- package/examples/js/loaders/PVRLoader.js +0 -218
- package/examples/js/loaders/RGBELoader.js +0 -442
- package/examples/js/loaders/RGBMLoader.js +0 -1354
- package/examples/js/loaders/STLLoader.js +0 -364
- package/examples/js/loaders/SVGLoader.js +0 -2783
- package/examples/js/loaders/TDSLoader.js +0 -992
- package/examples/js/loaders/TGALoader.js +0 -484
- package/examples/js/loaders/TIFFLoader.js +0 -30
- package/examples/js/loaders/TTFLoader.js +0 -203
- package/examples/js/loaders/TiltLoader.js +0 -459
- package/examples/js/loaders/VOXLoader.js +0 -240
- package/examples/js/loaders/VRMLLoader.js +0 -3140
- package/examples/js/loaders/VTKLoader.js +0 -1078
- package/examples/js/loaders/XYZLoader.js +0 -89
- package/examples/js/loaders/lwo/IFFParser.js +0 -1067
- package/examples/js/loaders/lwo/LWO2Parser.js +0 -397
- package/examples/js/loaders/lwo/LWO3Parser.js +0 -360
- package/examples/js/materials/MeshGouraudMaterial.js +0 -387
- package/examples/js/math/Capsule.js +0 -103
- package/examples/js/math/ColorConverter.js +0 -33
- package/examples/js/math/ConvexHull.js +0 -1154
- package/examples/js/math/ImprovedNoise.js +0 -66
- package/examples/js/math/Lut.js +0 -164
- package/examples/js/math/MeshSurfaceSampler.js +0 -171
- package/examples/js/math/OBB.js +0 -382
- package/examples/js/math/Octree.js +0 -410
- package/examples/js/math/SimplexNoise.js +0 -445
- package/examples/js/misc/ConvexObjectBreaker.js +0 -474
- package/examples/js/misc/GPUComputationRenderer.js +0 -393
- package/examples/js/misc/Gyroscope.js +0 -56
- package/examples/js/misc/MD2Character.js +0 -235
- package/examples/js/misc/MD2CharacterComplex.js +0 -513
- package/examples/js/misc/MorphAnimMesh.js +0 -63
- package/examples/js/misc/MorphBlendMesh.js +0 -265
- package/examples/js/misc/ProgressiveLightMap.js +0 -335
- package/examples/js/misc/RollerCoaster.js +0 -430
- package/examples/js/misc/TubePainter.js +0 -167
- package/examples/js/misc/Volume.js +0 -437
- package/examples/js/misc/VolumeSlice.js +0 -214
- package/examples/js/modifiers/CurveModifier.js +0 -309
- package/examples/js/modifiers/EdgeSplitModifier.js +0 -228
- package/examples/js/modifiers/SimplifyModifier.js +0 -465
- package/examples/js/modifiers/TessellateModifier.js +0 -276
- package/examples/js/objects/GroundProjectedEnv.js +0 -181
- package/examples/js/objects/Lensflare.js +0 -356
- package/examples/js/objects/LightningStorm.js +0 -206
- package/examples/js/objects/MarchingCubes.js +0 -759
- package/examples/js/objects/Reflector.js +0 -216
- package/examples/js/objects/ReflectorForSSRPass.js +0 -315
- package/examples/js/objects/Refractor.js +0 -283
- package/examples/js/objects/ShadowMesh.js +0 -59
- package/examples/js/objects/Sky.js +0 -218
- package/examples/js/objects/Water.js +0 -292
- package/examples/js/objects/Water2.js +0 -307
- package/examples/js/physics/AmmoPhysics.js +0 -259
- package/examples/js/physics/OimoPhysics.js +0 -217
- package/examples/js/postprocessing/AdaptiveToneMappingPass.js +0 -335
- package/examples/js/postprocessing/AfterimagePass.js +0 -77
- package/examples/js/postprocessing/BloomPass.js +0 -135
- package/examples/js/postprocessing/BokehPass.js +0 -120
- package/examples/js/postprocessing/ClearPass.js +0 -39
- package/examples/js/postprocessing/CubeTexturePass.js +0 -60
- package/examples/js/postprocessing/DotScreenPass.js +0 -51
- package/examples/js/postprocessing/EffectComposer.js +0 -272
- package/examples/js/postprocessing/FilmPass.js +0 -52
- package/examples/js/postprocessing/GlitchPass.js +0 -104
- package/examples/js/postprocessing/HalftonePass.js +0 -75
- package/examples/js/postprocessing/LUTPass.js +0 -171
- package/examples/js/postprocessing/MaskPass.js +0 -95
- package/examples/js/postprocessing/OutlinePass.js +0 -598
- package/examples/js/postprocessing/Pass.js +0 -72
- package/examples/js/postprocessing/RenderPass.js +0 -70
- package/examples/js/postprocessing/SAOPass.js +0 -374
- package/examples/js/postprocessing/SMAAPass.js +0 -170
- package/examples/js/postprocessing/SSAARenderPass.js +0 -156
- package/examples/js/postprocessing/SSAOPass.js +0 -365
- package/examples/js/postprocessing/SSRPass.js +0 -567
- package/examples/js/postprocessing/SavePass.js +0 -59
- package/examples/js/postprocessing/ShaderPass.js +0 -64
- package/examples/js/postprocessing/TAARenderPass.js +0 -130
- package/examples/js/postprocessing/TexturePass.js +0 -49
- package/examples/js/postprocessing/UnrealBloomPass.js +0 -375
- package/examples/js/renderers/CSS2DRenderer.js +0 -178
- package/examples/js/renderers/CSS3DRenderer.js +0 -237
- package/examples/js/renderers/Projector.js +0 -818
- package/examples/js/renderers/SVGRenderer.js +0 -491
- package/examples/js/shaders/ACESFilmicToneMappingShader.js +0 -89
- package/examples/js/shaders/AfterimageShader.js +0 -60
- package/examples/js/shaders/BasicShader.js +0 -27
- package/examples/js/shaders/BleachBypassShader.js +0 -62
- package/examples/js/shaders/BlendShader.js +0 -54
- package/examples/js/shaders/BokehShader.js +0 -156
- package/examples/js/shaders/BokehShader2.js +0 -419
- package/examples/js/shaders/BrightnessContrastShader.js +0 -58
- package/examples/js/shaders/ColorCorrectionShader.js +0 -52
- package/examples/js/shaders/ColorifyShader.js +0 -47
- package/examples/js/shaders/ConvolutionShader.js +0 -92
- package/examples/js/shaders/CopyShader.js +0 -45
- package/examples/js/shaders/DOFMipMapShader.js +0 -60
- package/examples/js/shaders/DepthLimitedBlurShader.js +0 -173
- package/examples/js/shaders/DigitalGlitch.js +0 -127
- package/examples/js/shaders/DotScreenShader.js +0 -72
- package/examples/js/shaders/FXAAShader.js +0 -284
- package/examples/js/shaders/FilmShader.js +0 -110
- package/examples/js/shaders/FocusShader.js +0 -95
- package/examples/js/shaders/FreiChenShader.js +0 -93
- package/examples/js/shaders/GammaCorrectionShader.js +0 -41
- package/examples/js/shaders/GodRaysShader.js +0 -284
- package/examples/js/shaders/HalftoneShader.js +0 -336
- package/examples/js/shaders/HorizontalBlurShader.js +0 -59
- package/examples/js/shaders/HorizontalTiltShiftShader.js +0 -65
- package/examples/js/shaders/HueSaturationShader.js +0 -69
- package/examples/js/shaders/KaleidoShader.js +0 -60
- package/examples/js/shaders/LuminosityHighPassShader.js +0 -67
- package/examples/js/shaders/LuminosityShader.js +0 -46
- package/examples/js/shaders/MMDToonShader.js +0 -96
- package/examples/js/shaders/MirrorShader.js +0 -56
- package/examples/js/shaders/NormalMapShader.js +0 -55
- package/examples/js/shaders/RGBShiftShader.js +0 -56
- package/examples/js/shaders/SAOShader.js +0 -209
- package/examples/js/shaders/SMAAShader.js +0 -454
- package/examples/js/shaders/SSAOShader.js +0 -295
- package/examples/js/shaders/SSRShader.js +0 -381
- package/examples/js/shaders/SepiaShader.js +0 -52
- package/examples/js/shaders/SobelOperatorShader.js +0 -88
- package/examples/js/shaders/SubsurfaceScatteringShader.js +0 -49
- package/examples/js/shaders/TechnicolorShader.js +0 -43
- package/examples/js/shaders/ToneMapShader.js +0 -84
- package/examples/js/shaders/ToonShader.js +0 -335
- package/examples/js/shaders/TriangleBlurShader.js +0 -70
- package/examples/js/shaders/UnpackDepthRGBAShader.js +0 -47
- package/examples/js/shaders/VelocityShader.js +0 -126
- package/examples/js/shaders/VerticalBlurShader.js +0 -59
- package/examples/js/shaders/VerticalTiltShiftShader.js +0 -65
- package/examples/js/shaders/VignetteShader.js +0 -53
- package/examples/js/shaders/VolumeShader.js +0 -296
- package/examples/js/shaders/WaterRefractionShader.js +0 -84
- package/examples/js/textures/FlakesTexture.js +0 -40
- package/examples/js/utils/BufferGeometryUtils.js +0 -1160
- package/examples/js/utils/CameraUtils.js +0 -71
- package/examples/js/utils/GPUStatsPanel.js +0 -125
- package/examples/js/utils/GeometryCompressionUtils.js +0 -549
- package/examples/js/utils/GeometryUtils.js +0 -168
- package/examples/js/utils/LDrawUtils.js +0 -179
- package/examples/js/utils/PackedPhongMaterial.js +0 -109
- package/examples/js/utils/SceneUtils.js +0 -214
- package/examples/js/utils/ShadowMapViewer.js +0 -183
- package/examples/js/utils/SkeletonUtils.js +0 -493
- package/examples/js/utils/UVsDebug.js +0 -143
- package/examples/js/utils/WorkerPool.js +0 -105
- package/examples/jsm/exporters/ColladaExporter.js +0 -713
- package/examples/jsm/geometries/LightningStrike.js +0 -1017
- package/examples/jsm/libs/OimoPhysics/OimoPhysics.js +0 -37071
- package/examples/jsm/libs/OimoPhysics/index.js +0 -43
- package/examples/jsm/libs/flow.module.js +0 -4552
- package/examples/jsm/libs/tween.module.min.js +0 -3
- package/examples/jsm/loaders/BasisTextureLoader.js +0 -790
- package/examples/jsm/loaders/IFCLoader.js +0 -2431
- package/examples/jsm/loaders/PRWMLoader.js +0 -299
- package/examples/jsm/loaders/ifc/web-ifc-api.js +0 -47504
- package/examples/jsm/loaders/ifc/web-ifc.wasm +0 -0
- package/examples/jsm/node-editor/NodeEditor.js +0 -857
- package/examples/jsm/node-editor/accessors/MatcapUVEditor.js +0 -14
- package/examples/jsm/node-editor/accessors/NormalEditor.js +0 -30
- package/examples/jsm/node-editor/accessors/PositionEditor.js +0 -30
- package/examples/jsm/node-editor/accessors/UVEditor.js +0 -25
- package/examples/jsm/node-editor/core/BaseNode.js +0 -96
- package/examples/jsm/node-editor/core/DataFile.js +0 -59
- package/examples/jsm/node-editor/core/FileEditor.js +0 -20
- package/examples/jsm/node-editor/core/FileURLEditor.js +0 -29
- package/examples/jsm/node-editor/display/BlendEditor.js +0 -44
- package/examples/jsm/node-editor/display/NormalMapEditor.js +0 -49
- package/examples/jsm/node-editor/examples/animate-uv.json +0 -1
- package/examples/jsm/node-editor/examples/fake-top-light.json +0 -1
- package/examples/jsm/node-editor/examples/matcap.json +0 -1
- package/examples/jsm/node-editor/examples/oscillator-color.json +0 -1
- package/examples/jsm/node-editor/examples/rim.json +0 -1
- package/examples/jsm/node-editor/inputs/ColorEditor.js +0 -96
- package/examples/jsm/node-editor/inputs/FloatEditor.js +0 -23
- package/examples/jsm/node-editor/inputs/SliderEditor.js +0 -67
- package/examples/jsm/node-editor/inputs/TextureEditor.js +0 -155
- package/examples/jsm/node-editor/inputs/Vector2Editor.js +0 -28
- package/examples/jsm/node-editor/inputs/Vector3Editor.js +0 -30
- package/examples/jsm/node-editor/inputs/Vector4Editor.js +0 -37
- package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +0 -84
- package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +0 -102
- package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +0 -118
- package/examples/jsm/node-editor/math/AngleEditor.js +0 -40
- package/examples/jsm/node-editor/math/DotEditor.js +0 -35
- package/examples/jsm/node-editor/math/InvertEditor.js +0 -39
- package/examples/jsm/node-editor/math/LimiterEditor.js +0 -62
- package/examples/jsm/node-editor/math/NormalizeEditor.js +0 -28
- package/examples/jsm/node-editor/math/OperatorEditor.js +0 -63
- package/examples/jsm/node-editor/math/PowerEditor.js +0 -44
- package/examples/jsm/node-editor/math/TrigonometryEditor.js +0 -45
- package/examples/jsm/node-editor/procedural/CheckerEditor.js +0 -27
- package/examples/jsm/node-editor/scene/MeshEditor.js +0 -102
- package/examples/jsm/node-editor/scene/Object3DEditor.js +0 -160
- package/examples/jsm/node-editor/scene/PointsEditor.js +0 -99
- package/examples/jsm/node-editor/utils/JoinEditor.js +0 -58
- package/examples/jsm/node-editor/utils/OscillatorEditor.js +0 -43
- package/examples/jsm/node-editor/utils/PreviewEditor.js +0 -170
- package/examples/jsm/node-editor/utils/SplitEditor.js +0 -39
- package/examples/jsm/node-editor/utils/TimerEditor.js +0 -58
- package/examples/jsm/nodes/core/CodeNode.js +0 -50
- package/examples/jsm/nodes/core/ExpressionNode.js +0 -32
- package/examples/jsm/nodes/functions/light/getDistanceAttenuation.js +0 -22
- package/examples/jsm/nodes/lighting/PunctualLightNode.js +0 -68
- package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +0 -301
- package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +0 -149
- package/examples/jsm/objects/GroundProjectedEnv.js +0 -186
- package/examples/jsm/objects/LightningStorm.js +0 -245
- package/examples/jsm/physics/OimoPhysics.js +0 -231
- package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +0 -369
- package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +0 -187
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +0 -173
- package/examples/jsm/renderers/webgpu/WebGPUBinding.js +0 -22
- package/examples/jsm/renderers/webgpu/WebGPUBindings.js +0 -255
- package/examples/jsm/renderers/webgpu/WebGPUBuffer.js +0 -43
- package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +0 -78
- package/examples/jsm/renderers/webgpu/WebGPUGeometries.js +0 -82
- package/examples/jsm/renderers/webgpu/WebGPUObjects.js +0 -36
- package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +0 -22
- package/examples/jsm/renderers/webgpu/WebGPUProperties.js +0 -38
- package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +0 -296
- package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +0 -66
- package/examples/jsm/renderers/webgpu/WebGPUSampledTexture.js +0 -73
- package/examples/jsm/renderers/webgpu/WebGPUSampler.js +0 -29
- package/examples/jsm/renderers/webgpu/WebGPUStorageBuffer.js +0 -20
- package/examples/jsm/renderers/webgpu/WebGPUTextureRenderer.js +0 -40
- package/examples/jsm/renderers/webgpu/WebGPUTextures.js +0 -794
- package/examples/jsm/renderers/webgpu/WebGPUUniformBuffer.js +0 -18
- package/examples/jsm/renderers/webgpu/WebGPUUtils.js +0 -81
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +0 -83
- package/examples/jsm/shaders/ToneMapShader.js +0 -73
- package/src/renderers/shaders/ShaderChunk/uv2_pars_fragment.glsl.js +0 -7
- package/src/renderers/shaders/ShaderChunk/uv2_pars_vertex.glsl.js +0 -10
- package/src/renderers/shaders/ShaderChunk/uv2_vertex.glsl.js +0 -7
- /package/examples/{js → jsm}/libs/ammo.wasm.js +0 -0
- /package/examples/{js → jsm}/libs/ammo.wasm.wasm +0 -0
- /package/examples/{js → jsm}/libs/basis/basis_transcoder.js +0 -0
- /package/examples/{js → jsm}/libs/basis/basis_transcoder.wasm +0 -0
- /package/examples/{js → jsm}/libs/draco/README.md +0 -0
- /package/examples/{js → jsm}/libs/draco/draco_encoder.js +0 -0
- /package/examples/{js → jsm}/libs/draco/gltf/draco_encoder.js +0 -0
|
@@ -1,418 +1,87 @@
|
|
|
1
|
-
import
|
|
2
|
-
PlaneBufferGeometry,
|
|
3
|
-
Texture,
|
|
4
|
-
Uniform,
|
|
5
|
-
PerspectiveCamera,
|
|
6
|
-
Scene,
|
|
7
|
-
Mesh,
|
|
8
|
-
ShaderMaterial,
|
|
9
|
-
WebGLRenderer,
|
|
10
|
-
MathUtils,
|
|
11
|
-
Matrix4,
|
|
12
|
-
RepeatWrapping,
|
|
13
|
-
MirroredRepeatWrapping,
|
|
14
|
-
DoubleSide
|
|
15
|
-
} from 'three';
|
|
1
|
+
import * as THREE from 'three';
|
|
16
2
|
import * as fflate from '../libs/fflate.module.js';
|
|
17
3
|
|
|
18
|
-
|
|
19
|
-
// prepend "_" to fix cases where the name is just a number
|
|
20
|
-
return "_" + str.replace(/[^a-zA-Z0-9_]/g, '');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
class USDZDocument {
|
|
24
|
-
|
|
25
|
-
get isDocumentRoot() {
|
|
26
|
-
|
|
27
|
-
return true;
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
get isDynamic() {
|
|
31
|
-
|
|
32
|
-
return false;
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
constructor() {
|
|
37
|
-
|
|
38
|
-
this.name = 'StageRoot';
|
|
39
|
-
this.children = [];
|
|
40
|
-
this.stageLength = 100;
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
add( child ) {
|
|
45
|
-
|
|
46
|
-
child.parent = this;
|
|
47
|
-
this.children.push( child );
|
|
48
|
-
|
|
49
|
-
}
|
|
4
|
+
class USDZExporter {
|
|
50
5
|
|
|
51
|
-
|
|
6
|
+
async parse( scene, options = {} ) {
|
|
52
7
|
|
|
53
|
-
|
|
54
|
-
|
|
8
|
+
options = Object.assign( {
|
|
9
|
+
ar: {
|
|
10
|
+
anchoring: { type: 'plane' },
|
|
11
|
+
planeAnchoring: { alignment: 'horizontal' }
|
|
12
|
+
},
|
|
13
|
+
quickLookCompatible: false,
|
|
14
|
+
}, options );
|
|
55
15
|
|
|
56
|
-
|
|
57
|
-
|
|
16
|
+
const files = {};
|
|
17
|
+
const modelFileName = 'model.usda';
|
|
58
18
|
|
|
59
|
-
|
|
19
|
+
// model file should be first in USDZ archive so we init it here
|
|
20
|
+
files[ modelFileName ] = null;
|
|
60
21
|
|
|
61
|
-
|
|
22
|
+
let output = buildHeader();
|
|
62
23
|
|
|
24
|
+
output += buildSceneStart( options );
|
|
63
25
|
|
|
64
|
-
|
|
26
|
+
const materials = {};
|
|
27
|
+
const textures = {};
|
|
65
28
|
|
|
66
|
-
|
|
67
|
-
else current = this;
|
|
68
|
-
if ( current.children ) {
|
|
29
|
+
scene.traverseVisible( ( object ) => {
|
|
69
30
|
|
|
70
|
-
|
|
31
|
+
if ( object.isMesh ) {
|
|
71
32
|
|
|
72
|
-
|
|
33
|
+
const geometry = object.geometry;
|
|
34
|
+
const material = object.material;
|
|
73
35
|
|
|
74
|
-
|
|
36
|
+
if ( material.isMeshStandardMaterial ) {
|
|
75
37
|
|
|
76
|
-
|
|
38
|
+
const geometryFileName = 'geometries/Geometry_' + geometry.id + '.usda';
|
|
77
39
|
|
|
78
|
-
|
|
40
|
+
if ( ! ( geometryFileName in files ) ) {
|
|
79
41
|
|
|
80
|
-
|
|
42
|
+
const meshObject = buildMeshObject( geometry );
|
|
43
|
+
files[ geometryFileName ] = buildUSDFileAsString( meshObject );
|
|
81
44
|
|
|
82
|
-
|
|
83
|
-
function search( current ) {
|
|
45
|
+
}
|
|
84
46
|
|
|
85
|
-
|
|
86
|
-
if ( current.uuid === uuid ) {
|
|
47
|
+
if ( ! ( material.uuid in materials ) ) {
|
|
87
48
|
|
|
88
|
-
|
|
89
|
-
return current;
|
|
49
|
+
materials[ material.uuid ] = material;
|
|
90
50
|
|
|
91
|
-
|
|
51
|
+
}
|
|
92
52
|
|
|
93
|
-
|
|
53
|
+
output += buildXform( object, geometry, material );
|
|
94
54
|
|
|
95
|
-
|
|
55
|
+
} else {
|
|
96
56
|
|
|
97
|
-
|
|
98
|
-
if ( res ) return res;
|
|
57
|
+
console.warn( 'THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)', object );
|
|
99
58
|
|
|
100
59
|
}
|
|
101
60
|
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return search( this );
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
buildHeader() {
|
|
112
|
-
|
|
113
|
-
return `#usda 1.0
|
|
114
|
-
(
|
|
115
|
-
customLayerData = {
|
|
116
|
-
string creator = "Three.js USDZExporter"
|
|
117
|
-
}
|
|
118
|
-
defaultPrim = "${makeNameSafe(this.name)}"
|
|
119
|
-
metersPerUnit = 1
|
|
120
|
-
upAxis = "Y"
|
|
121
|
-
startTimeCode = 0
|
|
122
|
-
endTimeCode = ${this.stageLength}
|
|
123
|
-
timeCodesPerSecond = 60
|
|
124
|
-
framesPerSecond = 60
|
|
125
|
-
)
|
|
126
|
-
`;
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export class USDZObject {
|
|
133
|
-
|
|
134
|
-
static _id;
|
|
135
|
-
|
|
136
|
-
static createEmptyParent( object ) {
|
|
137
|
-
|
|
138
|
-
const emptyParent = new USDZObject( MathUtils.generateUUID(), object.name + '_empty_' + ( this._id ++ ), object.matrix );
|
|
139
|
-
const parent = object.parent;
|
|
140
|
-
parent.add( emptyParent );
|
|
141
|
-
emptyParent.add( object );
|
|
142
|
-
emptyParent.isDynamic = true;
|
|
143
|
-
object.matrix = new Matrix4().identity();
|
|
144
|
-
return emptyParent;
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
constructor( id, name, matrix, mesh, material, camera ) {
|
|
149
|
-
|
|
150
|
-
this.uuid = id;
|
|
151
|
-
this.name = makeNameSafe(name);
|
|
152
|
-
this.matrix = matrix;
|
|
153
|
-
this.geometry = mesh;
|
|
154
|
-
this.material = material;
|
|
155
|
-
this.camera = camera;
|
|
156
|
-
this.parent = null;
|
|
157
|
-
this.children = [];
|
|
158
|
-
this._eventListeners = {};
|
|
159
|
-
this.isDynamic = false;
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
is( obj ) {
|
|
164
|
-
|
|
165
|
-
if ( ! obj ) return false;
|
|
166
|
-
return this.uuid === obj.uuid;
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
isEmpty() {
|
|
171
|
-
|
|
172
|
-
return ! this.geometry;
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
clone() {
|
|
177
|
-
|
|
178
|
-
const clone = new USDZObject( MathUtils.generateUUID(), this.name, this.matrix, this.mesh, this.material );
|
|
179
|
-
clone.isDynamic = this.isDynamic;
|
|
180
|
-
return clone;
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
getPath() {
|
|
185
|
-
|
|
186
|
-
let current = this.parent;
|
|
187
|
-
let path = this.name;
|
|
188
|
-
while ( current ) {
|
|
189
|
-
|
|
190
|
-
path = current.name + '/' + path;
|
|
191
|
-
current = current.parent;
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return '</' + path + '>';
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
add( child ) {
|
|
200
|
-
|
|
201
|
-
if ( child.parent ) {
|
|
202
|
-
|
|
203
|
-
child.parent.remove( child );
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
child.parent = this;
|
|
208
|
-
this.children.push( child );
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
remove( child ) {
|
|
213
|
-
|
|
214
|
-
const index = this.children.indexOf( child );
|
|
215
|
-
if ( index >= 0 ) {
|
|
216
|
-
|
|
217
|
-
if ( child.parent === this ) child.parent = null;
|
|
218
|
-
this.children.splice( index, 1 );
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
addEventListener( evt, listener ) {
|
|
225
|
-
|
|
226
|
-
if ( ! this._eventListeners[ evt ] ) this._eventListeners[ evt ] = [];
|
|
227
|
-
this._eventListeners[ evt ].push( listener );
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
removeEventListener( evt, listener ) {
|
|
232
|
-
|
|
233
|
-
if ( ! this._eventListeners[ evt ] ) return;
|
|
234
|
-
const index = this._eventListeners[ evt ].indexOf( listener );
|
|
235
|
-
if ( index >= 0 ) {
|
|
236
|
-
|
|
237
|
-
this._eventListeners[ evt ].splice( index, 1 );
|
|
61
|
+
} else if ( object.isCamera ) {
|
|
238
62
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
onSerialize( writer, context ) {
|
|
244
|
-
|
|
245
|
-
this._eventListeners[ 'serialize' ]?.forEach( listener => listener( writer, context ) );
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
const newLine = '\n';
|
|
252
|
-
export class CodeWriter {
|
|
253
|
-
|
|
254
|
-
constructor() {
|
|
255
|
-
|
|
256
|
-
this.str = '';
|
|
257
|
-
this.indent = 0;
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
clear() {
|
|
262
|
-
|
|
263
|
-
this.str = '';
|
|
264
|
-
this.indent = 0;
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
beginBlock( str ) {
|
|
269
|
-
|
|
270
|
-
str = this.applyIndent( str );
|
|
271
|
-
this.str += str;
|
|
272
|
-
this.str += newLine;
|
|
273
|
-
this.str += this.applyIndent( '{' );
|
|
274
|
-
this.str += newLine;
|
|
275
|
-
this.indent += 1;
|
|
276
|
-
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
closeBlock() {
|
|
280
|
-
|
|
281
|
-
this.indent -= 1;
|
|
282
|
-
this.str += this.applyIndent( '}' ) + newLine;
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
beginArray( str ) {
|
|
287
|
-
|
|
288
|
-
str = this.applyIndent( str + ' = [' );
|
|
289
|
-
this.str += str;
|
|
290
|
-
this.str += newLine;
|
|
291
|
-
this.indent += 1;
|
|
292
|
-
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
closeArray() {
|
|
296
|
-
|
|
297
|
-
this.indent -= 1;
|
|
298
|
-
this.str += this.applyIndent( ']' ) + newLine;
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
appendLine( str = '' ) {
|
|
303
|
-
|
|
304
|
-
str = this.applyIndent( str );
|
|
305
|
-
this.str += str;
|
|
306
|
-
this.str += newLine;
|
|
307
|
-
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
toString() {
|
|
311
|
-
|
|
312
|
-
return this.str;
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
applyIndent( str ) {
|
|
317
|
-
|
|
318
|
-
let indents = '';
|
|
319
|
-
for ( let i = 0; i < this.indent; i ++ ) indents += '\t';
|
|
320
|
-
return indents + str;
|
|
321
|
-
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
class USDZExporterContext {
|
|
327
|
-
|
|
328
|
-
constructor( root, exporter, extensions ) {
|
|
63
|
+
output += buildCamera( object );
|
|
329
64
|
|
|
330
|
-
|
|
331
|
-
this.exporter = exporter;
|
|
332
|
-
|
|
333
|
-
if ( extensions )
|
|
334
|
-
this.extensions = extensions;
|
|
335
|
-
|
|
336
|
-
this.materials = {};
|
|
337
|
-
this.textures = {};
|
|
338
|
-
this.files = {};
|
|
339
|
-
this.document = new USDZDocument();
|
|
340
|
-
this.output = '';
|
|
341
|
-
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
class USDZExporter {
|
|
347
|
-
|
|
348
|
-
constructor(){
|
|
349
|
-
this.debug = false;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
async parse( scene, extensions, sceneAnchoringOptions = { ar: { anchoring: { type: 'plane' }, planeAnchoring: { alignment: 'horizontal' } } } ) {
|
|
353
|
-
|
|
354
|
-
this.sceneAnchoringOptions = sceneAnchoringOptions;
|
|
355
|
-
const context = new USDZExporterContext( scene, this, extensions );
|
|
356
|
-
extensions = context.extensions;
|
|
357
|
-
|
|
358
|
-
const files = context.files;
|
|
359
|
-
const modelFileName = 'model.usda';
|
|
360
|
-
|
|
361
|
-
// model file should be first in USDZ archive so we init it here
|
|
362
|
-
files[ modelFileName ] = null;
|
|
363
|
-
|
|
364
|
-
const materials = context.materials;
|
|
365
|
-
const textures = context.textures;
|
|
366
|
-
|
|
367
|
-
invokeAll( context, 'onBeforeBuildDocument' );
|
|
368
|
-
|
|
369
|
-
traverseVisible( scene, context.document, context );
|
|
370
|
-
|
|
371
|
-
invokeAll( context, 'onAfterBuildDocument' );
|
|
372
|
-
|
|
373
|
-
parseDocument( context );
|
|
374
|
-
|
|
375
|
-
invokeAll( context, 'onAfterSerialize' );
|
|
65
|
+
}
|
|
376
66
|
|
|
377
|
-
|
|
67
|
+
} );
|
|
378
68
|
|
|
379
|
-
const header = context.document.buildHeader();
|
|
380
|
-
const final = header + '\n' + context.output;
|
|
381
69
|
|
|
382
|
-
|
|
383
|
-
this.lastUsda = final;
|
|
70
|
+
output += buildSceneEnd();
|
|
384
71
|
|
|
385
|
-
|
|
386
|
-
if(this.debug)
|
|
387
|
-
console.log( final );
|
|
72
|
+
output += buildMaterials( materials, textures, options.quickLookCompatible );
|
|
388
73
|
|
|
389
|
-
files[ modelFileName ] = fflate.strToU8(
|
|
390
|
-
|
|
74
|
+
files[ modelFileName ] = fflate.strToU8( output );
|
|
75
|
+
output = null;
|
|
391
76
|
|
|
392
77
|
for ( const id in textures ) {
|
|
393
78
|
|
|
394
|
-
|
|
395
|
-
const isRGBA = texture.format === 1023;
|
|
396
|
-
if ( texture.isCompressedTexture ) {
|
|
397
|
-
|
|
398
|
-
texture = copyTexture( texture );
|
|
79
|
+
const texture = textures[ id ];
|
|
399
80
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
// TODO add readback options for textures that don't have texture.image
|
|
403
|
-
const canvas = await imageToCanvas( texture.image );
|
|
81
|
+
const canvas = imageToCanvas( texture.image, texture.flipY );
|
|
82
|
+
const blob = await new Promise( resolve => canvas.toBlob( resolve, 'image/png', 1 ) );
|
|
404
83
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
const blob = await new Promise( resolve => canvas.toBlob( resolve, isRGBA ? 'image/png' : 'image/jpeg', 1 ) );
|
|
408
|
-
files[ `textures/Texture_${id}.${isRGBA ? 'png' : 'jpg'}` ] = new Uint8Array( await blob.arrayBuffer() );
|
|
409
|
-
|
|
410
|
-
}
|
|
411
|
-
else {
|
|
412
|
-
|
|
413
|
-
console.warn( 'Can`t export texture: ', texture );
|
|
414
|
-
|
|
415
|
-
}
|
|
84
|
+
files[ `textures/Texture_${ id }.png` ] = new Uint8Array( await blob.arrayBuffer() );
|
|
416
85
|
|
|
417
86
|
}
|
|
418
87
|
|
|
@@ -449,273 +118,91 @@ class USDZExporter {
|
|
|
449
118
|
|
|
450
119
|
}
|
|
451
120
|
|
|
452
|
-
function
|
|
453
|
-
|
|
454
|
-
if ( ! object.visible ) return;
|
|
455
|
-
|
|
456
|
-
let model = undefined;
|
|
457
|
-
const geometry = object.geometry;
|
|
458
|
-
const material = object.material;
|
|
459
|
-
|
|
460
|
-
if ( object.isMesh && material?.isMeshStandardMaterial && ! object.isSkinnedMesh ) {
|
|
461
|
-
|
|
462
|
-
const name = getObjectId( object );
|
|
463
|
-
model = new USDZObject( object.uuid, name, object.matrix, geometry, material );
|
|
464
|
-
|
|
465
|
-
} else if ( object.isCamera ) {
|
|
121
|
+
function imageToCanvas( image, flipY ) {
|
|
466
122
|
|
|
467
|
-
|
|
468
|
-
|
|
123
|
+
if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||
|
|
124
|
+
( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||
|
|
125
|
+
( typeof OffscreenCanvas !== 'undefined' && image instanceof OffscreenCanvas ) ||
|
|
126
|
+
( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) {
|
|
469
127
|
|
|
470
|
-
|
|
128
|
+
const scale = 1024 / Math.max( image.width, image.height );
|
|
471
129
|
|
|
472
|
-
const
|
|
473
|
-
|
|
130
|
+
const canvas = document.createElement( 'canvas' );
|
|
131
|
+
canvas.width = image.width * Math.min( 1, scale );
|
|
132
|
+
canvas.height = image.height * Math.min( 1, scale );
|
|
474
133
|
|
|
475
|
-
|
|
134
|
+
const context = canvas.getContext( '2d' );
|
|
476
135
|
|
|
477
|
-
|
|
136
|
+
// TODO: We should be able to do this in the UsdTransform2d?
|
|
478
137
|
|
|
479
|
-
if (
|
|
138
|
+
if ( flipY === true ) {
|
|
480
139
|
|
|
481
|
-
|
|
140
|
+
context.translate( 0, canvas.height );
|
|
141
|
+
context.scale( 1, - 1 );
|
|
482
142
|
|
|
483
143
|
}
|
|
484
144
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
if ( context.extensions ) {
|
|
488
|
-
|
|
489
|
-
for ( const ext of context.extensions ) {
|
|
490
|
-
|
|
491
|
-
ext.onExportObject?.call( ext, object, model, context );
|
|
492
|
-
|
|
493
|
-
}
|
|
145
|
+
context.drawImage( image, 0, 0, canvas.width, canvas.height );
|
|
494
146
|
|
|
495
|
-
|
|
147
|
+
return canvas;
|
|
496
148
|
|
|
497
149
|
} else {
|
|
498
150
|
|
|
499
|
-
|
|
500
|
-
const empty = new USDZObject( object.uuid, name, object.matrix );
|
|
501
|
-
if ( parentModel ) {
|
|
502
|
-
|
|
503
|
-
parentModel.add( empty );
|
|
504
|
-
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
parentModel = empty;
|
|
508
|
-
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
for ( const ch of object.children ) {
|
|
512
|
-
|
|
513
|
-
traverseVisible( ch, parentModel, context );
|
|
151
|
+
throw new Error( 'THREE.USDZExporter: No valid image data found. Unable to process texture.' );
|
|
514
152
|
|
|
515
153
|
}
|
|
516
154
|
|
|
517
155
|
}
|
|
518
156
|
|
|
519
|
-
|
|
157
|
+
//
|
|
520
158
|
|
|
521
|
-
|
|
159
|
+
const PRECISION = 7;
|
|
522
160
|
|
|
523
|
-
|
|
161
|
+
function buildHeader() {
|
|
524
162
|
|
|
163
|
+
return `#usda 1.0
|
|
164
|
+
(
|
|
165
|
+
customLayerData = {
|
|
166
|
+
string creator = "Three.js USDZExporter"
|
|
525
167
|
}
|
|
168
|
+
metersPerUnit = 1
|
|
169
|
+
upAxis = "Y"
|
|
170
|
+
)
|
|
526
171
|
|
|
527
|
-
|
|
172
|
+
`;
|
|
528
173
|
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
kind = "sceneLibrary"
|
|
533
|
-
)`);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function buildSceneStart( options ) {
|
|
534
177
|
|
|
535
|
-
|
|
178
|
+
return `def Xform "Root"
|
|
179
|
+
{
|
|
180
|
+
def Scope "Scenes" (
|
|
181
|
+
kind = "sceneLibrary"
|
|
182
|
+
)
|
|
183
|
+
{
|
|
184
|
+
def Xform "Scene" (
|
|
536
185
|
customData = {
|
|
537
186
|
bool preliminary_collidesWithEnvironment = 0
|
|
538
187
|
string sceneName = "Scene"
|
|
539
188
|
}
|
|
540
189
|
sceneName = "Scene"
|
|
541
|
-
)
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
writer.appendLine();
|
|
546
|
-
|
|
547
|
-
for ( const child of context.document.children ) {
|
|
548
|
-
|
|
549
|
-
buildXform( child, writer, context );
|
|
550
|
-
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
invokeAll( context, 'onAfterHierarchy', writer );
|
|
554
|
-
|
|
555
|
-
writer.closeBlock();
|
|
556
|
-
writer.closeBlock();
|
|
557
|
-
writer.closeBlock();
|
|
558
|
-
|
|
559
|
-
context.output += writer.toString();
|
|
560
|
-
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
function addResources( object, context ) {
|
|
564
|
-
|
|
565
|
-
const geometry = object.geometry;
|
|
566
|
-
const material = object.material;
|
|
567
|
-
|
|
568
|
-
if ( geometry ) {
|
|
569
|
-
|
|
570
|
-
if ( material.isMeshStandardMaterial ) {
|
|
571
|
-
|
|
572
|
-
const geometryFileName = 'geometries/Geometry_' + geometry.id + '.usd';
|
|
573
|
-
|
|
574
|
-
if ( ! ( geometryFileName in context.files ) ) {
|
|
575
|
-
|
|
576
|
-
const meshObject = buildMeshObject( geometry );
|
|
577
|
-
context.files[ geometryFileName ] = buildUSDFileAsString( meshObject, context );
|
|
578
|
-
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
if ( ! ( material.uuid in context.materials ) ) {
|
|
582
|
-
|
|
583
|
-
context.materials[ material.uuid ] = material;
|
|
584
|
-
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
} else {
|
|
588
|
-
|
|
589
|
-
console.warn( 'THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)', name );
|
|
590
|
-
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
for ( const ch of object.children ) {
|
|
596
|
-
|
|
597
|
-
addResources( ch, context );
|
|
598
|
-
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
function invokeAll( context, name, writer = null ) {
|
|
604
|
-
|
|
605
|
-
if ( context.extensions ) {
|
|
606
|
-
|
|
607
|
-
for ( const ext of context.extensions ) {
|
|
608
|
-
|
|
609
|
-
if ( typeof ext[ name ] === 'function' )
|
|
610
|
-
ext[ name ]( context, writer );
|
|
611
|
-
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
function copyTexture( texture ) {
|
|
619
|
-
|
|
620
|
-
const geometry = new PlaneBufferGeometry( 2, 2, 1, 1 );
|
|
621
|
-
const material = new ShaderMaterial( {
|
|
622
|
-
uniforms: { blitTexture: new Uniform( texture ) },
|
|
623
|
-
vertexShader: `
|
|
624
|
-
varying vec2 vUv;
|
|
625
|
-
void main(){
|
|
626
|
-
vUv = uv;
|
|
627
|
-
gl_Position = vec4(position.xy * 1.0,0.,.999999);
|
|
628
|
-
}`,
|
|
629
|
-
fragmentShader: `
|
|
630
|
-
uniform sampler2D blitTexture;
|
|
631
|
-
varying vec2 vUv;
|
|
632
|
-
void main(){
|
|
633
|
-
gl_FragColor = vec4(vUv.xy, 0, 1);
|
|
634
|
-
gl_FragColor = texture2D( blitTexture, vUv);
|
|
635
|
-
}`
|
|
636
|
-
} );
|
|
637
|
-
|
|
638
|
-
const mesh = new Mesh( geometry, material );
|
|
639
|
-
mesh.frustumCulled = false;
|
|
640
|
-
const cam = new PerspectiveCamera();
|
|
641
|
-
const scene = new Scene();
|
|
642
|
-
scene.add( mesh );
|
|
643
|
-
const renderer = new WebGLRenderer( { antialias: false } );
|
|
644
|
-
renderer.setSize( texture.image.width, texture.image.height );
|
|
645
|
-
renderer.clear();
|
|
646
|
-
renderer.render( scene, cam );
|
|
647
|
-
|
|
648
|
-
return new Texture( renderer.domElement );
|
|
190
|
+
)
|
|
191
|
+
{
|
|
192
|
+
token preliminary:anchoring:type = "${options.ar.anchoring.type}"
|
|
193
|
+
token preliminary:planeAnchoring:alignment = "${options.ar.planeAnchoring.alignment}"
|
|
649
194
|
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
function isImageBitmap( image ) {
|
|
654
|
-
|
|
655
|
-
return ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||
|
|
656
|
-
( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||
|
|
657
|
-
( typeof OffscreenCanvas !== 'undefined' && image instanceof OffscreenCanvas ) ||
|
|
658
|
-
( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap );
|
|
195
|
+
`;
|
|
659
196
|
|
|
660
197
|
}
|
|
661
198
|
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
if ( isImageBitmap( image ) ) {
|
|
665
|
-
|
|
666
|
-
const scale = 1024 / Math.max( image.width, image.height );
|
|
667
|
-
|
|
668
|
-
const canvas = document.createElement( 'canvas' );
|
|
669
|
-
canvas.width = image.width * Math.min( 1, scale );
|
|
670
|
-
canvas.height = image.height * Math.min( 1, scale );
|
|
671
|
-
|
|
672
|
-
const context = canvas.getContext( '2d' );
|
|
673
|
-
context.drawImage( image, 0, 0, canvas.width, canvas.height );
|
|
674
|
-
|
|
675
|
-
// TODO remove, not used anymore
|
|
676
|
-
if ( color !== undefined ) {
|
|
677
|
-
|
|
678
|
-
const hex = parseInt( color, 16 );
|
|
679
|
-
|
|
680
|
-
const r = ( hex >> 16 & 255 ) / 255;
|
|
681
|
-
const g = ( hex >> 8 & 255 ) / 255;
|
|
682
|
-
const b = ( hex & 255 ) / 255;
|
|
683
|
-
|
|
684
|
-
const imagedata = context.getImageData( 0, 0, canvas.width, canvas.height );
|
|
685
|
-
const data = imagedata.data;
|
|
686
|
-
|
|
687
|
-
for ( let i = 0; i < data.length; i += 4 ) {
|
|
688
|
-
|
|
689
|
-
data[ i + 0 ] = data[ i + 0 ] * r;
|
|
690
|
-
data[ i + 1 ] = data[ i + 1 ] * g;
|
|
691
|
-
data[ i + 2 ] = data[ i + 2 ] * b;
|
|
692
|
-
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
context.putImageData( imagedata, 0, 0 );
|
|
199
|
+
function buildSceneEnd() {
|
|
696
200
|
|
|
201
|
+
return `
|
|
697
202
|
}
|
|
698
|
-
|
|
699
|
-
return canvas;
|
|
700
|
-
|
|
701
203
|
}
|
|
702
|
-
|
|
703
204
|
}
|
|
704
205
|
|
|
705
|
-
//
|
|
706
|
-
|
|
707
|
-
const PRECISION = 7;
|
|
708
|
-
|
|
709
|
-
function buildHeader() {
|
|
710
|
-
|
|
711
|
-
return `#usda 1.0
|
|
712
|
-
(
|
|
713
|
-
customLayerData = {
|
|
714
|
-
string creator = "Three.js USDZExporter"
|
|
715
|
-
}
|
|
716
|
-
metersPerUnit = 1
|
|
717
|
-
upAxis = "Y"
|
|
718
|
-
)
|
|
719
206
|
`;
|
|
720
207
|
|
|
721
208
|
}
|
|
@@ -728,95 +215,45 @@ function buildUSDFileAsString( dataToInsert ) {
|
|
|
728
215
|
|
|
729
216
|
}
|
|
730
217
|
|
|
731
|
-
function getObjectId( object ) {
|
|
732
|
-
|
|
733
|
-
return object.name.replace( /[-<>\(\)\[\]§$%&\/\\\=\?\,\;]/g, '' ) + '_' + object.id;
|
|
734
|
-
|
|
735
|
-
}
|
|
736
|
-
|
|
737
218
|
// Xform
|
|
738
219
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
const matrix = model.matrix;
|
|
742
|
-
const geometry = model.geometry;
|
|
743
|
-
const material = model.material;
|
|
744
|
-
const camera = model.camera;
|
|
745
|
-
const name = model.name;
|
|
746
|
-
const transform = buildMatrix( matrix );
|
|
747
|
-
|
|
748
|
-
if ( matrix.determinant() < 0 ) {
|
|
749
|
-
|
|
750
|
-
console.warn( 'THREE.USDZExporter: USDZ does not support negative scales', name );
|
|
751
|
-
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
if ( geometry )
|
|
755
|
-
writer.beginBlock( `def Xform "${name}" (prepend references = @./geometries/Geometry_${geometry.id}.usd@</Geometry>)` );
|
|
756
|
-
else if ( camera )
|
|
757
|
-
writer.beginBlock( `def Camera "${name}"` );
|
|
758
|
-
else
|
|
759
|
-
writer.beginBlock( `def Xform "${name}"` );
|
|
760
|
-
|
|
761
|
-
if ( material )
|
|
762
|
-
writer.appendLine( `rel material:binding = </Materials/Material_${material.id}>` );
|
|
763
|
-
writer.appendLine( `matrix4d xformOp:transform = ${transform}` );
|
|
764
|
-
writer.appendLine( 'uniform token[] xformOpOrder = ["xformOp:transform"]' );
|
|
765
|
-
|
|
766
|
-
if ( camera ) {
|
|
767
|
-
|
|
768
|
-
if ( camera.isOrthographicCamera ) {
|
|
769
|
-
|
|
770
|
-
writer.appendLine(`float2 clippingRange = (${camera.near}, ${camera.far})`);
|
|
771
|
-
writer.appendLine(`float horizontalAperture = ${(( Math.abs( camera.left ) + Math.abs( camera.right ) ) * 10).toPrecision( PRECISION )}`);
|
|
772
|
-
writer.appendLine(`float verticalAperture = ${(( Math.abs( camera.top ) + Math.abs( camera.bottom ) ) * 10).toPrecision( PRECISION )}`);
|
|
773
|
-
writer.appendLine(`token projection = "orthographic"`);
|
|
774
|
-
|
|
775
|
-
} else {
|
|
776
|
-
|
|
777
|
-
writer.appendLine(`float2 clippingRange = (${camera.near.toPrecision( PRECISION )}, ${camera.far.toPrecision( PRECISION )})`);
|
|
778
|
-
writer.appendLine(`float focalLength = ${camera.getFocalLength().toPrecision( PRECISION )}`);
|
|
779
|
-
writer.appendLine(`float focusDistance = ${camera.focus.toPrecision( PRECISION )}`);
|
|
780
|
-
writer.appendLine(`float horizontalAperture = ${camera.getFilmWidth().toPrecision( PRECISION )}`);
|
|
781
|
-
writer.appendLine(`token projection = "perspective"`);
|
|
782
|
-
writer.appendLine(`float verticalAperture = ${camera.getFilmHeight().toPrecision( PRECISION )}`);
|
|
220
|
+
function buildXform( object, geometry, material ) {
|
|
783
221
|
|
|
784
|
-
|
|
222
|
+
const name = 'Object_' + object.id;
|
|
223
|
+
const transform = buildMatrix( object.matrixWorld );
|
|
785
224
|
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
if ( model.onSerialize ) {
|
|
225
|
+
if ( object.matrixWorld.determinant() < 0 ) {
|
|
789
226
|
|
|
790
|
-
|
|
227
|
+
console.warn( 'THREE.USDZExporter: USDZ does not support negative scales', object );
|
|
791
228
|
|
|
792
229
|
}
|
|
793
230
|
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
}
|
|
231
|
+
return `def Xform "${ name }" (
|
|
232
|
+
prepend references = @./geometries/Geometry_${ geometry.id }.usda@</Geometry>
|
|
233
|
+
prepend apiSchemas = ["MaterialBindingAPI"]
|
|
234
|
+
)
|
|
235
|
+
{
|
|
236
|
+
matrix4d xformOp:transform = ${ transform }
|
|
237
|
+
uniform token[] xformOpOrder = ["xformOp:transform"]
|
|
802
238
|
|
|
803
|
-
}
|
|
239
|
+
rel material:binding = </Materials/Material_${ material.id }>
|
|
240
|
+
}
|
|
804
241
|
|
|
805
|
-
|
|
242
|
+
`;
|
|
806
243
|
|
|
807
244
|
}
|
|
808
245
|
|
|
809
|
-
|
|
246
|
+
function buildMatrix( matrix ) {
|
|
810
247
|
|
|
811
248
|
const array = matrix.elements;
|
|
812
249
|
|
|
813
|
-
return `( ${buildMatrixRow( array, 0 )}, ${buildMatrixRow( array, 4 )}, ${buildMatrixRow( array, 8 )}, ${buildMatrixRow( array, 12 )} )`;
|
|
250
|
+
return `( ${ buildMatrixRow( array, 0 ) }, ${ buildMatrixRow( array, 4 ) }, ${ buildMatrixRow( array, 8 ) }, ${ buildMatrixRow( array, 12 ) } )`;
|
|
814
251
|
|
|
815
252
|
}
|
|
816
253
|
|
|
817
254
|
function buildMatrixRow( array, offset ) {
|
|
818
255
|
|
|
819
|
-
return `(${array[ offset + 0 ]}, ${array[ offset + 1 ]}, ${array[ offset + 2 ]}, ${array[ offset + 3 ]})`;
|
|
256
|
+
return `(${ array[ offset + 0 ] }, ${ array[ offset + 1 ] }, ${ array[ offset + 2 ] }, ${ array[ offset + 3 ] })`;
|
|
820
257
|
|
|
821
258
|
}
|
|
822
259
|
|
|
@@ -828,7 +265,7 @@ function buildMeshObject( geometry ) {
|
|
|
828
265
|
return `
|
|
829
266
|
def "Geometry"
|
|
830
267
|
{
|
|
831
|
-
|
|
268
|
+
${mesh}
|
|
832
269
|
}
|
|
833
270
|
`;
|
|
834
271
|
|
|
@@ -841,24 +278,17 @@ function buildMesh( geometry ) {
|
|
|
841
278
|
const count = attributes.position.count;
|
|
842
279
|
|
|
843
280
|
return `
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
)` : '' }
|
|
856
|
-
${attributes.uv2 ?
|
|
857
|
-
`float2[] primvars:st2 = [${buildVector2Array( attributes.uv2, count )}] (
|
|
858
|
-
interpolation = "vertex"
|
|
859
|
-
)` : '' }
|
|
860
|
-
uniform token subdivisionScheme = "none"
|
|
861
|
-
}
|
|
281
|
+
def Mesh "${ name }"
|
|
282
|
+
{
|
|
283
|
+
int[] faceVertexCounts = [${ buildMeshVertexCount( geometry ) }]
|
|
284
|
+
int[] faceVertexIndices = [${ buildMeshVertexIndices( geometry ) }]
|
|
285
|
+
normal3f[] normals = [${ buildVector3Array( attributes.normal, count )}] (
|
|
286
|
+
interpolation = "vertex"
|
|
287
|
+
)
|
|
288
|
+
point3f[] points = [${ buildVector3Array( attributes.position, count )}]
|
|
289
|
+
${ buildPrimvars( attributes, count ) }
|
|
290
|
+
uniform token subdivisionScheme = "none"
|
|
291
|
+
}
|
|
862
292
|
`;
|
|
863
293
|
|
|
864
294
|
}
|
|
@@ -917,7 +347,7 @@ function buildVector3Array( attribute, count ) {
|
|
|
917
347
|
const y = attribute.getY( i );
|
|
918
348
|
const z = attribute.getZ( i );
|
|
919
349
|
|
|
920
|
-
array.push( `(${x.toPrecision( PRECISION )}, ${y.toPrecision( PRECISION )}, ${z.toPrecision( PRECISION )})` );
|
|
350
|
+
array.push( `(${ x.toPrecision( PRECISION ) }, ${ y.toPrecision( PRECISION ) }, ${ z.toPrecision( PRECISION ) })` );
|
|
921
351
|
|
|
922
352
|
}
|
|
923
353
|
|
|
@@ -941,7 +371,7 @@ function buildVector2Array( attribute, count ) {
|
|
|
941
371
|
const x = attribute.getX( i );
|
|
942
372
|
const y = attribute.getY( i );
|
|
943
373
|
|
|
944
|
-
array.push( `(${x.toPrecision( PRECISION )}, ${1 - y.toPrecision( PRECISION )})` );
|
|
374
|
+
array.push( `(${ x.toPrecision( PRECISION ) }, ${ 1 - y.toPrecision( PRECISION ) })` );
|
|
945
375
|
|
|
946
376
|
}
|
|
947
377
|
|
|
@@ -949,9 +379,33 @@ function buildVector2Array( attribute, count ) {
|
|
|
949
379
|
|
|
950
380
|
}
|
|
951
381
|
|
|
382
|
+
function buildPrimvars( attributes, count ) {
|
|
383
|
+
|
|
384
|
+
let string = '';
|
|
385
|
+
|
|
386
|
+
for ( let i = 0; i < 4; i ++ ) {
|
|
387
|
+
|
|
388
|
+
const id = ( i > 0 ? i : '' );
|
|
389
|
+
const attribute = attributes[ 'uv' + id ];
|
|
390
|
+
|
|
391
|
+
if ( attribute !== undefined ) {
|
|
392
|
+
|
|
393
|
+
string += `
|
|
394
|
+
texCoord2f[] primvars:st${ id } = [${ buildVector2Array( attribute, count )}] (
|
|
395
|
+
interpolation = "vertex"
|
|
396
|
+
)`;
|
|
397
|
+
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
return string;
|
|
403
|
+
|
|
404
|
+
}
|
|
405
|
+
|
|
952
406
|
// Materials
|
|
953
407
|
|
|
954
|
-
function buildMaterials( materials, textures ) {
|
|
408
|
+
function buildMaterials( materials, textures, quickLookCompatible = false ) {
|
|
955
409
|
|
|
956
410
|
const array = [];
|
|
957
411
|
|
|
@@ -959,92 +413,112 @@ function buildMaterials( materials, textures ) {
|
|
|
959
413
|
|
|
960
414
|
const material = materials[ uuid ];
|
|
961
415
|
|
|
962
|
-
array.push( buildMaterial( material, textures ) );
|
|
416
|
+
array.push( buildMaterial( material, textures, quickLookCompatible ) );
|
|
963
417
|
|
|
964
418
|
}
|
|
965
419
|
|
|
966
420
|
return `def "Materials"
|
|
967
421
|
{
|
|
968
|
-
${array.join( '' )}
|
|
422
|
+
${ array.join( '' ) }
|
|
969
423
|
}
|
|
970
424
|
|
|
971
425
|
`;
|
|
972
426
|
|
|
973
427
|
}
|
|
974
428
|
|
|
975
|
-
function buildMaterial( material, textures ) {
|
|
429
|
+
function buildMaterial( material, textures, quickLookCompatible = false ) {
|
|
976
430
|
|
|
977
431
|
// https://graphics.pixar.com/usd/docs/UsdPreviewSurface-Proposal.html
|
|
978
432
|
|
|
979
|
-
const pad = '
|
|
433
|
+
const pad = ' ';
|
|
980
434
|
const inputs = [];
|
|
981
435
|
const samplers = [];
|
|
982
|
-
const exportForQuickLook = true;
|
|
983
436
|
|
|
984
|
-
function buildTexture( texture, mapType, color
|
|
437
|
+
function buildTexture( texture, mapType, color ) {
|
|
438
|
+
|
|
439
|
+
const id = texture.source.id + '_' + texture.flipY;
|
|
440
|
+
|
|
441
|
+
textures[ id ] = texture;
|
|
985
442
|
|
|
986
|
-
const
|
|
987
|
-
const isRGBA = texture.format === 1023;
|
|
443
|
+
const uv = texture.channel > 0 ? 'st' + texture.channel : 'st';
|
|
988
444
|
|
|
989
|
-
const
|
|
990
|
-
|
|
445
|
+
const WRAPPINGS = {
|
|
446
|
+
1000: 'repeat', // RepeatWrapping
|
|
447
|
+
1001: 'clamp', // ClampToEdgeWrapping
|
|
448
|
+
1002: 'mirror' // MirroredRepeatWrapping
|
|
449
|
+
};
|
|
991
450
|
|
|
992
451
|
const repeat = texture.repeat.clone();
|
|
993
452
|
const offset = texture.offset.clone();
|
|
453
|
+
const rotation = texture.rotation;
|
|
454
|
+
|
|
455
|
+
// rotation is around the wrong point. after rotation we need to shift offset again so that we're rotating around the right spot
|
|
456
|
+
const xRotationOffset = Math.sin( rotation );
|
|
457
|
+
const yRotationOffset = Math.cos( rotation );
|
|
994
458
|
|
|
995
459
|
// texture coordinates start in the opposite corner, need to correct
|
|
996
460
|
offset.y = 1 - offset.y - repeat.y;
|
|
997
461
|
|
|
998
|
-
// turns out QuickLook is buggy and interprets texture repeat inverted.
|
|
462
|
+
// turns out QuickLook is buggy and interprets texture repeat inverted/applies operations in a different order.
|
|
999
463
|
// Apple Feedback: FB10036297 and FB11442287
|
|
1000
|
-
if (
|
|
464
|
+
if ( quickLookCompatible ) {
|
|
465
|
+
|
|
466
|
+
// This is NOT correct yet in QuickLook, but comes close for a range of models.
|
|
467
|
+
// It becomes more incorrect the bigger the offset is
|
|
1001
468
|
|
|
1002
469
|
offset.x = offset.x / repeat.x;
|
|
1003
470
|
offset.y = offset.y / repeat.y;
|
|
1004
471
|
|
|
1005
|
-
|
|
472
|
+
offset.x += xRotationOffset / repeat.x;
|
|
473
|
+
offset.y += yRotationOffset - 1;
|
|
1006
474
|
|
|
1007
|
-
|
|
1008
|
-
const uvReader = mapType == 'occlusion' ? 'uvReader_st2' : 'uvReader_st';
|
|
475
|
+
} else {
|
|
1009
476
|
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
477
|
+
// results match glTF results exactly. verified correct in usdview.
|
|
478
|
+
offset.x += xRotationOffset * repeat.x;
|
|
479
|
+
offset.y += ( 1 - yRotationOffset ) * repeat.y;
|
|
480
|
+
|
|
481
|
+
}
|
|
1013
482
|
|
|
1014
483
|
return `
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
484
|
+
def Shader "PrimvarReader_${ mapType }"
|
|
485
|
+
{
|
|
486
|
+
uniform token info:id = "UsdPrimvarReader_float2"
|
|
487
|
+
float2 inputs:fallback = (0.0, 0.0)
|
|
488
|
+
token inputs:varname = "${ uv }"
|
|
489
|
+
float2 outputs:result
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
def Shader "Transform2d_${ mapType }"
|
|
493
|
+
{
|
|
494
|
+
uniform token info:id = "UsdTransform2d"
|
|
495
|
+
token inputs:in.connect = </Materials/Material_${ material.id }/PrimvarReader_${ mapType }.outputs:result>
|
|
496
|
+
float inputs:rotation = ${ ( rotation * ( 180 / Math.PI ) ).toFixed( PRECISION ) }
|
|
497
|
+
float2 inputs:scale = ${ buildVector2( repeat ) }
|
|
498
|
+
float2 inputs:translation = ${ buildVector2( offset ) }
|
|
499
|
+
float2 outputs:result
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
def Shader "Texture_${ texture.id }_${ mapType }"
|
|
503
|
+
{
|
|
504
|
+
uniform token info:id = "UsdUVTexture"
|
|
505
|
+
asset inputs:file = @textures/Texture_${ id }.png@
|
|
506
|
+
float2 inputs:st.connect = </Materials/Material_${ material.id }/Transform2d_${ mapType }.outputs:result>
|
|
507
|
+
${ color !== undefined ? 'float4 inputs:scale = ' + buildColor4( color ) : '' }
|
|
508
|
+
token inputs:sourceColorSpace = "${ texture.colorSpace === THREE.NoColorSpace ? 'raw' : 'sRGB' }"
|
|
509
|
+
token inputs:wrapS = "${ WRAPPINGS[ texture.wrapS ] }"
|
|
510
|
+
token inputs:wrapT = "${ WRAPPINGS[ texture.wrapT ] }"
|
|
511
|
+
float outputs:r
|
|
512
|
+
float outputs:g
|
|
513
|
+
float outputs:b
|
|
514
|
+
float3 outputs:rgb
|
|
515
|
+
${ material.transparent || material.alphaTest > 0.0 ? 'float outputs:a' : '' }
|
|
516
|
+
}`;
|
|
1042
517
|
|
|
1043
518
|
}
|
|
1044
519
|
|
|
1045
|
-
const effectiveOpacity = (material.transparent || material.alphaTest) ? material.opacity : 1;
|
|
1046
520
|
|
|
1047
|
-
if ( material.side === DoubleSide ) {
|
|
521
|
+
if ( material.side === THREE.DoubleSide ) {
|
|
1048
522
|
|
|
1049
523
|
console.warn( 'THREE.USDZExporter: USDZ does not support double sided materials', material );
|
|
1050
524
|
|
|
@@ -1052,42 +526,42 @@ function buildMaterial( material, textures ) {
|
|
|
1052
526
|
|
|
1053
527
|
if ( material.map?.image ) {
|
|
1054
528
|
|
|
1055
|
-
inputs.push( `${pad}color3f inputs:diffuseColor.connect = </Materials/Material_${material.id}/Texture_${material.map.id}_diffuse.outputs:rgb>` );
|
|
529
|
+
inputs.push( `${ pad }color3f inputs:diffuseColor.connect = </Materials/Material_${ material.id }/Texture_${ material.map.id }_diffuse.outputs:rgb>` );
|
|
1056
530
|
|
|
1057
531
|
if ( material.transparent ) {
|
|
1058
532
|
|
|
1059
|
-
inputs.push( `${pad}float inputs:opacity.connect = </Materials/Material_${material.id}/Texture_${material.map.id}_diffuse.outputs:a>` );
|
|
533
|
+
inputs.push( `${ pad }float inputs:opacity.connect = </Materials/Material_${ material.id }/Texture_${ material.map.id }_diffuse.outputs:a>` );
|
|
1060
534
|
|
|
1061
535
|
} else if ( material.alphaTest > 0.0 ) {
|
|
1062
536
|
|
|
1063
|
-
inputs.push( `${pad}float inputs:opacity.connect = </Materials/Material_${material.id}/Texture_${material.map.id}_diffuse.outputs:a>` );
|
|
1064
|
-
inputs.push( `${pad}float inputs:opacityThreshold = ${material.alphaTest}` );
|
|
537
|
+
inputs.push( `${ pad }float inputs:opacity.connect = </Materials/Material_${ material.id }/Texture_${ material.map.id }_diffuse.outputs:a>` );
|
|
538
|
+
inputs.push( `${ pad }float inputs:opacityThreshold = ${material.alphaTest}` );
|
|
1065
539
|
|
|
1066
540
|
}
|
|
1067
541
|
|
|
1068
|
-
samplers.push( buildTexture( material.map, 'diffuse', material.color
|
|
542
|
+
samplers.push( buildTexture( material.map, 'diffuse', material.color ) );
|
|
1069
543
|
|
|
1070
544
|
} else {
|
|
1071
545
|
|
|
1072
|
-
inputs.push( `${pad}color3f inputs:diffuseColor = ${buildColor( material.color )}` );
|
|
546
|
+
inputs.push( `${ pad }color3f inputs:diffuseColor = ${ buildColor( material.color ) }` );
|
|
1073
547
|
|
|
1074
548
|
}
|
|
1075
549
|
|
|
1076
550
|
if ( material.emissiveMap?.image ) {
|
|
1077
551
|
|
|
1078
|
-
inputs.push( `${pad}color3f inputs:emissiveColor.connect = </Materials/Material_${material.id}/Texture_${material.emissiveMap.id}_emissive.outputs:rgb>` );
|
|
552
|
+
inputs.push( `${ pad }color3f inputs:emissiveColor.connect = </Materials/Material_${ material.id }/Texture_${ material.emissiveMap.id }_emissive.outputs:rgb>` );
|
|
1079
553
|
|
|
1080
554
|
samplers.push( buildTexture( material.emissiveMap, 'emissive' ) );
|
|
1081
555
|
|
|
1082
556
|
} else if ( material.emissive.getHex() > 0 ) {
|
|
1083
557
|
|
|
1084
|
-
inputs.push( `${pad}color3f inputs:emissiveColor = ${buildColor( material.emissive )}` );
|
|
558
|
+
inputs.push( `${ pad }color3f inputs:emissiveColor = ${ buildColor( material.emissive ) }` );
|
|
1085
559
|
|
|
1086
560
|
}
|
|
1087
561
|
|
|
1088
562
|
if ( material.normalMap?.image ) {
|
|
1089
563
|
|
|
1090
|
-
inputs.push( `${pad}normal3f inputs:normal.connect = </Materials/Material_${material.id}/Texture_${material.normalMap.id}_normal.outputs:rgb>` );
|
|
564
|
+
inputs.push( `${ pad }normal3f inputs:normal.connect = </Materials/Material_${ material.id }/Texture_${ material.normalMap.id }_normal.outputs:rgb>` );
|
|
1091
565
|
|
|
1092
566
|
samplers.push( buildTexture( material.normalMap, 'normal' ) );
|
|
1093
567
|
|
|
@@ -1095,7 +569,7 @@ function buildMaterial( material, textures ) {
|
|
|
1095
569
|
|
|
1096
570
|
if ( material.aoMap?.image ) {
|
|
1097
571
|
|
|
1098
|
-
inputs.push( `${pad}float inputs:occlusion.connect = </Materials/Material_${material.id}/Texture_${material.aoMap.id}_occlusion.outputs:r>` );
|
|
572
|
+
inputs.push( `${ pad }float inputs:occlusion.connect = </Materials/Material_${ material.id }/Texture_${ material.aoMap.id }_occlusion.outputs:r>` );
|
|
1099
573
|
|
|
1100
574
|
samplers.push( buildTexture( material.aoMap, 'occlusion' ) );
|
|
1101
575
|
|
|
@@ -1103,25 +577,25 @@ function buildMaterial( material, textures ) {
|
|
|
1103
577
|
|
|
1104
578
|
if ( material.roughnessMap?.image && material.roughness === 1 ) {
|
|
1105
579
|
|
|
1106
|
-
inputs.push( `${pad}float inputs:roughness.connect = </Materials/Material_${material.id}/Texture_${material.roughnessMap.id}_roughness.outputs:g>` );
|
|
580
|
+
inputs.push( `${ pad }float inputs:roughness.connect = </Materials/Material_${ material.id }/Texture_${ material.roughnessMap.id }_roughness.outputs:g>` );
|
|
1107
581
|
|
|
1108
582
|
samplers.push( buildTexture( material.roughnessMap, 'roughness' ) );
|
|
1109
583
|
|
|
1110
584
|
} else {
|
|
1111
585
|
|
|
1112
|
-
inputs.push( `${pad}float inputs:roughness = ${material.roughness}` );
|
|
586
|
+
inputs.push( `${ pad }float inputs:roughness = ${ material.roughness }` );
|
|
1113
587
|
|
|
1114
588
|
}
|
|
1115
589
|
|
|
1116
590
|
if ( material.metalnessMap?.image && material.metalness === 1 ) {
|
|
1117
591
|
|
|
1118
|
-
inputs.push( `${pad}float inputs:metallic.connect = </Materials/Material_${material.id}/Texture_${material.metalnessMap.id}_metallic.outputs:b>` );
|
|
592
|
+
inputs.push( `${ pad }float inputs:metallic.connect = </Materials/Material_${ material.id }/Texture_${ material.metalnessMap.id }_metallic.outputs:b>` );
|
|
1119
593
|
|
|
1120
594
|
samplers.push( buildTexture( material.metalnessMap, 'metallic' ) );
|
|
1121
595
|
|
|
1122
596
|
} else {
|
|
1123
597
|
|
|
1124
|
-
inputs.push( `${pad}float inputs:metallic = ${material.metalness}` );
|
|
598
|
+
inputs.push( `${ pad }float inputs:metallic = ${ material.metalness }` );
|
|
1125
599
|
|
|
1126
600
|
}
|
|
1127
601
|
|
|
@@ -1134,63 +608,102 @@ function buildMaterial( material, textures ) {
|
|
|
1134
608
|
|
|
1135
609
|
} else {
|
|
1136
610
|
|
|
1137
|
-
inputs.push( `${pad}float inputs:opacity = ${
|
|
611
|
+
inputs.push( `${pad}float inputs:opacity = ${material.opacity}` );
|
|
1138
612
|
|
|
1139
613
|
}
|
|
1140
614
|
|
|
1141
615
|
if ( material.isMeshPhysicalMaterial ) {
|
|
1142
616
|
|
|
1143
|
-
inputs.push( `${pad}float inputs:clearcoat = ${material.clearcoat}` );
|
|
1144
|
-
inputs.push( `${pad}float inputs:clearcoatRoughness = ${material.clearcoatRoughness}` );
|
|
1145
|
-
inputs.push( `${pad}float inputs:ior = ${material.ior}` );
|
|
617
|
+
inputs.push( `${ pad }float inputs:clearcoat = ${ material.clearcoat }` );
|
|
618
|
+
inputs.push( `${ pad }float inputs:clearcoatRoughness = ${ material.clearcoatRoughness }` );
|
|
619
|
+
inputs.push( `${ pad }float inputs:ior = ${ material.ior }` );
|
|
1146
620
|
|
|
1147
621
|
}
|
|
1148
622
|
|
|
1149
623
|
return `
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
${inputs.join( '\n' )}
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
token inputs:varname = "st"
|
|
1166
|
-
float2 inputs:fallback = (0.0, 0.0)
|
|
1167
|
-
float2 outputs:result
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
def Shader "uvReader_st2"
|
|
1171
|
-
{
|
|
1172
|
-
uniform token info:id = "UsdPrimvarReader_float2"
|
|
1173
|
-
token inputs:varname = "st2"
|
|
1174
|
-
float2 inputs:fallback = (0.0, 0.0)
|
|
1175
|
-
float2 outputs:result
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
${samplers.join( '\n' )}
|
|
1179
|
-
|
|
1180
|
-
}
|
|
624
|
+
def Material "Material_${ material.id }"
|
|
625
|
+
{
|
|
626
|
+
def Shader "PreviewSurface"
|
|
627
|
+
{
|
|
628
|
+
uniform token info:id = "UsdPreviewSurface"
|
|
629
|
+
${ inputs.join( '\n' ) }
|
|
630
|
+
int inputs:useSpecularWorkflow = 0
|
|
631
|
+
token outputs:surface
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
token outputs:surface.connect = </Materials/Material_${ material.id }/PreviewSurface.outputs:surface>
|
|
635
|
+
|
|
636
|
+
${ samplers.join( '\n' ) }
|
|
637
|
+
|
|
638
|
+
}
|
|
1181
639
|
`;
|
|
1182
640
|
|
|
1183
641
|
}
|
|
1184
642
|
|
|
1185
643
|
function buildColor( color ) {
|
|
1186
644
|
|
|
1187
|
-
return `(${color.r}, ${color.g}, ${color.b})`;
|
|
645
|
+
return `(${ color.r }, ${ color.g }, ${ color.b })`;
|
|
646
|
+
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
function buildColor4( color ) {
|
|
650
|
+
|
|
651
|
+
return `(${ color.r }, ${ color.g }, ${ color.b }, 1.0)`;
|
|
1188
652
|
|
|
1189
653
|
}
|
|
1190
654
|
|
|
1191
655
|
function buildVector2( vector ) {
|
|
1192
656
|
|
|
1193
|
-
return `(${vector.x}, ${vector.y})`;
|
|
657
|
+
return `(${ vector.x }, ${ vector.y })`;
|
|
658
|
+
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
function buildCamera( camera ) {
|
|
663
|
+
|
|
664
|
+
const name = camera.name ? camera.name : 'Camera_' + camera.id;
|
|
665
|
+
|
|
666
|
+
const transform = buildMatrix( camera.matrixWorld );
|
|
667
|
+
|
|
668
|
+
if ( camera.matrixWorld.determinant() < 0 ) {
|
|
669
|
+
|
|
670
|
+
console.warn( 'THREE.USDZExporter: USDZ does not support negative scales', camera );
|
|
671
|
+
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
if ( camera.isOrthographicCamera ) {
|
|
675
|
+
|
|
676
|
+
return `def Camera "${name}"
|
|
677
|
+
{
|
|
678
|
+
matrix4d xformOp:transform = ${ transform }
|
|
679
|
+
uniform token[] xformOpOrder = ["xformOp:transform"]
|
|
680
|
+
|
|
681
|
+
float2 clippingRange = (${ camera.near.toPrecision( PRECISION ) }, ${ camera.far.toPrecision( PRECISION ) })
|
|
682
|
+
float horizontalAperture = ${ ( ( Math.abs( camera.left ) + Math.abs( camera.right ) ) * 10 ).toPrecision( PRECISION ) }
|
|
683
|
+
float verticalAperture = ${ ( ( Math.abs( camera.top ) + Math.abs( camera.bottom ) ) * 10 ).toPrecision( PRECISION ) }
|
|
684
|
+
token projection = "orthographic"
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
`;
|
|
688
|
+
|
|
689
|
+
} else {
|
|
690
|
+
|
|
691
|
+
return `def Camera "${name}"
|
|
692
|
+
{
|
|
693
|
+
matrix4d xformOp:transform = ${ transform }
|
|
694
|
+
uniform token[] xformOpOrder = ["xformOp:transform"]
|
|
695
|
+
|
|
696
|
+
float2 clippingRange = (${ camera.near.toPrecision( PRECISION ) }, ${ camera.far.toPrecision( PRECISION ) })
|
|
697
|
+
float focalLength = ${ camera.getFocalLength().toPrecision( PRECISION ) }
|
|
698
|
+
float focusDistance = ${ camera.focus.toPrecision( PRECISION ) }
|
|
699
|
+
float horizontalAperture = ${ camera.getFilmWidth().toPrecision( PRECISION ) }
|
|
700
|
+
token projection = "perspective"
|
|
701
|
+
float verticalAperture = ${ camera.getFilmHeight().toPrecision( PRECISION ) }
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
`;
|
|
705
|
+
|
|
706
|
+
}
|
|
1194
707
|
|
|
1195
708
|
}
|
|
1196
709
|
|