@needle-tools/three 0.146.10 → 0.153.1
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 +40124 -20919
- package/build/three.js +40120 -20914
- package/build/three.min.js +8 -6
- package/build/three.module.js +7298 -6003
- package/build/three.module.min.js +7 -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 +89 -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
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
BufferGeometry,
|
|
7
7
|
ClampToEdgeWrapping,
|
|
8
8
|
Color,
|
|
9
|
-
ColorKeyframeTrack,
|
|
10
9
|
DirectionalLight,
|
|
11
10
|
DoubleSide,
|
|
12
11
|
FileLoader,
|
|
@@ -61,8 +60,9 @@ import {
|
|
|
61
60
|
Vector2,
|
|
62
61
|
Vector3,
|
|
63
62
|
VectorKeyframeTrack,
|
|
64
|
-
|
|
63
|
+
SRGBColorSpace
|
|
65
64
|
} from 'three';
|
|
65
|
+
import { toTrianglesDrawMode } from '../utils/BufferGeometryUtils.js';
|
|
66
66
|
|
|
67
67
|
class GLTFLoader extends Loader {
|
|
68
68
|
|
|
@@ -73,7 +73,6 @@ class GLTFLoader extends Loader {
|
|
|
73
73
|
this.dracoLoader = null;
|
|
74
74
|
this.ktx2Loader = null;
|
|
75
75
|
this.meshoptDecoder = null;
|
|
76
|
-
this.animationPointerResolver = null;
|
|
77
76
|
|
|
78
77
|
this.pluginCallbacks = [];
|
|
79
78
|
|
|
@@ -95,6 +94,12 @@ class GLTFLoader extends Loader {
|
|
|
95
94
|
|
|
96
95
|
} );
|
|
97
96
|
|
|
97
|
+
this.register( function ( parser ) {
|
|
98
|
+
|
|
99
|
+
return new GLTFTextureAVIFExtension( parser );
|
|
100
|
+
|
|
101
|
+
} );
|
|
102
|
+
|
|
98
103
|
this.register( function ( parser ) {
|
|
99
104
|
|
|
100
105
|
return new GLTFMaterialsSheenExtension( parser );
|
|
@@ -139,25 +144,25 @@ class GLTFLoader extends Loader {
|
|
|
139
144
|
|
|
140
145
|
this.register( function ( parser ) {
|
|
141
146
|
|
|
142
|
-
return new
|
|
147
|
+
return new GLTFMaterialsAnisotropyExtension( parser );
|
|
143
148
|
|
|
144
149
|
} );
|
|
145
150
|
|
|
146
151
|
this.register( function ( parser ) {
|
|
147
152
|
|
|
148
|
-
return new
|
|
153
|
+
return new GLTFLightsExtension( parser );
|
|
149
154
|
|
|
150
155
|
} );
|
|
151
156
|
|
|
152
157
|
this.register( function ( parser ) {
|
|
153
158
|
|
|
154
|
-
return new
|
|
159
|
+
return new GLTFMeshoptCompression( parser );
|
|
155
160
|
|
|
156
161
|
} );
|
|
157
162
|
|
|
158
163
|
this.register( function ( parser ) {
|
|
159
164
|
|
|
160
|
-
return new
|
|
165
|
+
return new GLTFMeshGpuInstancing( parser );
|
|
161
166
|
|
|
162
167
|
} );
|
|
163
168
|
|
|
@@ -265,13 +270,6 @@ class GLTFLoader extends Loader {
|
|
|
265
270
|
|
|
266
271
|
}
|
|
267
272
|
|
|
268
|
-
setAnimationPointerResolver( animationPointerResolver ) {
|
|
269
|
-
|
|
270
|
-
this.animationPointerResolver = animationPointerResolver;
|
|
271
|
-
return this;
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
|
|
275
273
|
register( callback ) {
|
|
276
274
|
|
|
277
275
|
if ( this.pluginCallbacks.indexOf( callback ) === - 1 ) {
|
|
@@ -301,6 +299,7 @@ class GLTFLoader extends Loader {
|
|
|
301
299
|
let json;
|
|
302
300
|
const extensions = {};
|
|
303
301
|
const plugins = {};
|
|
302
|
+
const textDecoder = new TextDecoder();
|
|
304
303
|
|
|
305
304
|
if ( typeof data === 'string' ) {
|
|
306
305
|
|
|
@@ -308,7 +307,7 @@ class GLTFLoader extends Loader {
|
|
|
308
307
|
|
|
309
308
|
} else if ( data instanceof ArrayBuffer ) {
|
|
310
309
|
|
|
311
|
-
const magic =
|
|
310
|
+
const magic = textDecoder.decode( new Uint8Array( data, 0, 4 ) );
|
|
312
311
|
|
|
313
312
|
if ( magic === BINARY_EXTENSION_HEADER_MAGIC ) {
|
|
314
313
|
|
|
@@ -327,7 +326,7 @@ class GLTFLoader extends Loader {
|
|
|
327
326
|
|
|
328
327
|
} else {
|
|
329
328
|
|
|
330
|
-
json = JSON.parse(
|
|
329
|
+
json = JSON.parse( textDecoder.decode( data ) );
|
|
331
330
|
|
|
332
331
|
}
|
|
333
332
|
|
|
@@ -351,8 +350,7 @@ class GLTFLoader extends Loader {
|
|
|
351
350
|
requestHeader: this.requestHeader,
|
|
352
351
|
manager: this.manager,
|
|
353
352
|
ktx2Loader: this.ktx2Loader,
|
|
354
|
-
meshoptDecoder: this.meshoptDecoder
|
|
355
|
-
animationPointerResolver: this.animationPointerResolver,
|
|
353
|
+
meshoptDecoder: this.meshoptDecoder
|
|
356
354
|
|
|
357
355
|
} );
|
|
358
356
|
|
|
@@ -480,14 +478,15 @@ const EXTENSIONS = {
|
|
|
480
478
|
KHR_MATERIALS_SPECULAR: 'KHR_materials_specular',
|
|
481
479
|
KHR_MATERIALS_TRANSMISSION: 'KHR_materials_transmission',
|
|
482
480
|
KHR_MATERIALS_IRIDESCENCE: 'KHR_materials_iridescence',
|
|
481
|
+
KHR_MATERIALS_ANISOTROPY: 'KHR_materials_anisotropy',
|
|
483
482
|
KHR_MATERIALS_UNLIT: 'KHR_materials_unlit',
|
|
484
483
|
KHR_MATERIALS_VOLUME: 'KHR_materials_volume',
|
|
485
484
|
KHR_TEXTURE_BASISU: 'KHR_texture_basisu',
|
|
486
485
|
KHR_TEXTURE_TRANSFORM: 'KHR_texture_transform',
|
|
487
486
|
KHR_MESH_QUANTIZATION: 'KHR_mesh_quantization',
|
|
488
487
|
KHR_MATERIALS_EMISSIVE_STRENGTH: 'KHR_materials_emissive_strength',
|
|
489
|
-
KHR_ANIMATION_POINTER: 'KHR_animation_pointer',
|
|
490
488
|
EXT_TEXTURE_WEBP: 'EXT_texture_webp',
|
|
489
|
+
EXT_TEXTURE_AVIF: 'EXT_texture_avif',
|
|
491
490
|
EXT_MESHOPT_COMPRESSION: 'EXT_meshopt_compression',
|
|
492
491
|
EXT_MESH_GPU_INSTANCING: 'EXT_mesh_gpu_instancing'
|
|
493
492
|
};
|
|
@@ -671,7 +670,7 @@ class GLTFMaterialsUnlitExtension {
|
|
|
671
670
|
|
|
672
671
|
if ( metallicRoughness.baseColorTexture !== undefined ) {
|
|
673
672
|
|
|
674
|
-
pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture,
|
|
673
|
+
pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture, SRGBColorSpace ) );
|
|
675
674
|
|
|
676
675
|
}
|
|
677
676
|
|
|
@@ -806,556 +805,6 @@ class GLTFMaterialsClearcoatExtension {
|
|
|
806
805
|
|
|
807
806
|
}
|
|
808
807
|
|
|
809
|
-
/**
|
|
810
|
-
* Animation Pointer Extension
|
|
811
|
-
*
|
|
812
|
-
* Draft Specification: https://github.com/ux3d/glTF/tree/extensions/KHR_animation_pointer/extensions/2.0/Khronos/KHR_animation_pointer
|
|
813
|
-
*/
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
// HACK monkey patching findNode to ensure we can map to other types required by KHR_animation_pointer.
|
|
817
|
-
const find = PropertyBinding.findNode;
|
|
818
|
-
const _animationPointerDebug = false;
|
|
819
|
-
|
|
820
|
-
class GLTFAnimationPointerExtension {
|
|
821
|
-
|
|
822
|
-
ANIMATION_TARGET_TYPE = {
|
|
823
|
-
node: 'node',
|
|
824
|
-
material: 'material',
|
|
825
|
-
camera: 'camera',
|
|
826
|
-
light: 'light',
|
|
827
|
-
};
|
|
828
|
-
|
|
829
|
-
constructor( parser ) {
|
|
830
|
-
|
|
831
|
-
this.parser = parser;
|
|
832
|
-
this.name = EXTENSIONS.KHR_ANIMATION_POINTER;
|
|
833
|
-
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
_havePatchedPropertyBindings = false;
|
|
837
|
-
_patchPropertyBindingFindNode() {
|
|
838
|
-
|
|
839
|
-
if ( this._havePatchedPropertyBindings ) return;
|
|
840
|
-
this._havePatchedPropertyBindings = true;
|
|
841
|
-
|
|
842
|
-
// "node" is the Animator component in our case
|
|
843
|
-
// "path" is the animated property path, just with translated material names.
|
|
844
|
-
PropertyBinding.findNode = function ( node, path ) {
|
|
845
|
-
|
|
846
|
-
if ( path.startsWith( '.materials.' ) ) {
|
|
847
|
-
|
|
848
|
-
if ( _animationPointerDebug ) console.log( 'FIND', path );
|
|
849
|
-
|
|
850
|
-
const remainingPath = path.substring( '.materials.'.length ).substring( path.indexOf( '.' ) );
|
|
851
|
-
const nextIndex = remainingPath.indexOf( '.' );
|
|
852
|
-
const uuid = nextIndex < 0 ? remainingPath : remainingPath.substring( 0, nextIndex );
|
|
853
|
-
let res = null;
|
|
854
|
-
node.traverse( x => {
|
|
855
|
-
|
|
856
|
-
if ( res !== null || x.type !== 'Mesh' ) return;
|
|
857
|
-
if ( x[ 'material' ]?.uuid === uuid || x[ 'material' ]?.name === uuid ) {
|
|
858
|
-
|
|
859
|
-
res = x[ 'material' ];
|
|
860
|
-
if ( _animationPointerDebug ) console.log( res, remainingPath );
|
|
861
|
-
if ( res !== null ) {
|
|
862
|
-
|
|
863
|
-
if ( remainingPath.endsWith( '.map' ) )
|
|
864
|
-
res = res[ 'map' ];
|
|
865
|
-
else if ( remainingPath.endsWith( '.emissiveMap' ) )
|
|
866
|
-
res = res[ 'emissiveMap' ];
|
|
867
|
-
|
|
868
|
-
// TODO other texture slots only make sense if three.js actually supports them
|
|
869
|
-
// (currently only .map can have repeat/offset)
|
|
870
|
-
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
} );
|
|
876
|
-
|
|
877
|
-
return res;
|
|
878
|
-
|
|
879
|
-
} else if ( path.startsWith( '.nodes.' ) || path.startsWith( '.lights.' ) || path.startsWith( '.cameras.' ) ) {
|
|
880
|
-
|
|
881
|
-
const sections = path.split( '.' );
|
|
882
|
-
let currentTarget = undefined;
|
|
883
|
-
for ( let i = 1; i < sections.length; i ++ ) {
|
|
884
|
-
|
|
885
|
-
const val = sections[ i ];
|
|
886
|
-
const isUUID = val.length == 36;
|
|
887
|
-
if ( isUUID ) {
|
|
888
|
-
|
|
889
|
-
// access by UUID
|
|
890
|
-
currentTarget = node.getObjectByProperty( 'uuid', val );
|
|
891
|
-
|
|
892
|
-
} else if ( currentTarget && currentTarget[ val ] ) {
|
|
893
|
-
|
|
894
|
-
// access by index
|
|
895
|
-
const index = Number.parseInt( val );
|
|
896
|
-
let key = val;
|
|
897
|
-
if ( index >= 0 ) key = index;
|
|
898
|
-
currentTarget = currentTarget[ key ];
|
|
899
|
-
if ( _animationPointerDebug )
|
|
900
|
-
console.log( currentTarget );
|
|
901
|
-
|
|
902
|
-
} else {
|
|
903
|
-
|
|
904
|
-
// access by node name
|
|
905
|
-
const foundNode = node.getObjectByName( val );
|
|
906
|
-
if ( foundNode )
|
|
907
|
-
currentTarget = foundNode;
|
|
908
|
-
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
if ( ! currentTarget ) {
|
|
914
|
-
|
|
915
|
-
const originalFindResult = find( node, sections[ 2 ] );
|
|
916
|
-
|
|
917
|
-
if ( ! originalFindResult )
|
|
918
|
-
console.warn( EXTENSIONS.KHR_ANIMATION_POINTER + ': Property binding not found', path, node, node.name, sections );
|
|
919
|
-
|
|
920
|
-
return originalFindResult;
|
|
921
|
-
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
if ( _animationPointerDebug )
|
|
925
|
-
console.log( 'NODE', path, currentTarget );
|
|
926
|
-
|
|
927
|
-
return currentTarget;
|
|
928
|
-
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
return find( node, path );
|
|
932
|
-
|
|
933
|
-
};
|
|
934
|
-
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
loadAnimationTargetFromChannel( animationChannel ) {
|
|
938
|
-
|
|
939
|
-
if ( ! this._havePatchedPropertyBindings )
|
|
940
|
-
this._patchPropertyBindingFindNode();
|
|
941
|
-
|
|
942
|
-
const target = animationChannel.target;
|
|
943
|
-
const useExtension = target.extensions && target.extensions[ EXTENSIONS.KHR_ANIMATION_POINTER ] && target.path && target.path === 'pointer';
|
|
944
|
-
if ( ! useExtension ) return null;
|
|
945
|
-
|
|
946
|
-
let targetProperty = undefined;
|
|
947
|
-
|
|
948
|
-
// check if this is a extension animation
|
|
949
|
-
let type = this.ANIMATION_TARGET_TYPE.node;
|
|
950
|
-
let targetId = undefined;
|
|
951
|
-
|
|
952
|
-
if ( useExtension ) {
|
|
953
|
-
|
|
954
|
-
const ext = target.extensions[ EXTENSIONS.KHR_ANIMATION_POINTER ];
|
|
955
|
-
let path = ext.pointer;
|
|
956
|
-
if ( this._animationPointerDebug )
|
|
957
|
-
console.log( 'Original path: ' + path, target );
|
|
958
|
-
|
|
959
|
-
if ( ! path ) {
|
|
960
|
-
|
|
961
|
-
console.warn( 'Invalid path', ext, target );
|
|
962
|
-
return;
|
|
963
|
-
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
if ( path.startsWith( '/materials/' ) )
|
|
967
|
-
type = this.ANIMATION_TARGET_TYPE.material;
|
|
968
|
-
else if ( path.startsWith( '/extensions/KHR_lights_punctual/lights/' ) )
|
|
969
|
-
type = this.ANIMATION_TARGET_TYPE.light;
|
|
970
|
-
else if ( path.startsWith( '/cameras/' ) )
|
|
971
|
-
type = this.ANIMATION_TARGET_TYPE.camera;
|
|
972
|
-
|
|
973
|
-
targetId = this._tryResolveTargetId( path, type );
|
|
974
|
-
if ( targetId === null || isNaN( targetId ) ) {
|
|
975
|
-
|
|
976
|
-
console.warn( 'Failed resolving animation node id: ' + targetId, path );
|
|
977
|
-
return;
|
|
978
|
-
|
|
979
|
-
} else {
|
|
980
|
-
|
|
981
|
-
if ( this._animationPointerDebug ) console.log( 'Resolved node ID for ' + type, targetId );
|
|
982
|
-
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
// TODO could be parsed better
|
|
986
|
-
switch ( type ) {
|
|
987
|
-
|
|
988
|
-
case this.ANIMATION_TARGET_TYPE.material:
|
|
989
|
-
const pathIndex = ( '/materials/' + targetId.toString() + '/' ).length;
|
|
990
|
-
const pathStart = path.substring( 0, pathIndex );
|
|
991
|
-
targetProperty = path.substring( pathIndex );
|
|
992
|
-
|
|
993
|
-
switch ( targetProperty ) {
|
|
994
|
-
|
|
995
|
-
// Core Spec PBR Properties
|
|
996
|
-
case 'pbrMetallicRoughness/baseColorFactor':
|
|
997
|
-
targetProperty = 'color';
|
|
998
|
-
break;
|
|
999
|
-
case 'pbrMetallicRoughness/roughnessFactor':
|
|
1000
|
-
targetProperty = 'roughness';
|
|
1001
|
-
break;
|
|
1002
|
-
case 'pbrMetallicRoughness/metallicFactor':
|
|
1003
|
-
targetProperty = 'metalness';
|
|
1004
|
-
break;
|
|
1005
|
-
case 'emissiveFactor':
|
|
1006
|
-
targetProperty = 'emissive';
|
|
1007
|
-
break;
|
|
1008
|
-
case 'alphaCutoff':
|
|
1009
|
-
targetProperty = 'alphaTest';
|
|
1010
|
-
break;
|
|
1011
|
-
case 'occlusionTexture/strength':
|
|
1012
|
-
targetProperty = 'aoMapIntensity';
|
|
1013
|
-
break;
|
|
1014
|
-
case 'normalTexture/scale':
|
|
1015
|
-
targetProperty = 'normalScale';
|
|
1016
|
-
break;
|
|
1017
|
-
|
|
1018
|
-
// Core Spec + KHR_texture_transform
|
|
1019
|
-
case 'pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale':
|
|
1020
|
-
targetProperty = 'map/repeat';
|
|
1021
|
-
break;
|
|
1022
|
-
case 'pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset':
|
|
1023
|
-
targetProperty = 'map/offset';
|
|
1024
|
-
break;
|
|
1025
|
-
|
|
1026
|
-
// UV transforms for anything but map doesn't seem to currently be supported in three.js
|
|
1027
|
-
case 'emissiveTexture/extensions/KHR_texture_transform/scale':
|
|
1028
|
-
targetProperty = 'emissiveMap/repeat';
|
|
1029
|
-
break;
|
|
1030
|
-
case 'emissiveTexture/extensions/KHR_texture_transform/offset':
|
|
1031
|
-
targetProperty = 'emissiveMap/offset';
|
|
1032
|
-
break;
|
|
1033
|
-
|
|
1034
|
-
// KHR_materials_emissive_strength
|
|
1035
|
-
case 'extensions/KHR_materials_emissive_strength/emissiveStrength':
|
|
1036
|
-
targetProperty = 'emissiveIntensity';
|
|
1037
|
-
break;
|
|
1038
|
-
|
|
1039
|
-
// KHR_materials_transmission
|
|
1040
|
-
case 'extensions/KHR_materials_transmission/transmissionFactor':
|
|
1041
|
-
targetProperty = 'transmission';
|
|
1042
|
-
break;
|
|
1043
|
-
|
|
1044
|
-
// KHR_materials_ior
|
|
1045
|
-
case 'extensions/KHR_materials_ior/ior':
|
|
1046
|
-
targetProperty = 'ior';
|
|
1047
|
-
break;
|
|
1048
|
-
|
|
1049
|
-
// KHR_materials_volume
|
|
1050
|
-
case 'extensions/KHR_materials_volume/thicknessFactor':
|
|
1051
|
-
targetProperty = 'thickness';
|
|
1052
|
-
break;
|
|
1053
|
-
case 'extensions/KHR_materials_volume/attenuationColor':
|
|
1054
|
-
targetProperty = 'attenuationColor';
|
|
1055
|
-
break;
|
|
1056
|
-
case 'extensions/KHR_materials_volume/attenuationDistance':
|
|
1057
|
-
targetProperty = 'attenuationDistance';
|
|
1058
|
-
break;
|
|
1059
|
-
|
|
1060
|
-
// KHR_materials_iridescence
|
|
1061
|
-
case 'extensions/KHR_materials_iridescence/iridescenceFactor':
|
|
1062
|
-
targetProperty = 'iridescence';
|
|
1063
|
-
break;
|
|
1064
|
-
case 'extensions/KHR_materials_iridescence/iridescenceIor':
|
|
1065
|
-
targetProperty = 'iridescenceIOR';
|
|
1066
|
-
break;
|
|
1067
|
-
case 'extensions/KHR_materials_iridescence/iridescenceThicknessMinimum':
|
|
1068
|
-
targetProperty = 'iridescenceThicknessRange[0]';
|
|
1069
|
-
break;
|
|
1070
|
-
case 'extensions/KHR_materials_iridescence/iridescenceThicknessMaximum':
|
|
1071
|
-
targetProperty = 'iridescenceThicknessRange[1]';
|
|
1072
|
-
break;
|
|
1073
|
-
|
|
1074
|
-
// KHR_materials_clearcoat
|
|
1075
|
-
case 'extensions/KHR_materials_clearcoat/clearcoatFactor':
|
|
1076
|
-
targetProperty = 'clearcoat';
|
|
1077
|
-
break;
|
|
1078
|
-
case 'extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor':
|
|
1079
|
-
targetProperty = 'clearcoatRoughness';
|
|
1080
|
-
break;
|
|
1081
|
-
|
|
1082
|
-
// KHR_materials_sheen
|
|
1083
|
-
case 'extensions/KHR_materials_sheen/sheenColorFactor':
|
|
1084
|
-
targetProperty = 'sheenColor';
|
|
1085
|
-
break;
|
|
1086
|
-
case 'extensions/KHR_materials_sheen/sheenRoughnessFactor':
|
|
1087
|
-
targetProperty = 'sheenRoughness';
|
|
1088
|
-
break;
|
|
1089
|
-
|
|
1090
|
-
// KHR_materials_specular
|
|
1091
|
-
case 'extensions/KHR_materials_specular/specularFactor':
|
|
1092
|
-
targetProperty = 'specularIntensity';
|
|
1093
|
-
break;
|
|
1094
|
-
case 'extensions/KHR_materials_specular/specularColorFactor':
|
|
1095
|
-
targetProperty = 'specularColor';
|
|
1096
|
-
break;
|
|
1097
|
-
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
path = pathStart + targetProperty;
|
|
1101
|
-
if ( this._animationPointerDebug ) console.log( 'PROPERTY PATH', pathStart, targetProperty, path );
|
|
1102
|
-
break;
|
|
1103
|
-
|
|
1104
|
-
case this.ANIMATION_TARGET_TYPE.node:
|
|
1105
|
-
const pathIndexNode = ( '/nodes/' + targetId.toString() + '/' ).length;
|
|
1106
|
-
const pathStartNode = path.substring( 0, pathIndexNode );
|
|
1107
|
-
targetProperty = path.substring( pathIndexNode );
|
|
1108
|
-
|
|
1109
|
-
switch ( targetProperty ) {
|
|
1110
|
-
|
|
1111
|
-
case 'translation':
|
|
1112
|
-
targetProperty = 'position';
|
|
1113
|
-
break;
|
|
1114
|
-
case 'rotation':
|
|
1115
|
-
targetProperty = 'quaternion';
|
|
1116
|
-
break;
|
|
1117
|
-
case 'scale':
|
|
1118
|
-
targetProperty = 'scale';
|
|
1119
|
-
break;
|
|
1120
|
-
case 'weights':
|
|
1121
|
-
targetProperty = 'morphTargetInfluences';
|
|
1122
|
-
break;
|
|
1123
|
-
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
|
-
path = pathStartNode + targetProperty;
|
|
1127
|
-
break;
|
|
1128
|
-
|
|
1129
|
-
case this.ANIMATION_TARGET_TYPE.light:
|
|
1130
|
-
const pathIndexLight = ( '/extensions/KHR_lights_punctual/lights/' + targetId.toString() + '/' ).length;
|
|
1131
|
-
targetProperty = path.substring( pathIndexLight );
|
|
1132
|
-
|
|
1133
|
-
switch ( targetProperty ) {
|
|
1134
|
-
|
|
1135
|
-
case 'color':
|
|
1136
|
-
break;
|
|
1137
|
-
case 'intensity':
|
|
1138
|
-
break;
|
|
1139
|
-
case 'spot/innerConeAngle':
|
|
1140
|
-
// TODO would need to set .penumbra, but requires calculations on every animation change (?)
|
|
1141
|
-
targetProperty = 'penumbra';
|
|
1142
|
-
break;
|
|
1143
|
-
case 'spot/outerConeAngle':
|
|
1144
|
-
targetProperty = 'angle';
|
|
1145
|
-
break;
|
|
1146
|
-
case 'range':
|
|
1147
|
-
targetProperty = 'distance';
|
|
1148
|
-
break;
|
|
1149
|
-
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
path = '/lights/' + targetId.toString() + '/' + targetProperty;
|
|
1153
|
-
break;
|
|
1154
|
-
|
|
1155
|
-
case this.ANIMATION_TARGET_TYPE.camera:
|
|
1156
|
-
const pathIndexCamera = ( '/cameras/' + targetId.toString() + '/' ).length;
|
|
1157
|
-
const pathStartCamera = path.substring( 0, pathIndexCamera );
|
|
1158
|
-
targetProperty = path.substring( pathIndexCamera );
|
|
1159
|
-
|
|
1160
|
-
switch ( targetProperty ) {
|
|
1161
|
-
|
|
1162
|
-
case 'perspective/yfov':
|
|
1163
|
-
targetProperty = 'fov';
|
|
1164
|
-
break;
|
|
1165
|
-
case 'perspective/znear':
|
|
1166
|
-
case 'orthographic/znear':
|
|
1167
|
-
targetProperty = 'near';
|
|
1168
|
-
break;
|
|
1169
|
-
case 'perspective/zfar':
|
|
1170
|
-
case 'orthographic/zfar':
|
|
1171
|
-
targetProperty = 'far';
|
|
1172
|
-
break;
|
|
1173
|
-
case 'perspective/aspect':
|
|
1174
|
-
targetProperty = 'aspect';
|
|
1175
|
-
break;
|
|
1176
|
-
// these two write to the same target property since three.js orthographic camera only supports 'zoom'.
|
|
1177
|
-
// TODO should there be a warning for either of them? E.g. a warning for "xmag" so that "yfov" + "ymag" work by default?
|
|
1178
|
-
case 'orthographic/xmag':
|
|
1179
|
-
targetProperty = 'zoom';
|
|
1180
|
-
break;
|
|
1181
|
-
case 'orthographic/ymag':
|
|
1182
|
-
targetProperty = 'zoom';
|
|
1183
|
-
break;
|
|
1184
|
-
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
path = pathStartCamera + targetProperty;
|
|
1188
|
-
break;
|
|
1189
|
-
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
const pointerResolver = this.parser.options.animationPointerResolver;
|
|
1193
|
-
if ( pointerResolver && pointerResolver.resolvePath ) {
|
|
1194
|
-
|
|
1195
|
-
path = pointerResolver.resolvePath( path );
|
|
1196
|
-
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1199
|
-
target.extensions[ EXTENSIONS.KHR_ANIMATION_POINTER ].pointer = path;
|
|
1200
|
-
|
|
1201
|
-
}
|
|
1202
|
-
|
|
1203
|
-
if ( targetId === null || isNaN( targetId ) ) {
|
|
1204
|
-
|
|
1205
|
-
console.warn( 'Failed resolving animation node id: ' + targetId, target );
|
|
1206
|
-
return;
|
|
1207
|
-
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
let depPromise;
|
|
1211
|
-
|
|
1212
|
-
if ( type === this.ANIMATION_TARGET_TYPE.node )
|
|
1213
|
-
depPromise = this.parser.getDependency( 'node', targetId );
|
|
1214
|
-
else if ( type === this.ANIMATION_TARGET_TYPE.material )
|
|
1215
|
-
depPromise = this.parser.getDependency( 'material', targetId );
|
|
1216
|
-
else if ( type === this.ANIMATION_TARGET_TYPE.light )
|
|
1217
|
-
depPromise = this.parser.getDependency( 'light', targetId );
|
|
1218
|
-
else if ( type === this.ANIMATION_TARGET_TYPE.camera )
|
|
1219
|
-
depPromise = this.parser.getDependency( 'camera', targetId );
|
|
1220
|
-
else
|
|
1221
|
-
console.error( 'Unhandled type', type );
|
|
1222
|
-
|
|
1223
|
-
return depPromise;
|
|
1224
|
-
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
createAnimationTracks( node, inputAccessor, outputAccessor, sampler, target ) {
|
|
1228
|
-
|
|
1229
|
-
const useExtension = target.extensions && target.extensions[ EXTENSIONS.KHR_ANIMATION_POINTER ] && target.path && target.path === 'pointer';
|
|
1230
|
-
if ( ! useExtension ) return null;
|
|
1231
|
-
|
|
1232
|
-
let animationPointerPropertyPath = target.extensions[ EXTENSIONS.KHR_ANIMATION_POINTER ].pointer;
|
|
1233
|
-
if ( ! animationPointerPropertyPath ) return null;
|
|
1234
|
-
|
|
1235
|
-
const tracks = [];
|
|
1236
|
-
|
|
1237
|
-
animationPointerPropertyPath = animationPointerPropertyPath.replaceAll( '/', '.' );
|
|
1238
|
-
// replace node/material/camera/light ID by UUID
|
|
1239
|
-
const parts = animationPointerPropertyPath.split( '.' );
|
|
1240
|
-
parts[ 2 ] = node.name ?? node.uuid;
|
|
1241
|
-
animationPointerPropertyPath = parts.join( '.' );
|
|
1242
|
-
if ( this._animationPointerDebug )
|
|
1243
|
-
console.log( node, inputAccessor, outputAccessor, target, animationPointerPropertyPath );
|
|
1244
|
-
|
|
1245
|
-
let TypedKeyframeTrack;
|
|
1246
|
-
|
|
1247
|
-
switch ( outputAccessor.itemSize ) {
|
|
1248
|
-
|
|
1249
|
-
case 1:
|
|
1250
|
-
TypedKeyframeTrack = NumberKeyframeTrack;
|
|
1251
|
-
break;
|
|
1252
|
-
case 2:
|
|
1253
|
-
case 3:
|
|
1254
|
-
TypedKeyframeTrack = VectorKeyframeTrack;
|
|
1255
|
-
break;
|
|
1256
|
-
case 4:
|
|
1257
|
-
|
|
1258
|
-
if ( animationPointerPropertyPath.endsWith( '.quaternion' ) )
|
|
1259
|
-
TypedKeyframeTrack = QuaternionKeyframeTrack;
|
|
1260
|
-
else
|
|
1261
|
-
TypedKeyframeTrack = ColorKeyframeTrack;
|
|
1262
|
-
|
|
1263
|
-
break;
|
|
1264
|
-
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
const interpolation = sampler.interpolation !== undefined ? INTERPOLATION[ sampler.interpolation ] : InterpolateLinear;
|
|
1268
|
-
|
|
1269
|
-
let outputArray = getArrayFromAccessor( outputAccessor );
|
|
1270
|
-
|
|
1271
|
-
// convert fov values from radians to degrees
|
|
1272
|
-
if ( animationPointerPropertyPath.endsWith( '.fov' ) ) {
|
|
1273
|
-
|
|
1274
|
-
outputArray = outputArray.map( value => value / Math.PI * 180 );
|
|
1275
|
-
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
|
-
const track = new TypedKeyframeTrack(
|
|
1279
|
-
animationPointerPropertyPath,
|
|
1280
|
-
inputAccessor.array,
|
|
1281
|
-
outputArray,
|
|
1282
|
-
interpolation
|
|
1283
|
-
);
|
|
1284
|
-
|
|
1285
|
-
// Override interpolation with custom factory method.
|
|
1286
|
-
if ( interpolation === 'CUBICSPLINE' ) {
|
|
1287
|
-
|
|
1288
|
-
createCubicSplineTrackInterpolant( track );
|
|
1289
|
-
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
|
-
tracks.push( track );
|
|
1293
|
-
|
|
1294
|
-
// glTF has opacity animation as last component of baseColorFactor,
|
|
1295
|
-
// so we need to split that up here and create a separate opacity track if that is animated.
|
|
1296
|
-
if ( animationPointerPropertyPath && outputAccessor.itemSize === 4 &&
|
|
1297
|
-
animationPointerPropertyPath.startsWith( '.materials.' ) && animationPointerPropertyPath.endsWith( '.color' ) ) {
|
|
1298
|
-
|
|
1299
|
-
const opacityArray = new Float32Array( outputArray.length / 4 );
|
|
1300
|
-
|
|
1301
|
-
for ( let j = 0, jl = outputArray.length / 4; j < jl; j += 1 ) {
|
|
1302
|
-
|
|
1303
|
-
opacityArray[ j ] = outputArray[ j * 4 + 3 ];
|
|
1304
|
-
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
const opacityTrack = new TypedKeyframeTrack(
|
|
1308
|
-
animationPointerPropertyPath.replace( '.color', '.opacity' ),
|
|
1309
|
-
inputAccessor.array,
|
|
1310
|
-
opacityArray,
|
|
1311
|
-
interpolation
|
|
1312
|
-
);
|
|
1313
|
-
|
|
1314
|
-
// Override interpolation with custom factory method.
|
|
1315
|
-
if ( interpolation === 'CUBICSPLINE' ) {
|
|
1316
|
-
|
|
1317
|
-
createCubicSplineTrackInterpolant( track );
|
|
1318
|
-
|
|
1319
|
-
}
|
|
1320
|
-
|
|
1321
|
-
tracks.push( opacityTrack );
|
|
1322
|
-
|
|
1323
|
-
}
|
|
1324
|
-
|
|
1325
|
-
return tracks;
|
|
1326
|
-
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
_tryResolveTargetId( path, type ) {
|
|
1331
|
-
|
|
1332
|
-
let name = '';
|
|
1333
|
-
if ( type === 'node' ) {
|
|
1334
|
-
|
|
1335
|
-
name = path.substring( '/nodes/'.length );
|
|
1336
|
-
|
|
1337
|
-
} else if ( type === 'material' ) {
|
|
1338
|
-
|
|
1339
|
-
name = path.substring( '/materials/'.length );
|
|
1340
|
-
|
|
1341
|
-
} else if ( type === 'light' ) {
|
|
1342
|
-
|
|
1343
|
-
name = path.substring( '/extensions/KHR_lights_punctual/lights/'.length );
|
|
1344
|
-
|
|
1345
|
-
} else if ( type === 'camera' ) {
|
|
1346
|
-
|
|
1347
|
-
name = path.substring( '/cameras/'.length );
|
|
1348
|
-
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
name = name.substring( 0, name.indexOf( '/' ) );
|
|
1352
|
-
const index = Number.parseInt( name );
|
|
1353
|
-
return index;
|
|
1354
|
-
|
|
1355
|
-
}
|
|
1356
|
-
|
|
1357
|
-
}
|
|
1358
|
-
|
|
1359
808
|
/**
|
|
1360
809
|
* Iridescence Materials Extension
|
|
1361
810
|
*
|
|
@@ -1502,7 +951,7 @@ class GLTFMaterialsSheenExtension {
|
|
|
1502
951
|
|
|
1503
952
|
if ( extension.sheenColorTexture !== undefined ) {
|
|
1504
953
|
|
|
1505
|
-
pending.push( parser.assignTexture( materialParams, 'sheenColorMap', extension.sheenColorTexture,
|
|
954
|
+
pending.push( parser.assignTexture( materialParams, 'sheenColorMap', extension.sheenColorTexture, SRGBColorSpace ) );
|
|
1506
955
|
|
|
1507
956
|
}
|
|
1508
957
|
|
|
@@ -1735,7 +1184,71 @@ class GLTFMaterialsSpecularExtension {
|
|
|
1735
1184
|
|
|
1736
1185
|
if ( extension.specularColorTexture !== undefined ) {
|
|
1737
1186
|
|
|
1738
|
-
pending.push( parser.assignTexture( materialParams, 'specularColorMap', extension.specularColorTexture,
|
|
1187
|
+
pending.push( parser.assignTexture( materialParams, 'specularColorMap', extension.specularColorTexture, SRGBColorSpace ) );
|
|
1188
|
+
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
return Promise.all( pending );
|
|
1192
|
+
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
/**
|
|
1198
|
+
* Materials anisotropy Extension
|
|
1199
|
+
*
|
|
1200
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_anisotropy
|
|
1201
|
+
*/
|
|
1202
|
+
class GLTFMaterialsAnisotropyExtension {
|
|
1203
|
+
|
|
1204
|
+
constructor( parser ) {
|
|
1205
|
+
|
|
1206
|
+
this.parser = parser;
|
|
1207
|
+
this.name = EXTENSIONS.KHR_MATERIALS_ANISOTROPY;
|
|
1208
|
+
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
getMaterialType( materialIndex ) {
|
|
1212
|
+
|
|
1213
|
+
const parser = this.parser;
|
|
1214
|
+
const materialDef = parser.json.materials[ materialIndex ];
|
|
1215
|
+
|
|
1216
|
+
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
|
|
1217
|
+
|
|
1218
|
+
return MeshPhysicalMaterial;
|
|
1219
|
+
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
extendMaterialParams( materialIndex, materialParams ) {
|
|
1223
|
+
|
|
1224
|
+
const parser = this.parser;
|
|
1225
|
+
const materialDef = parser.json.materials[ materialIndex ];
|
|
1226
|
+
|
|
1227
|
+
if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
|
|
1228
|
+
|
|
1229
|
+
return Promise.resolve();
|
|
1230
|
+
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
const pending = [];
|
|
1234
|
+
|
|
1235
|
+
const extension = materialDef.extensions[ this.name ];
|
|
1236
|
+
|
|
1237
|
+
if ( extension.anisotropyStrength !== undefined ) {
|
|
1238
|
+
|
|
1239
|
+
materialParams.anisotropy = extension.anisotropyStrength;
|
|
1240
|
+
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
if ( extension.anisotropyRotation !== undefined ) {
|
|
1244
|
+
|
|
1245
|
+
materialParams.anisotropyRotation = extension.anisotropyRotation;
|
|
1246
|
+
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
if ( extension.anisotropyTexture !== undefined ) {
|
|
1250
|
+
|
|
1251
|
+
pending.push( parser.assignTexture( materialParams, 'anisotropyMap', extension.anisotropyTexture ) );
|
|
1739
1252
|
|
|
1740
1253
|
}
|
|
1741
1254
|
|
|
@@ -1881,6 +1394,89 @@ class GLTFTextureWebPExtension {
|
|
|
1881
1394
|
|
|
1882
1395
|
}
|
|
1883
1396
|
|
|
1397
|
+
/**
|
|
1398
|
+
* AVIF Texture Extension
|
|
1399
|
+
*
|
|
1400
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_avif
|
|
1401
|
+
*/
|
|
1402
|
+
class GLTFTextureAVIFExtension {
|
|
1403
|
+
|
|
1404
|
+
constructor( parser ) {
|
|
1405
|
+
|
|
1406
|
+
this.parser = parser;
|
|
1407
|
+
this.name = EXTENSIONS.EXT_TEXTURE_AVIF;
|
|
1408
|
+
this.isSupported = null;
|
|
1409
|
+
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
loadTexture( textureIndex ) {
|
|
1413
|
+
|
|
1414
|
+
const name = this.name;
|
|
1415
|
+
const parser = this.parser;
|
|
1416
|
+
const json = parser.json;
|
|
1417
|
+
|
|
1418
|
+
const textureDef = json.textures[ textureIndex ];
|
|
1419
|
+
|
|
1420
|
+
if ( ! textureDef.extensions || ! textureDef.extensions[ name ] ) {
|
|
1421
|
+
|
|
1422
|
+
return null;
|
|
1423
|
+
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
const extension = textureDef.extensions[ name ];
|
|
1427
|
+
const source = json.images[ extension.source ];
|
|
1428
|
+
|
|
1429
|
+
let loader = parser.textureLoader;
|
|
1430
|
+
if ( source.uri ) {
|
|
1431
|
+
|
|
1432
|
+
const handler = parser.options.manager.getHandler( source.uri );
|
|
1433
|
+
if ( handler !== null ) loader = handler;
|
|
1434
|
+
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
return this.detectSupport().then( function ( isSupported ) {
|
|
1438
|
+
|
|
1439
|
+
if ( isSupported ) return parser.loadTextureImage( textureIndex, extension.source, loader );
|
|
1440
|
+
|
|
1441
|
+
if ( json.extensionsRequired && json.extensionsRequired.indexOf( name ) >= 0 ) {
|
|
1442
|
+
|
|
1443
|
+
throw new Error( 'THREE.GLTFLoader: AVIF required by asset but unsupported.' );
|
|
1444
|
+
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
// Fall back to PNG or JPEG.
|
|
1448
|
+
return parser.loadTexture( textureIndex );
|
|
1449
|
+
|
|
1450
|
+
} );
|
|
1451
|
+
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
detectSupport() {
|
|
1455
|
+
|
|
1456
|
+
if ( ! this.isSupported ) {
|
|
1457
|
+
|
|
1458
|
+
this.isSupported = new Promise( function ( resolve ) {
|
|
1459
|
+
|
|
1460
|
+
const image = new Image();
|
|
1461
|
+
|
|
1462
|
+
// Lossy test image.
|
|
1463
|
+
image.src = 'data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=';
|
|
1464
|
+
image.onload = image.onerror = function () {
|
|
1465
|
+
|
|
1466
|
+
resolve( image.height === 1 );
|
|
1467
|
+
|
|
1468
|
+
};
|
|
1469
|
+
|
|
1470
|
+
} );
|
|
1471
|
+
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
return this.isSupported;
|
|
1475
|
+
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1884
1480
|
/**
|
|
1885
1481
|
* meshopt BufferView Compression Extension
|
|
1886
1482
|
*
|
|
@@ -2093,8 +1689,6 @@ class GLTFMeshGpuInstancing {
|
|
|
2093
1689
|
// Just in case
|
|
2094
1690
|
Object3D.prototype.copy.call( instancedMesh, mesh );
|
|
2095
1691
|
|
|
2096
|
-
// https://github.com/mrdoob/three.js/issues/18334
|
|
2097
|
-
instancedMesh.frustumCulled = false;
|
|
2098
1692
|
this.parser.assignFinalMaterial( instancedMesh );
|
|
2099
1693
|
|
|
2100
1694
|
instancedMeshes.push( instancedMesh );
|
|
@@ -2133,9 +1727,10 @@ class GLTFBinaryExtension {
|
|
|
2133
1727
|
this.body = null;
|
|
2134
1728
|
|
|
2135
1729
|
const headerView = new DataView( data, 0, BINARY_EXTENSION_HEADER_LENGTH );
|
|
1730
|
+
const textDecoder = new TextDecoder();
|
|
2136
1731
|
|
|
2137
1732
|
this.header = {
|
|
2138
|
-
magic:
|
|
1733
|
+
magic: textDecoder.decode( new Uint8Array( data.slice( 0, 4 ) ) ),
|
|
2139
1734
|
version: headerView.getUint32( 4, true ),
|
|
2140
1735
|
length: headerView.getUint32( 8, true )
|
|
2141
1736
|
};
|
|
@@ -2165,7 +1760,7 @@ class GLTFBinaryExtension {
|
|
|
2165
1760
|
if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.JSON ) {
|
|
2166
1761
|
|
|
2167
1762
|
const contentArray = new Uint8Array( data, BINARY_EXTENSION_HEADER_LENGTH + chunkIndex, chunkLength );
|
|
2168
|
-
this.content =
|
|
1763
|
+
this.content = textDecoder.decode( contentArray );
|
|
2169
1764
|
|
|
2170
1765
|
} else if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.BIN ) {
|
|
2171
1766
|
|
|
@@ -2288,13 +1883,10 @@ class GLTFTextureTransformExtension {
|
|
|
2288
1883
|
|
|
2289
1884
|
extendTexture( texture, transform ) {
|
|
2290
1885
|
|
|
2291
|
-
if ( transform.texCoord
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
}
|
|
2296
|
-
|
|
2297
|
-
if ( transform.offset === undefined && transform.rotation === undefined && transform.scale === undefined ) {
|
|
1886
|
+
if ( ( transform.texCoord === undefined || transform.texCoord === texture.channel )
|
|
1887
|
+
&& transform.offset === undefined
|
|
1888
|
+
&& transform.rotation === undefined
|
|
1889
|
+
&& transform.scale === undefined ) {
|
|
2298
1890
|
|
|
2299
1891
|
// See https://github.com/mrdoob/three.js/issues/21819.
|
|
2300
1892
|
return texture;
|
|
@@ -2303,6 +1895,12 @@ class GLTFTextureTransformExtension {
|
|
|
2303
1895
|
|
|
2304
1896
|
texture = texture.clone();
|
|
2305
1897
|
|
|
1898
|
+
if ( transform.texCoord !== undefined ) {
|
|
1899
|
+
|
|
1900
|
+
texture.channel = transform.texCoord;
|
|
1901
|
+
|
|
1902
|
+
}
|
|
1903
|
+
|
|
2306
1904
|
if ( transform.offset !== undefined ) {
|
|
2307
1905
|
|
|
2308
1906
|
texture.offset.fromArray( transform.offset );
|
|
@@ -2504,7 +2102,9 @@ const ATTRIBUTES = {
|
|
|
2504
2102
|
NORMAL: 'normal',
|
|
2505
2103
|
TANGENT: 'tangent',
|
|
2506
2104
|
TEXCOORD_0: 'uv',
|
|
2507
|
-
TEXCOORD_1: '
|
|
2105
|
+
TEXCOORD_1: 'uv1',
|
|
2106
|
+
TEXCOORD_2: 'uv2',
|
|
2107
|
+
TEXCOORD_3: 'uv3',
|
|
2508
2108
|
COLOR_0: 'color',
|
|
2509
2109
|
WEIGHTS_0: 'skinWeight',
|
|
2510
2110
|
JOINTS_0: 'skinIndex',
|
|
@@ -2726,18 +2326,29 @@ function updateMorphTargets( mesh, meshDef ) {
|
|
|
2726
2326
|
|
|
2727
2327
|
function createPrimitiveKey( primitiveDef ) {
|
|
2728
2328
|
|
|
2729
|
-
const dracoExtension = primitiveDef.extensions && primitiveDef.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ];
|
|
2730
2329
|
let geometryKey;
|
|
2731
2330
|
|
|
2331
|
+
const dracoExtension = primitiveDef.extensions && primitiveDef.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ];
|
|
2332
|
+
|
|
2732
2333
|
if ( dracoExtension ) {
|
|
2733
2334
|
|
|
2734
2335
|
geometryKey = 'draco:' + dracoExtension.bufferView
|
|
2735
2336
|
+ ':' + dracoExtension.indices
|
|
2736
2337
|
+ ':' + createAttributesKey( dracoExtension.attributes );
|
|
2737
2338
|
|
|
2738
|
-
} else {
|
|
2339
|
+
} else {
|
|
2340
|
+
|
|
2341
|
+
geometryKey = primitiveDef.indices + ':' + createAttributesKey( primitiveDef.attributes ) + ':' + primitiveDef.mode;
|
|
2342
|
+
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2345
|
+
if ( primitiveDef.targets !== undefined ) {
|
|
2739
2346
|
|
|
2740
|
-
|
|
2347
|
+
for ( let i = 0, il = primitiveDef.targets.length; i < il; i ++ ) {
|
|
2348
|
+
|
|
2349
|
+
geometryKey += ':' + createAttributesKey( primitiveDef.targets[ i ] );
|
|
2350
|
+
|
|
2351
|
+
}
|
|
2741
2352
|
|
|
2742
2353
|
}
|
|
2743
2354
|
|
|
@@ -2787,48 +2398,6 @@ function getNormalizedComponentScale( constructor ) {
|
|
|
2787
2398
|
|
|
2788
2399
|
}
|
|
2789
2400
|
|
|
2790
|
-
function getArrayFromAccessor( accessor ) {
|
|
2791
|
-
|
|
2792
|
-
let outputArray = accessor.array;
|
|
2793
|
-
|
|
2794
|
-
if ( accessor.normalized ) {
|
|
2795
|
-
|
|
2796
|
-
const scale = getNormalizedComponentScale( outputArray.constructor );
|
|
2797
|
-
const scaled = new Float32Array( outputArray.length );
|
|
2798
|
-
|
|
2799
|
-
for ( let j = 0, jl = outputArray.length; j < jl; j ++ ) {
|
|
2800
|
-
|
|
2801
|
-
scaled[ j ] = outputArray[ j ] * scale;
|
|
2802
|
-
|
|
2803
|
-
}
|
|
2804
|
-
|
|
2805
|
-
outputArray = scaled;
|
|
2806
|
-
|
|
2807
|
-
}
|
|
2808
|
-
|
|
2809
|
-
return outputArray;
|
|
2810
|
-
|
|
2811
|
-
}
|
|
2812
|
-
|
|
2813
|
-
function createCubicSplineTrackInterpolant( track ) {
|
|
2814
|
-
|
|
2815
|
-
track.createInterpolant = function InterpolantFactoryMethodGLTFCubicSpline( result ) {
|
|
2816
|
-
|
|
2817
|
-
// A CUBICSPLINE keyframe in glTF has three output values for each input value,
|
|
2818
|
-
// representing inTangent, splineVertex, and outTangent. As a result, track.getValueSize()
|
|
2819
|
-
// must be divided by three to get the interpolant's sampleSize argument.
|
|
2820
|
-
|
|
2821
|
-
const interpolantType = ( this instanceof QuaternionKeyframeTrack ) ? GLTFCubicSplineQuaternionInterpolant : GLTFCubicSplineInterpolant;
|
|
2822
|
-
|
|
2823
|
-
return new interpolantType( this.times, this.values, this.getValueSize() / 3, result );
|
|
2824
|
-
|
|
2825
|
-
};
|
|
2826
|
-
|
|
2827
|
-
// Mark as CUBICSPLINE. `track.getInterpolation()` doesn't support custom interpolants.
|
|
2828
|
-
track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true;
|
|
2829
|
-
|
|
2830
|
-
}
|
|
2831
|
-
|
|
2832
2401
|
function getImageURIMimeType( uri ) {
|
|
2833
2402
|
|
|
2834
2403
|
if ( uri.search( /\.jpe?g($|\?)/i ) > 0 || uri.search( /^data\:image\/jpeg/ ) === 0 ) return 'image/jpeg';
|
|
@@ -2838,6 +2407,8 @@ function getImageURIMimeType( uri ) {
|
|
|
2838
2407
|
|
|
2839
2408
|
}
|
|
2840
2409
|
|
|
2410
|
+
const _identityMatrix = new Matrix4();
|
|
2411
|
+
|
|
2841
2412
|
/* GLTF PARSER */
|
|
2842
2413
|
|
|
2843
2414
|
class GLTFParser {
|
|
@@ -2858,6 +2429,9 @@ class GLTFParser {
|
|
|
2858
2429
|
// BufferGeometry caching
|
|
2859
2430
|
this.primitiveCache = {};
|
|
2860
2431
|
|
|
2432
|
+
// Node cache
|
|
2433
|
+
this.nodeCache = {};
|
|
2434
|
+
|
|
2861
2435
|
// Object3D instance caches
|
|
2862
2436
|
this.meshCache = { refs: {}, uses: {} };
|
|
2863
2437
|
this.cameraCache = { refs: {}, uses: {} };
|
|
@@ -2928,6 +2502,7 @@ class GLTFParser {
|
|
|
2928
2502
|
|
|
2929
2503
|
// Clear the loader cache
|
|
2930
2504
|
this.cache.removeAll();
|
|
2505
|
+
this.nodeCache = {};
|
|
2931
2506
|
|
|
2932
2507
|
// Mark the special nodes/meshes in json for efficient parse
|
|
2933
2508
|
this._invokeAll( function ( ext ) {
|
|
@@ -3147,7 +2722,11 @@ class GLTFParser {
|
|
|
3147
2722
|
break;
|
|
3148
2723
|
|
|
3149
2724
|
case 'node':
|
|
3150
|
-
dependency = this.
|
|
2725
|
+
dependency = this._invokeOne( function ( ext ) {
|
|
2726
|
+
|
|
2727
|
+
return ext.loadNode && ext.loadNode( index );
|
|
2728
|
+
|
|
2729
|
+
} );
|
|
3151
2730
|
break;
|
|
3152
2731
|
|
|
3153
2732
|
case 'mesh':
|
|
@@ -3206,14 +2785,6 @@ class GLTFParser {
|
|
|
3206
2785
|
dependency = this.loadCamera( index );
|
|
3207
2786
|
break;
|
|
3208
2787
|
|
|
3209
|
-
case 'light':
|
|
3210
|
-
dependency = this._invokeOne( function ( ext ) {
|
|
3211
|
-
|
|
3212
|
-
return ext._loadLight && ext._loadLight( index );
|
|
3213
|
-
|
|
3214
|
-
} );
|
|
3215
|
-
break;
|
|
3216
|
-
|
|
3217
2788
|
default:
|
|
3218
2789
|
dependency = this._invokeOne( function ( ext ) {
|
|
3219
2790
|
|
|
@@ -3460,7 +3031,7 @@ class GLTFParser {
|
|
|
3460
3031
|
/**
|
|
3461
3032
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
|
|
3462
3033
|
* @param {number} textureIndex
|
|
3463
|
-
* @return {Promise<THREE.Texture>}
|
|
3034
|
+
* @return {Promise<THREE.Texture|null>}
|
|
3464
3035
|
*/
|
|
3465
3036
|
loadTexture( textureIndex ) {
|
|
3466
3037
|
|
|
@@ -3506,6 +3077,12 @@ class GLTFParser {
|
|
|
3506
3077
|
|
|
3507
3078
|
texture.name = textureDef.name || sourceDef.name || '';
|
|
3508
3079
|
|
|
3080
|
+
if ( texture.name === '' && typeof sourceDef.uri === 'string' && sourceDef.uri.startsWith( 'data:image/' ) === false ) {
|
|
3081
|
+
|
|
3082
|
+
texture.name = sourceDef.uri;
|
|
3083
|
+
|
|
3084
|
+
}
|
|
3085
|
+
|
|
3509
3086
|
const samplers = json.samplers || {};
|
|
3510
3087
|
const sampler = samplers[ textureDef.sampler ] || {};
|
|
3511
3088
|
|
|
@@ -3625,17 +3202,18 @@ class GLTFParser {
|
|
|
3625
3202
|
* @param {Object} mapDef
|
|
3626
3203
|
* @return {Promise<Texture>}
|
|
3627
3204
|
*/
|
|
3628
|
-
assignTexture( materialParams, mapName, mapDef,
|
|
3205
|
+
assignTexture( materialParams, mapName, mapDef, colorSpace ) {
|
|
3629
3206
|
|
|
3630
3207
|
const parser = this;
|
|
3631
3208
|
|
|
3632
3209
|
return this.getDependency( 'texture', mapDef.index ).then( function ( texture ) {
|
|
3633
3210
|
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
if ( mapDef.texCoord !== undefined && mapDef.texCoord
|
|
3211
|
+
if ( ! texture ) return null;
|
|
3212
|
+
|
|
3213
|
+
if ( mapDef.texCoord !== undefined && mapDef.texCoord > 0 ) {
|
|
3637
3214
|
|
|
3638
|
-
|
|
3215
|
+
texture = texture.clone();
|
|
3216
|
+
texture.channel = mapDef.texCoord;
|
|
3639
3217
|
|
|
3640
3218
|
}
|
|
3641
3219
|
|
|
@@ -3653,9 +3231,9 @@ class GLTFParser {
|
|
|
3653
3231
|
|
|
3654
3232
|
}
|
|
3655
3233
|
|
|
3656
|
-
if (
|
|
3234
|
+
if ( colorSpace !== undefined ) {
|
|
3657
3235
|
|
|
3658
|
-
texture.
|
|
3236
|
+
texture.colorSpace = colorSpace;
|
|
3659
3237
|
|
|
3660
3238
|
}
|
|
3661
3239
|
|
|
@@ -3715,6 +3293,7 @@ class GLTFParser {
|
|
|
3715
3293
|
lineMaterial = new LineBasicMaterial();
|
|
3716
3294
|
Material.prototype.copy.call( lineMaterial, material );
|
|
3717
3295
|
lineMaterial.color.copy( material.color );
|
|
3296
|
+
lineMaterial.map = material.map;
|
|
3718
3297
|
|
|
3719
3298
|
this.cache.add( cacheKey, lineMaterial );
|
|
3720
3299
|
|
|
@@ -3760,14 +3339,6 @@ class GLTFParser {
|
|
|
3760
3339
|
|
|
3761
3340
|
}
|
|
3762
3341
|
|
|
3763
|
-
// workarounds for mesh and geometry
|
|
3764
|
-
|
|
3765
|
-
if ( material.aoMap && geometry.attributes.uv2 === undefined && geometry.attributes.uv !== undefined ) {
|
|
3766
|
-
|
|
3767
|
-
geometry.setAttribute( 'uv2', geometry.attributes.uv );
|
|
3768
|
-
|
|
3769
|
-
}
|
|
3770
|
-
|
|
3771
3342
|
mesh.material = material;
|
|
3772
3343
|
|
|
3773
3344
|
}
|
|
@@ -3823,7 +3394,7 @@ class GLTFParser {
|
|
|
3823
3394
|
|
|
3824
3395
|
if ( metallicRoughness.baseColorTexture !== undefined ) {
|
|
3825
3396
|
|
|
3826
|
-
pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture,
|
|
3397
|
+
pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture, SRGBColorSpace ) );
|
|
3827
3398
|
|
|
3828
3399
|
}
|
|
3829
3400
|
|
|
@@ -3914,7 +3485,7 @@ class GLTFParser {
|
|
|
3914
3485
|
|
|
3915
3486
|
if ( materialDef.emissiveTexture !== undefined && materialType !== MeshBasicMaterial ) {
|
|
3916
3487
|
|
|
3917
|
-
pending.push( parser.assignTexture( materialParams, 'emissiveMap', materialDef.emissiveTexture,
|
|
3488
|
+
pending.push( parser.assignTexture( materialParams, 'emissiveMap', materialDef.emissiveTexture, SRGBColorSpace ) );
|
|
3918
3489
|
|
|
3919
3490
|
}
|
|
3920
3491
|
|
|
@@ -3941,17 +3512,17 @@ class GLTFParser {
|
|
|
3941
3512
|
|
|
3942
3513
|
const sanitizedName = PropertyBinding.sanitizeNodeName( originalName || '' );
|
|
3943
3514
|
|
|
3944
|
-
|
|
3515
|
+
if ( sanitizedName in this.nodeNamesUsed ) {
|
|
3945
3516
|
|
|
3946
|
-
|
|
3517
|
+
return sanitizedName + '_' + ( ++ this.nodeNamesUsed[ sanitizedName ] );
|
|
3947
3518
|
|
|
3948
|
-
|
|
3519
|
+
} else {
|
|
3949
3520
|
|
|
3950
|
-
|
|
3521
|
+
this.nodeNamesUsed[ sanitizedName ] = 0;
|
|
3951
3522
|
|
|
3952
|
-
|
|
3523
|
+
return sanitizedName;
|
|
3953
3524
|
|
|
3954
|
-
|
|
3525
|
+
}
|
|
3955
3526
|
|
|
3956
3527
|
}
|
|
3957
3528
|
|
|
@@ -4081,10 +3652,9 @@ class GLTFParser {
|
|
|
4081
3652
|
? new SkinnedMesh( geometry, material )
|
|
4082
3653
|
: new Mesh( geometry, material );
|
|
4083
3654
|
|
|
4084
|
-
if ( mesh.isSkinnedMesh === true
|
|
3655
|
+
if ( mesh.isSkinnedMesh === true ) {
|
|
4085
3656
|
|
|
4086
|
-
//
|
|
4087
|
-
// it's important to skip this for non-float32 data since normalizeSkinWeights assumes non-normalized inputs
|
|
3657
|
+
// normalize skin weights to fix malformed assets (see #15319)
|
|
4088
3658
|
mesh.normalizeSkinWeights();
|
|
4089
3659
|
|
|
4090
3660
|
}
|
|
@@ -4150,12 +3720,16 @@ class GLTFParser {
|
|
|
4150
3720
|
|
|
4151
3721
|
if ( meshes.length === 1 ) {
|
|
4152
3722
|
|
|
3723
|
+
if ( meshDef.extensions ) addUnknownExtensionsToUserData( extensions, meshes[ 0 ], meshDef );
|
|
3724
|
+
|
|
4153
3725
|
return meshes[ 0 ];
|
|
4154
3726
|
|
|
4155
3727
|
}
|
|
4156
3728
|
|
|
4157
3729
|
const group = new Group();
|
|
4158
3730
|
|
|
3731
|
+
if ( meshDef.extensions ) addUnknownExtensionsToUserData( extensions, group, meshDef );
|
|
3732
|
+
|
|
4159
3733
|
parser.associations.set( group, { meshes: meshIndex } );
|
|
4160
3734
|
|
|
4161
3735
|
for ( let i = 0, il = meshes.length; i < il; i ++ ) {
|
|
@@ -4209,25 +3783,68 @@ class GLTFParser {
|
|
|
4209
3783
|
/**
|
|
4210
3784
|
* Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
|
|
4211
3785
|
* @param {number} skinIndex
|
|
4212
|
-
* @return {Promise<
|
|
3786
|
+
* @return {Promise<Skeleton>}
|
|
4213
3787
|
*/
|
|
4214
3788
|
loadSkin( skinIndex ) {
|
|
4215
3789
|
|
|
4216
3790
|
const skinDef = this.json.skins[ skinIndex ];
|
|
4217
3791
|
|
|
4218
|
-
const
|
|
3792
|
+
const pending = [];
|
|
3793
|
+
|
|
3794
|
+
for ( let i = 0, il = skinDef.joints.length; i < il; i ++ ) {
|
|
3795
|
+
|
|
3796
|
+
pending.push( this._loadNodeShallow( skinDef.joints[ i ] ) );
|
|
3797
|
+
|
|
3798
|
+
}
|
|
3799
|
+
|
|
3800
|
+
if ( skinDef.inverseBindMatrices !== undefined ) {
|
|
4219
3801
|
|
|
4220
|
-
|
|
3802
|
+
pending.push( this.getDependency( 'accessor', skinDef.inverseBindMatrices ) );
|
|
3803
|
+
|
|
3804
|
+
} else {
|
|
4221
3805
|
|
|
4222
|
-
|
|
3806
|
+
pending.push( null );
|
|
4223
3807
|
|
|
4224
3808
|
}
|
|
4225
3809
|
|
|
4226
|
-
return
|
|
3810
|
+
return Promise.all( pending ).then( function ( results ) {
|
|
3811
|
+
|
|
3812
|
+
const inverseBindMatrices = results.pop();
|
|
3813
|
+
const jointNodes = results;
|
|
3814
|
+
|
|
3815
|
+
// Note that bones (joint nodes) may or may not be in the
|
|
3816
|
+
// scene graph at this time.
|
|
3817
|
+
|
|
3818
|
+
const bones = [];
|
|
3819
|
+
const boneInverses = [];
|
|
3820
|
+
|
|
3821
|
+
for ( let i = 0, il = jointNodes.length; i < il; i ++ ) {
|
|
3822
|
+
|
|
3823
|
+
const jointNode = jointNodes[ i ];
|
|
3824
|
+
|
|
3825
|
+
if ( jointNode ) {
|
|
3826
|
+
|
|
3827
|
+
bones.push( jointNode );
|
|
3828
|
+
|
|
3829
|
+
const mat = new Matrix4();
|
|
3830
|
+
|
|
3831
|
+
if ( inverseBindMatrices !== null ) {
|
|
3832
|
+
|
|
3833
|
+
mat.fromArray( inverseBindMatrices.array, i * 16 );
|
|
3834
|
+
|
|
3835
|
+
}
|
|
3836
|
+
|
|
3837
|
+
boneInverses.push( mat );
|
|
3838
|
+
|
|
3839
|
+
} else {
|
|
4227
3840
|
|
|
4228
|
-
|
|
3841
|
+
console.warn( 'THREE.GLTFLoader: Joint "%s" could not be found.', skinDef.joints[ i ] );
|
|
4229
3842
|
|
|
4230
|
-
|
|
3843
|
+
}
|
|
3844
|
+
|
|
3845
|
+
}
|
|
3846
|
+
|
|
3847
|
+
return new Skeleton( bones, boneInverses );
|
|
4231
3848
|
|
|
4232
3849
|
} );
|
|
4233
3850
|
|
|
@@ -4244,6 +3861,7 @@ class GLTFParser {
|
|
|
4244
3861
|
const parser = this;
|
|
4245
3862
|
|
|
4246
3863
|
const animationDef = json.animations[ animationIndex ];
|
|
3864
|
+
const animationName = animationDef.name ? animationDef.name : 'animation_' + animationIndex;
|
|
4247
3865
|
|
|
4248
3866
|
const pendingNodes = [];
|
|
4249
3867
|
const pendingInputAccessors = [];
|
|
@@ -4257,16 +3875,13 @@ class GLTFParser {
|
|
|
4257
3875
|
const channel = animationDef.channels[ i ];
|
|
4258
3876
|
const sampler = animationDef.samplers[ channel.sampler ];
|
|
4259
3877
|
const target = channel.target;
|
|
3878
|
+
const name = target.node;
|
|
4260
3879
|
const input = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.input ] : sampler.input;
|
|
4261
3880
|
const output = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.output ] : sampler.output;
|
|
4262
3881
|
|
|
4263
|
-
|
|
3882
|
+
if ( target.node === undefined ) continue;
|
|
4264
3883
|
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
} );
|
|
4268
|
-
|
|
4269
|
-
pendingNodes.push( nodeDependency );
|
|
3884
|
+
pendingNodes.push( this.getDependency( 'node', name ) );
|
|
4270
3885
|
pendingInputAccessors.push( this.getDependency( 'accessor', input ) );
|
|
4271
3886
|
pendingOutputAccessors.push( this.getDependency( 'accessor', output ) );
|
|
4272
3887
|
pendingSamplers.push( sampler );
|
|
@@ -4309,11 +3924,7 @@ class GLTFParser {
|
|
|
4309
3924
|
|
|
4310
3925
|
}
|
|
4311
3926
|
|
|
4312
|
-
const createdTracks = parser.
|
|
4313
|
-
|
|
4314
|
-
return ext.createAnimationTracks && ext.createAnimationTracks( node, inputAccessor, outputAccessor, sampler, target );
|
|
4315
|
-
|
|
4316
|
-
} );
|
|
3927
|
+
const createdTracks = parser._createAnimationTracks( node, inputAccessor, outputAccessor, sampler, target );
|
|
4317
3928
|
|
|
4318
3929
|
if ( createdTracks ) {
|
|
4319
3930
|
|
|
@@ -4327,9 +3938,7 @@ class GLTFParser {
|
|
|
4327
3938
|
|
|
4328
3939
|
}
|
|
4329
3940
|
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
return new AnimationClip( name, undefined, tracks );
|
|
3941
|
+
return new AnimationClip( animationName, undefined, tracks );
|
|
4333
3942
|
|
|
4334
3943
|
} );
|
|
4335
3944
|
|
|
@@ -4378,53 +3987,118 @@ class GLTFParser {
|
|
|
4378
3987
|
loadNode( nodeIndex ) {
|
|
4379
3988
|
|
|
4380
3989
|
const json = this.json;
|
|
4381
|
-
const extensions = this.extensions;
|
|
4382
3990
|
const parser = this;
|
|
4383
3991
|
|
|
4384
3992
|
const nodeDef = json.nodes[ nodeIndex ];
|
|
4385
3993
|
|
|
4386
|
-
|
|
4387
|
-
const nodeName = nodeDef.name ? parser.createUniqueName( nodeDef.name ) : '';
|
|
3994
|
+
const nodePending = parser._loadNodeShallow( nodeIndex );
|
|
4388
3995
|
|
|
4389
|
-
|
|
3996
|
+
const childPending = [];
|
|
3997
|
+
const childrenDef = nodeDef.children || [];
|
|
4390
3998
|
|
|
4391
|
-
|
|
3999
|
+
for ( let i = 0, il = childrenDef.length; i < il; i ++ ) {
|
|
4392
4000
|
|
|
4393
|
-
|
|
4001
|
+
childPending.push( parser.getDependency( 'node', childrenDef[ i ] ) );
|
|
4394
4002
|
|
|
4395
|
-
|
|
4003
|
+
}
|
|
4396
4004
|
|
|
4397
|
-
|
|
4005
|
+
const skeletonPending = nodeDef.skin === undefined
|
|
4006
|
+
? Promise.resolve( null )
|
|
4007
|
+
: parser.getDependency( 'skin', nodeDef.skin );
|
|
4398
4008
|
|
|
4399
|
-
|
|
4009
|
+
return Promise.all( [
|
|
4010
|
+
nodePending,
|
|
4011
|
+
Promise.all( childPending ),
|
|
4012
|
+
skeletonPending
|
|
4013
|
+
] ).then( function ( results ) {
|
|
4400
4014
|
|
|
4401
|
-
|
|
4015
|
+
const node = results[ 0 ];
|
|
4016
|
+
const children = results[ 1 ];
|
|
4017
|
+
const skeleton = results[ 2 ];
|
|
4402
4018
|
|
|
4403
|
-
|
|
4019
|
+
if ( skeleton !== null ) {
|
|
4404
4020
|
|
|
4405
|
-
|
|
4021
|
+
// This full traverse should be fine because
|
|
4022
|
+
// child glTF nodes have not been added to this node yet.
|
|
4023
|
+
node.traverse( function ( mesh ) {
|
|
4406
4024
|
|
|
4407
|
-
|
|
4025
|
+
if ( ! mesh.isSkinnedMesh ) return;
|
|
4408
4026
|
|
|
4409
|
-
|
|
4027
|
+
mesh.bind( skeleton, _identityMatrix );
|
|
4410
4028
|
|
|
4411
|
-
} )
|
|
4029
|
+
} );
|
|
4412
4030
|
|
|
4413
4031
|
}
|
|
4414
4032
|
|
|
4415
|
-
|
|
4033
|
+
for ( let i = 0, il = children.length; i < il; i ++ ) {
|
|
4416
4034
|
|
|
4417
|
-
|
|
4035
|
+
node.add( children[ i ] );
|
|
4418
4036
|
|
|
4419
|
-
}
|
|
4037
|
+
}
|
|
4420
4038
|
|
|
4421
|
-
|
|
4039
|
+
return node;
|
|
4422
4040
|
|
|
4423
|
-
|
|
4041
|
+
} );
|
|
4042
|
+
|
|
4043
|
+
}
|
|
4044
|
+
|
|
4045
|
+
// ._loadNodeShallow() parses a single node.
|
|
4046
|
+
// skin and child nodes are created and added in .loadNode() (no '_' prefix).
|
|
4047
|
+
_loadNodeShallow( nodeIndex ) {
|
|
4048
|
+
|
|
4049
|
+
const json = this.json;
|
|
4050
|
+
const extensions = this.extensions;
|
|
4051
|
+
const parser = this;
|
|
4052
|
+
|
|
4053
|
+
// This method is called from .loadNode() and .loadSkin().
|
|
4054
|
+
// Cache a node to avoid duplication.
|
|
4055
|
+
|
|
4056
|
+
if ( this.nodeCache[ nodeIndex ] !== undefined ) {
|
|
4057
|
+
|
|
4058
|
+
return this.nodeCache[ nodeIndex ];
|
|
4059
|
+
|
|
4060
|
+
}
|
|
4061
|
+
|
|
4062
|
+
const nodeDef = json.nodes[ nodeIndex ];
|
|
4063
|
+
|
|
4064
|
+
// reserve node's name before its dependencies, so the root has the intended name.
|
|
4065
|
+
const nodeName = nodeDef.name ? parser.createUniqueName( nodeDef.name ) : '';
|
|
4066
|
+
|
|
4067
|
+
const pending = [];
|
|
4068
|
+
|
|
4069
|
+
const meshPromise = parser._invokeOne( function ( ext ) {
|
|
4070
|
+
|
|
4071
|
+
return ext.createNodeMesh && ext.createNodeMesh( nodeIndex );
|
|
4072
|
+
|
|
4073
|
+
} );
|
|
4424
4074
|
|
|
4425
|
-
|
|
4075
|
+
if ( meshPromise ) {
|
|
4426
4076
|
|
|
4427
|
-
|
|
4077
|
+
pending.push( meshPromise );
|
|
4078
|
+
|
|
4079
|
+
}
|
|
4080
|
+
|
|
4081
|
+
if ( nodeDef.camera !== undefined ) {
|
|
4082
|
+
|
|
4083
|
+
pending.push( parser.getDependency( 'camera', nodeDef.camera ).then( function ( camera ) {
|
|
4084
|
+
|
|
4085
|
+
return parser._getNodeRef( parser.cameraCache, nodeDef.camera, camera );
|
|
4086
|
+
|
|
4087
|
+
} ) );
|
|
4088
|
+
|
|
4089
|
+
}
|
|
4090
|
+
|
|
4091
|
+
parser._invokeAll( function ( ext ) {
|
|
4092
|
+
|
|
4093
|
+
return ext.createNodeAttachment && ext.createNodeAttachment( nodeIndex );
|
|
4094
|
+
|
|
4095
|
+
} ).forEach( function ( promise ) {
|
|
4096
|
+
|
|
4097
|
+
pending.push( promise );
|
|
4098
|
+
|
|
4099
|
+
} );
|
|
4100
|
+
|
|
4101
|
+
this.nodeCache[ nodeIndex ] = Promise.all( pending ).then( function ( objects ) {
|
|
4428
4102
|
|
|
4429
4103
|
let node;
|
|
4430
4104
|
|
|
@@ -4508,6 +4182,8 @@ class GLTFParser {
|
|
|
4508
4182
|
|
|
4509
4183
|
} );
|
|
4510
4184
|
|
|
4185
|
+
return this.nodeCache[ nodeIndex ];
|
|
4186
|
+
|
|
4511
4187
|
}
|
|
4512
4188
|
|
|
4513
4189
|
/**
|
|
@@ -4517,7 +4193,6 @@ class GLTFParser {
|
|
|
4517
4193
|
*/
|
|
4518
4194
|
loadScene( sceneIndex ) {
|
|
4519
4195
|
|
|
4520
|
-
const json = this.json;
|
|
4521
4196
|
const extensions = this.extensions;
|
|
4522
4197
|
const sceneDef = this.json.scenes[ sceneIndex ];
|
|
4523
4198
|
const parser = this;
|
|
@@ -4537,11 +4212,17 @@ class GLTFParser {
|
|
|
4537
4212
|
|
|
4538
4213
|
for ( let i = 0, il = nodeIds.length; i < il; i ++ ) {
|
|
4539
4214
|
|
|
4540
|
-
pending.push(
|
|
4215
|
+
pending.push( parser.getDependency( 'node', nodeIds[ i ] ) );
|
|
4541
4216
|
|
|
4542
4217
|
}
|
|
4543
4218
|
|
|
4544
|
-
return Promise.all( pending ).then( function () {
|
|
4219
|
+
return Promise.all( pending ).then( function ( nodes ) {
|
|
4220
|
+
|
|
4221
|
+
for ( let i = 0, il = nodes.length; i < il; i ++ ) {
|
|
4222
|
+
|
|
4223
|
+
scene.add( nodes[ i ] );
|
|
4224
|
+
|
|
4225
|
+
}
|
|
4545
4226
|
|
|
4546
4227
|
// Removes dangling associations, associations that reference a node that
|
|
4547
4228
|
// didn't make it into the scene.
|
|
@@ -4583,15 +4264,7 @@ class GLTFParser {
|
|
|
4583
4264
|
|
|
4584
4265
|
}
|
|
4585
4266
|
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
const target = animationChannel.target;
|
|
4589
|
-
const name = target.node !== undefined ? target.node : target.id; // NOTE: target.id is deprecated.
|
|
4590
|
-
return this.getDependency( 'node', name );
|
|
4591
|
-
|
|
4592
|
-
}
|
|
4593
|
-
|
|
4594
|
-
createAnimationTracks( node, inputAccessor, outputAccessor, sampler, target ) {
|
|
4267
|
+
_createAnimationTracks( node, inputAccessor, outputAccessor, sampler, target ) {
|
|
4595
4268
|
|
|
4596
4269
|
const tracks = [];
|
|
4597
4270
|
|
|
@@ -4643,9 +4316,6 @@ class GLTFParser {
|
|
|
4643
4316
|
case 3:
|
|
4644
4317
|
TypedKeyframeTrack = VectorKeyframeTrack;
|
|
4645
4318
|
break;
|
|
4646
|
-
case 4:
|
|
4647
|
-
TypedKeyframeTrack = ColorKeyframeTrack;
|
|
4648
|
-
break;
|
|
4649
4319
|
|
|
4650
4320
|
}
|
|
4651
4321
|
|
|
@@ -4655,7 +4325,7 @@ class GLTFParser {
|
|
|
4655
4325
|
|
|
4656
4326
|
const interpolation = sampler.interpolation !== undefined ? INTERPOLATION[ sampler.interpolation ] : InterpolateLinear;
|
|
4657
4327
|
|
|
4658
|
-
const outputArray =
|
|
4328
|
+
const outputArray = this._getArrayFromAccessor( outputAccessor );
|
|
4659
4329
|
|
|
4660
4330
|
for ( let j = 0, jl = targetNames.length; j < jl; j ++ ) {
|
|
4661
4331
|
|
|
@@ -4669,7 +4339,7 @@ class GLTFParser {
|
|
|
4669
4339
|
// Override interpolation with custom factory method.
|
|
4670
4340
|
if ( interpolation === 'CUBICSPLINE' ) {
|
|
4671
4341
|
|
|
4672
|
-
|
|
4342
|
+
this._createCubicSplineTrackInterpolant( track );
|
|
4673
4343
|
|
|
4674
4344
|
}
|
|
4675
4345
|
|
|
@@ -4681,101 +4351,47 @@ class GLTFParser {
|
|
|
4681
4351
|
|
|
4682
4352
|
}
|
|
4683
4353
|
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
function buildNodeHierarchy( nodeId, parentObject, json, parser ) {
|
|
4687
|
-
|
|
4688
|
-
const nodeDef = json.nodes[ nodeId ];
|
|
4689
|
-
|
|
4690
|
-
return parser.getDependency( 'node', nodeId ).then( function ( node ) {
|
|
4354
|
+
_getArrayFromAccessor( accessor ) {
|
|
4691
4355
|
|
|
4692
|
-
|
|
4356
|
+
let outputArray = accessor.array;
|
|
4693
4357
|
|
|
4694
|
-
|
|
4358
|
+
if ( accessor.normalized ) {
|
|
4695
4359
|
|
|
4696
|
-
|
|
4360
|
+
const scale = getNormalizedComponentScale( outputArray.constructor );
|
|
4361
|
+
const scaled = new Float32Array( outputArray.length );
|
|
4697
4362
|
|
|
4698
|
-
|
|
4363
|
+
for ( let j = 0, jl = outputArray.length; j < jl; j ++ ) {
|
|
4699
4364
|
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
const pendingJoints = [];
|
|
4703
|
-
|
|
4704
|
-
for ( let i = 0, il = skinEntry.joints.length; i < il; i ++ ) {
|
|
4705
|
-
|
|
4706
|
-
pendingJoints.push( parser.getDependency( 'node', skinEntry.joints[ i ] ) );
|
|
4365
|
+
scaled[ j ] = outputArray[ j ] * scale;
|
|
4707
4366
|
|
|
4708
4367
|
}
|
|
4709
4368
|
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
} ).then( function ( jointNodes ) {
|
|
4713
|
-
|
|
4714
|
-
node.traverse( function ( mesh ) {
|
|
4715
|
-
|
|
4716
|
-
if ( ! mesh.isMesh ) return;
|
|
4717
|
-
|
|
4718
|
-
const bones = [];
|
|
4719
|
-
const boneInverses = [];
|
|
4720
|
-
|
|
4721
|
-
for ( let j = 0, jl = jointNodes.length; j < jl; j ++ ) {
|
|
4722
|
-
|
|
4723
|
-
const jointNode = jointNodes[ j ];
|
|
4724
|
-
|
|
4725
|
-
if ( jointNode ) {
|
|
4726
|
-
|
|
4727
|
-
bones.push( jointNode );
|
|
4728
|
-
|
|
4729
|
-
const mat = new Matrix4();
|
|
4730
|
-
|
|
4731
|
-
if ( skinEntry.inverseBindMatrices !== undefined ) {
|
|
4732
|
-
|
|
4733
|
-
mat.fromArray( skinEntry.inverseBindMatrices.array, j * 16 );
|
|
4734
|
-
|
|
4735
|
-
}
|
|
4736
|
-
|
|
4737
|
-
boneInverses.push( mat );
|
|
4738
|
-
|
|
4739
|
-
} else {
|
|
4740
|
-
|
|
4741
|
-
console.warn( 'THREE.GLTFLoader: Joint "%s" could not be found.', skinEntry.joints[ j ] );
|
|
4742
|
-
|
|
4743
|
-
}
|
|
4744
|
-
|
|
4745
|
-
}
|
|
4746
|
-
|
|
4747
|
-
mesh.bind( new Skeleton( bones, boneInverses ), mesh.matrixWorld );
|
|
4369
|
+
outputArray = scaled;
|
|
4748
4370
|
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
return node;
|
|
4752
|
-
|
|
4753
|
-
} );
|
|
4754
|
-
|
|
4755
|
-
} ).then( function ( node ) {
|
|
4756
|
-
|
|
4757
|
-
// build node hierachy
|
|
4371
|
+
}
|
|
4758
4372
|
|
|
4759
|
-
|
|
4373
|
+
return outputArray;
|
|
4760
4374
|
|
|
4761
|
-
|
|
4375
|
+
}
|
|
4762
4376
|
|
|
4763
|
-
|
|
4377
|
+
_createCubicSplineTrackInterpolant( track ) {
|
|
4764
4378
|
|
|
4765
|
-
|
|
4379
|
+
track.createInterpolant = function InterpolantFactoryMethodGLTFCubicSpline( result ) {
|
|
4766
4380
|
|
|
4767
|
-
|
|
4381
|
+
// A CUBICSPLINE keyframe in glTF has three output values for each input value,
|
|
4382
|
+
// representing inTangent, splineVertex, and outTangent. As a result, track.getValueSize()
|
|
4383
|
+
// must be divided by three to get the interpolant's sampleSize argument.
|
|
4768
4384
|
|
|
4769
|
-
|
|
4770
|
-
pending.push( buildNodeHierarchy( child, node, json, parser ) );
|
|
4385
|
+
const interpolantType = ( this instanceof QuaternionKeyframeTrack ) ? GLTFCubicSplineQuaternionInterpolant : GLTFCubicSplineInterpolant;
|
|
4771
4386
|
|
|
4772
|
-
|
|
4387
|
+
return new interpolantType( this.times, this.values, this.getValueSize() / 3, result );
|
|
4773
4388
|
|
|
4774
|
-
}
|
|
4389
|
+
};
|
|
4775
4390
|
|
|
4776
|
-
|
|
4391
|
+
// Mark as CUBICSPLINE. `track.getInterpolation()` doesn't support custom interpolants.
|
|
4392
|
+
track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true;
|
|
4777
4393
|
|
|
4778
|
-
}
|
|
4394
|
+
}
|
|
4779
4395
|
|
|
4780
4396
|
}
|
|
4781
4397
|
|
|
@@ -4954,98 +4570,4 @@ function addPrimitiveAttributes( geometry, primitiveDef, parser ) {
|
|
|
4954
4570
|
|
|
4955
4571
|
}
|
|
4956
4572
|
|
|
4957
|
-
/**
|
|
4958
|
-
* @param {BufferGeometry} geometry
|
|
4959
|
-
* @param {Number} drawMode
|
|
4960
|
-
* @return {BufferGeometry}
|
|
4961
|
-
*/
|
|
4962
|
-
function toTrianglesDrawMode( geometry, drawMode ) {
|
|
4963
|
-
|
|
4964
|
-
let index = geometry.getIndex();
|
|
4965
|
-
|
|
4966
|
-
// generate index if not present
|
|
4967
|
-
|
|
4968
|
-
if ( index === null ) {
|
|
4969
|
-
|
|
4970
|
-
const indices = [];
|
|
4971
|
-
|
|
4972
|
-
const position = geometry.getAttribute( 'position' );
|
|
4973
|
-
|
|
4974
|
-
if ( position !== undefined ) {
|
|
4975
|
-
|
|
4976
|
-
for ( let i = 0; i < position.count; i ++ ) {
|
|
4977
|
-
|
|
4978
|
-
indices.push( i );
|
|
4979
|
-
|
|
4980
|
-
}
|
|
4981
|
-
|
|
4982
|
-
geometry.setIndex( indices );
|
|
4983
|
-
index = geometry.getIndex();
|
|
4984
|
-
|
|
4985
|
-
} else {
|
|
4986
|
-
|
|
4987
|
-
console.error( 'THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.' );
|
|
4988
|
-
return geometry;
|
|
4989
|
-
|
|
4990
|
-
}
|
|
4991
|
-
|
|
4992
|
-
}
|
|
4993
|
-
|
|
4994
|
-
//
|
|
4995
|
-
|
|
4996
|
-
const numberOfTriangles = index.count - 2;
|
|
4997
|
-
const newIndices = [];
|
|
4998
|
-
|
|
4999
|
-
if ( drawMode === TriangleFanDrawMode ) {
|
|
5000
|
-
|
|
5001
|
-
// gl.TRIANGLE_FAN
|
|
5002
|
-
|
|
5003
|
-
for ( let i = 1; i <= numberOfTriangles; i ++ ) {
|
|
5004
|
-
|
|
5005
|
-
newIndices.push( index.getX( 0 ) );
|
|
5006
|
-
newIndices.push( index.getX( i ) );
|
|
5007
|
-
newIndices.push( index.getX( i + 1 ) );
|
|
5008
|
-
|
|
5009
|
-
}
|
|
5010
|
-
|
|
5011
|
-
} else {
|
|
5012
|
-
|
|
5013
|
-
// gl.TRIANGLE_STRIP
|
|
5014
|
-
|
|
5015
|
-
for ( let i = 0; i < numberOfTriangles; i ++ ) {
|
|
5016
|
-
|
|
5017
|
-
if ( i % 2 === 0 ) {
|
|
5018
|
-
|
|
5019
|
-
newIndices.push( index.getX( i ) );
|
|
5020
|
-
newIndices.push( index.getX( i + 1 ) );
|
|
5021
|
-
newIndices.push( index.getX( i + 2 ) );
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
} else {
|
|
5025
|
-
|
|
5026
|
-
newIndices.push( index.getX( i + 2 ) );
|
|
5027
|
-
newIndices.push( index.getX( i + 1 ) );
|
|
5028
|
-
newIndices.push( index.getX( i ) );
|
|
5029
|
-
|
|
5030
|
-
}
|
|
5031
|
-
|
|
5032
|
-
}
|
|
5033
|
-
|
|
5034
|
-
}
|
|
5035
|
-
|
|
5036
|
-
if ( ( newIndices.length / 3 ) !== numberOfTriangles ) {
|
|
5037
|
-
|
|
5038
|
-
console.error( 'THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.' );
|
|
5039
|
-
|
|
5040
|
-
}
|
|
5041
|
-
|
|
5042
|
-
// build final geometry
|
|
5043
|
-
|
|
5044
|
-
const newGeometry = geometry.clone();
|
|
5045
|
-
newGeometry.setIndex( newIndices );
|
|
5046
|
-
|
|
5047
|
-
return newGeometry;
|
|
5048
|
-
|
|
5049
|
-
}
|
|
5050
|
-
|
|
5051
4573
|
export { GLTFLoader };
|