three-stdlib 2.15.1 → 2.16.0
Sign up to get free protection for your applications and to get access to all the features.
- package/animation/AnimationClipCreator.js +32 -52
- package/animation/AnimationClipCreator.mjs +57 -0
- package/animation/CCDIKSolver.js +196 -302
- package/animation/CCDIKSolver.mjs +223 -0
- package/animation/MMDAnimationHelper.js +150 -341
- package/animation/MMDAnimationHelper.mjs +514 -0
- package/animation/MMDPhysics.js +154 -361
- package/animation/MMDPhysics.mjs +769 -0
- package/cameras/CinematicCamera.js +67 -77
- package/cameras/CinematicCamera.mjs +129 -0
- package/controls/ArcballControls.js +544 -1449
- package/controls/ArcballControls.mjs +1737 -0
- package/controls/DeviceOrientationControls.js +52 -97
- package/controls/DeviceOrientationControls.mjs +74 -0
- package/controls/DragControls.js +85 -187
- package/controls/DragControls.mjs +172 -0
- package/controls/FirstPersonControls.js +123 -193
- package/controls/FirstPersonControls.mjs +220 -0
- package/controls/FlyControls.js +82 -152
- package/controls/FlyControls.mjs +239 -0
- package/controls/OrbitControls.js +232 -481
- package/controls/OrbitControls.mjs +731 -0
- package/controls/PointerLockControls.js +63 -99
- package/controls/PointerLockControls.mjs +88 -0
- package/controls/TrackballControls.js +211 -383
- package/controls/TrackballControls.mjs +481 -0
- package/controls/TransformControls.js +575 -782
- package/controls/TransformControls.mjs +1068 -0
- package/controls/experimental/CameraControls.js +329 -609
- package/controls/experimental/CameraControls.mjs +673 -0
- package/csm/CSM.js +47 -108
- package/csm/CSM.mjs +244 -0
- package/csm/CSMFrustum.js +14 -29
- package/csm/CSMFrustum.mjs +75 -0
- package/csm/CSMHelper.js +20 -34
- package/csm/CSMHelper.mjs +114 -0
- package/csm/CSMShader.js +7 -11
- package/csm/CSMShader.mjs +251 -0
- package/curves/CurveExtras.js +73 -115
- package/curves/CurveExtras.mjs +224 -0
- package/curves/NURBSCurve.js +15 -43
- package/curves/NURBSCurve.mjs +35 -0
- package/curves/NURBSSurface.js +11 -27
- package/curves/NURBSSurface.mjs +28 -0
- package/curves/NURBSUtils.js +54 -203
- package/curves/NURBSUtils.mjs +226 -0
- package/deprecated/Geometry.js +191 -486
- package/deprecated/Geometry.mjs +966 -0
- package/effects/AnaglyphEffect.js +95 -60
- package/effects/AnaglyphEffect.mjs +120 -0
- package/effects/AsciiEffect.js +80 -110
- package/effects/AsciiEffect.mjs +173 -0
- package/effects/OutlineEffect.js +121 -204
- package/effects/OutlineEffect.mjs +295 -0
- package/effects/ParallaxBarrierEffect.js +39 -38
- package/effects/ParallaxBarrierEffect.mjs +64 -0
- package/effects/PeppersGhostEffect.js +19 -68
- package/effects/PeppersGhostEffect.mjs +85 -0
- package/effects/StereoEffect.js +12 -16
- package/effects/StereoEffect.mjs +32 -0
- package/environments/RoomEnvironment.js +52 -47
- package/environments/RoomEnvironment.mjs +78 -0
- package/exporters/ColladaExporter.js +115 -241
- package/exporters/ColladaExporter.mjs +299 -0
- package/exporters/DRACOExporter.js +67 -121
- package/exporters/DRACOExporter.mjs +132 -0
- package/exporters/GLTFExporter.js +463 -1014
- package/exporters/GLTFExporter.mjs +1381 -0
- package/exporters/MMDExporter.js +44 -102
- package/exporters/MMDExporter.mjs +102 -0
- package/exporters/OBJExporter.js +78 -140
- package/exporters/OBJExporter.mjs +166 -0
- package/exporters/PLYExporter.js +93 -154
- package/exporters/PLYExporter.mjs +278 -0
- package/exporters/STLExporter.js +30 -81
- package/exporters/STLExporter.mjs +129 -0
- package/exporters/USDZExporter.js +84 -144
- package/exporters/USDZExporter.mjs +328 -0
- package/geometries/BoxLineGeometry.js +7 -14
- package/geometries/BoxLineGeometry.mjs +45 -0
- package/geometries/ConvexGeometry.js +14 -23
- package/geometries/ConvexGeometry.mjs +29 -0
- package/geometries/DecalGeometry.js +108 -162
- package/geometries/DecalGeometry.mjs +184 -0
- package/geometries/LightningStrike.js +101 -294
- package/geometries/LightningStrike.mjs +547 -0
- package/geometries/ParametricGeometries.js +26 -76
- package/geometries/ParametricGeometries.mjs +129 -0
- package/geometries/ParametricGeometry.js +24 -48
- package/geometries/ParametricGeometry.mjs +63 -0
- package/geometries/RoundedBoxGeometry.js +33 -64
- package/geometries/RoundedBoxGeometry.mjs +91 -0
- package/geometries/TeapotGeometry.js +1434 -174
- package/geometries/TeapotGeometry.mjs +1557 -0
- package/geometries/TextGeometry.js +9 -17
- package/geometries/TextGeometry.mjs +23 -0
- package/helpers/LightProbeHelper.js +53 -21
- package/helpers/LightProbeHelper.mjs +72 -0
- package/helpers/PositionalAudioHelper.js +23 -30
- package/helpers/PositionalAudioHelper.mjs +68 -0
- package/helpers/RectAreaLightHelper.js +17 -33
- package/helpers/RectAreaLightHelper.mjs +44 -0
- package/helpers/VertexNormalsHelper.js +20 -41
- package/helpers/VertexNormalsHelper.mjs +54 -0
- package/helpers/VertexTangentsHelper.js +18 -36
- package/helpers/VertexTangentsHelper.mjs +45 -0
- package/index.js +969 -333
- package/index.mjs +969 -0
- package/interactive/SelectionBox.js +31 -46
- package/interactive/SelectionBox.mjs +137 -0
- package/interactive/SelectionHelper.js +16 -21
- package/interactive/SelectionHelper.mjs +54 -0
- package/libs/MeshoptDecoder.js +147 -58
- package/libs/MeshoptDecoder.mjs +210 -0
- package/libs/MotionControllers.js +66 -208
- package/libs/MotionControllers.mjs +261 -0
- package/lights/LightProbeGenerator.js +40 -96
- package/lights/LightProbeGenerator.mjs +145 -0
- package/lights/RectAreaLightUniformsLib.js +32842 -9
- package/lights/RectAreaLightUniformsLib.mjs +32842 -0
- package/lines/Line2.js +9 -12
- package/lines/Line2.mjs +13 -0
- package/lines/LineGeometry.js +7 -19
- package/lines/LineGeometry.mjs +44 -0
- package/lines/LineMaterial.js +51 -89
- package/lines/LineMaterial.mjs +539 -0
- package/lines/LineSegments2.js +56 -165
- package/lines/LineSegments2.mjs +202 -0
- package/lines/LineSegmentsGeometry.js +29 -71
- package/lines/LineSegmentsGeometry.mjs +124 -0
- package/lines/Wireframe.js +15 -29
- package/lines/Wireframe.mjs +31 -0
- package/lines/WireframeGeometry2.js +8 -9
- package/lines/WireframeGeometry2.mjs +13 -0
- package/loaders/3DMLoader.js +234 -469
- package/loaders/3DMLoader.mjs +802 -0
- package/loaders/3MFLoader.js +340 -555
- package/loaders/3MFLoader.mjs +837 -0
- package/loaders/AMFLoader.js +114 -219
- package/loaders/AMFLoader.mjs +284 -0
- package/loaders/AssimpLoader.js +328 -725
- package/loaders/AssimpLoader.mjs +1396 -0
- package/loaders/BVHLoader.js +94 -200
- package/loaders/BVHLoader.mjs +207 -0
- package/loaders/BasisTextureLoader.js +229 -357
- package/loaders/BasisTextureLoader.mjs +474 -0
- package/loaders/ColladaLoader.js +932 -1522
- package/loaders/ColladaLoader.mjs +2403 -0
- package/loaders/DDSLoader.js +42 -108
- package/loaders/DDSLoader.mjs +148 -0
- package/loaders/DRACOLoader.js +103 -210
- package/loaders/DRACOLoader.mjs +340 -0
- package/loaders/EXRLoader.js +461 -809
- package/loaders/EXRLoader.mjs +1351 -0
- package/loaders/FBXLoader.js +842 -1397
- package/loaders/FBXLoader.mjs +2362 -0
- package/loaders/FontLoader.js +33 -66
- package/loaders/FontLoader.mjs +111 -0
- package/loaders/GCodeLoader.js +63 -111
- package/loaders/GCodeLoader.mjs +141 -0
- package/loaders/GLTFLoader.js +771 -1484
- package/loaders/GLTFLoader.mjs +2316 -0
- package/loaders/HDRCubeTextureLoader.js +45 -50
- package/loaders/HDRCubeTextureLoader.mjs +77 -0
- package/loaders/KMZLoader.js +42 -55
- package/loaders/KMZLoader.mjs +75 -0
- package/loaders/KTX2Loader.js +229 -362
- package/loaders/KTX2Loader.mjs +427 -0
- package/loaders/KTXLoader.js +37 -99
- package/loaders/KTXLoader.mjs +87 -0
- package/loaders/LDrawLoader.js +313 -746
- package/loaders/LDrawLoader.mjs +1409 -0
- package/loaders/LUT3dlLoader.js +50 -62
- package/loaders/LUT3dlLoader.mjs +100 -0
- package/loaders/LUTCubeLoader.js +45 -56
- package/loaders/LUTCubeLoader.mjs +104 -0
- package/loaders/LWOLoader.js +227 -339
- package/loaders/LWOLoader.mjs +625 -0
- package/loaders/LottieLoader.js +36 -38
- package/loaders/LottieLoader.mjs +47 -0
- package/loaders/MD2Loader.js +248 -91
- package/loaders/MD2Loader.mjs +359 -0
- package/loaders/MDDLoader.js +25 -45
- package/loaders/MDDLoader.mjs +58 -0
- package/loaders/MMDLoader.js +359 -795
- package/loaders/MMDLoader.mjs +998 -0
- package/loaders/MTLLoader.js +91 -201
- package/loaders/MTLLoader.mjs +280 -0
- package/loaders/NRRDLoader.js +182 -263
- package/loaders/NRRDLoader.mjs +401 -0
- package/loaders/NodeMaterialLoader.js +121 -14
- package/loaders/NodeMaterialLoader.mjs +146 -0
- package/loaders/OBJLoader.js +161 -283
- package/loaders/OBJLoader.mjs +487 -0
- package/loaders/PCDLoader.js +145 -164
- package/loaders/PCDLoader.mjs +248 -0
- package/loaders/PDBLoader.js +45 -63
- package/loaders/PDBLoader.mjs +246 -0
- package/loaders/PLYLoader.js +106 -203
- package/loaders/PLYLoader.mjs +317 -0
- package/loaders/PRWMLoader.js +73 -110
- package/loaders/PRWMLoader.mjs +160 -0
- package/loaders/PVRLoader.js +32 -93
- package/loaders/PVRLoader.mjs +131 -0
- package/loaders/RGBELoader.js +96 -233
- package/loaders/RGBELoader.mjs +244 -0
- package/loaders/RGBMLoader.js +344 -514
- package/loaders/RGBMLoader.mjs +998 -0
- package/loaders/STLLoader.js +59 -165
- package/loaders/STLLoader.mjs +190 -0
- package/loaders/SVGLoader.js +481 -851
- package/loaders/SVGLoader.mjs +1709 -0
- package/loaders/TDSLoader.js +137 -527
- package/loaders/TDSLoader.mjs +480 -0
- package/loaders/TGALoader.js +94 -205
- package/loaders/TGALoader.mjs +285 -0
- package/loaders/TTFLoader.js +58 -79
- package/loaders/TTFLoader.mjs +131 -0
- package/loaders/TiltLoader.js +129 -167
- package/loaders/TiltLoader.mjs +373 -0
- package/loaders/VOXLoader.js +320 -84
- package/loaders/VOXLoader.mjs +431 -0
- package/loaders/VRMLLoader.js +786 -1268
- package/loaders/VRMLLoader.mjs +2093 -0
- package/loaders/VRMLoader.js +23 -31
- package/loaders/VRMLoader.mjs +38 -0
- package/loaders/VTKLoader.js +219 -407
- package/loaders/VTKLoader.mjs +646 -0
- package/loaders/XLoader.js +1083 -1259
- package/loaders/XLoader.mjs +1258 -0
- package/loaders/XYZLoader.js +28 -34
- package/loaders/XYZLoader.mjs +60 -0
- package/loaders/lwo/IFFParser.js +238 -492
- package/loaders/lwo/IFFParser.mjs +697 -0
- package/loaders/lwo/LWO2Parser.js +176 -279
- package/loaders/lwo/LWO2Parser.mjs +327 -0
- package/loaders/lwo/LWO3Parser.js +160 -247
- package/loaders/lwo/LWO3Parser.mjs +298 -0
- package/math/Capsule.js +56 -43
- package/math/Capsule.mjs +100 -0
- package/math/ColorConverter.js +18 -32
- package/math/ColorConverter.mjs +51 -0
- package/math/ConvexHull.js +97 -357
- package/math/ConvexHull.mjs +574 -0
- package/math/ImprovedNoise.js +282 -32
- package/math/ImprovedNoise.mjs +302 -0
- package/math/Lut.js +51 -35
- package/math/Lut.mjs +135 -0
- package/math/MeshSurfaceSampler.js +25 -68
- package/math/MeshSurfaceSampler.mjs +107 -0
- package/math/OBB.js +91 -152
- package/math/OBB.mjs +235 -0
- package/math/Octree.js +76 -139
- package/math/Octree.mjs +278 -0
- package/math/SimplexNoise.js +217 -238
- package/math/SimplexNoise.mjs +425 -0
- package/misc/ConvexObjectBreaker.js +79 -185
- package/misc/ConvexObjectBreaker.mjs +292 -0
- package/misc/GPUComputationRenderer.js +69 -194
- package/misc/GPUComputationRenderer.mjs +171 -0
- package/misc/Gyroscope.js +16 -22
- package/misc/Gyroscope.mjs +35 -0
- package/misc/MD2Character.js +52 -74
- package/misc/MD2Character.mjs +162 -0
- package/misc/MD2CharacterComplex.js +112 -163
- package/misc/MD2CharacterComplex.mjs +328 -0
- package/misc/MorphAnimMesh.js +20 -28
- package/misc/MorphAnimMesh.mjs +40 -0
- package/misc/MorphBlendMesh.js +45 -69
- package/misc/MorphBlendMesh.mjs +179 -0
- package/misc/ProgressiveLightmap.js +70 -187
- package/misc/ProgressiveLightmap.mjs +166 -0
- package/misc/RollerCoaster.js +106 -135
- package/misc/RollerCoaster.mjs +346 -0
- package/misc/TubePainter.js +74 -92
- package/misc/TubePainter.mjs +123 -0
- package/misc/Volume.js +108 -270
- package/misc/Volume.mjs +244 -0
- package/misc/VolumeSlice.js +34 -122
- package/misc/VolumeSlice.mjs +106 -0
- package/misc/WebGL.js +37 -34
- package/misc/WebGL.mjs +74 -0
- package/modifiers/CurveModifier.js +46 -151
- package/modifiers/CurveModifier.mjs +182 -0
- package/modifiers/EdgeSplitModifier.js +46 -90
- package/modifiers/EdgeSplitModifier.mjs +162 -0
- package/modifiers/SimplifyModifier.js +77 -202
- package/modifiers/SimplifyModifier.mjs +282 -0
- package/modifiers/TessellateModifier.js +65 -90
- package/modifiers/TessellateModifier.mjs +206 -0
- package/nodes/Nodes.js +274 -140
- package/nodes/Nodes.mjs +400 -0
- package/nodes/ShaderNode.js +296 -196
- package/nodes/ShaderNode.mjs +408 -0
- package/nodes/accessors/BufferNode.js +4 -8
- package/nodes/accessors/BufferNode.mjs +15 -0
- package/nodes/accessors/CameraNode.js +20 -25
- package/nodes/accessors/CameraNode.mjs +44 -0
- package/nodes/accessors/CubeTextureNode.js +14 -26
- package/nodes/accessors/CubeTextureNode.mjs +42 -0
- package/nodes/accessors/MaterialNode.js +43 -53
- package/nodes/accessors/MaterialNode.mjs +71 -0
- package/nodes/accessors/MaterialReferenceNode.js +3 -6
- package/nodes/accessors/MaterialReferenceNode.mjs +14 -0
- package/nodes/accessors/ModelNode.js +3 -5
- package/nodes/accessors/ModelNode.mjs +9 -0
- package/nodes/accessors/ModelViewProjectionNode.js +14 -13
- package/nodes/accessors/ModelViewProjectionNode.mjs +24 -0
- package/nodes/accessors/NormalNode.js +40 -39
- package/nodes/accessors/NormalNode.mjs +62 -0
- package/nodes/accessors/Object3DNode.js +40 -50
- package/nodes/accessors/Object3DNode.mjs +76 -0
- package/nodes/accessors/PointUVNode.js +5 -9
- package/nodes/accessors/PointUVNode.mjs +13 -0
- package/nodes/accessors/PositionNode.js +42 -41
- package/nodes/accessors/PositionNode.mjs +65 -0
- package/nodes/accessors/ReferenceNode.js +10 -17
- package/nodes/accessors/ReferenceNode.mjs +37 -0
- package/nodes/accessors/ReflectNode.js +23 -26
- package/nodes/accessors/ReflectNode.mjs +43 -0
- package/nodes/accessors/SkinningNode.js +46 -48
- package/nodes/accessors/SkinningNode.mjs +58 -0
- package/nodes/accessors/TextureNode.js +14 -29
- package/nodes/accessors/TextureNode.mjs +54 -0
- package/nodes/accessors/UVNode.js +5 -11
- package/nodes/accessors/UVNode.mjs +23 -0
- package/nodes/core/ArrayUniformNode.js +3 -7
- package/nodes/core/ArrayUniformNode.mjs +14 -0
- package/nodes/core/AttributeNode.js +5 -12
- package/nodes/core/AttributeNode.mjs +30 -0
- package/nodes/core/BypassNode.js +5 -12
- package/nodes/core/BypassNode.mjs +22 -0
- package/nodes/core/CodeNode.js +4 -12
- package/nodes/core/CodeNode.mjs +28 -0
- package/nodes/core/ConstNode.js +3 -7
- package/nodes/core/ConstNode.mjs +14 -0
- package/nodes/core/ContextNode.js +3 -8
- package/nodes/core/ContextNode.mjs +22 -0
- package/nodes/core/ExpressionNode.js +5 -9
- package/nodes/core/ExpressionNode.mjs +19 -0
- package/nodes/core/FunctionCallNode.js +6 -15
- package/nodes/core/FunctionCallNode.mjs +37 -0
- package/nodes/core/FunctionNode.js +10 -25
- package/nodes/core/FunctionNode.mjs +56 -0
- package/nodes/core/InputNode.js +12 -23
- package/nodes/core/InputNode.mjs +38 -0
- package/nodes/core/Node.js +35 -75
- package/nodes/core/Node.mjs +139 -0
- package/nodes/core/NodeAttribute.js +2 -4
- package/nodes/core/NodeAttribute.mjs +10 -0
- package/nodes/core/NodeBuilder.js +110 -224
- package/nodes/core/NodeBuilder.mjs +395 -0
- package/nodes/core/NodeCode.js +4 -7
- package/nodes/core/NodeCode.mjs +11 -0
- package/nodes/core/NodeFrame.js +9 -12
- package/nodes/core/NodeFrame.mjs +35 -0
- package/nodes/core/NodeFunctionInput.js +3 -5
- package/nodes/core/NodeFunctionInput.mjs +13 -0
- package/nodes/core/NodeKeywords.js +5 -16
- package/nodes/core/NodeKeywords.mjs +44 -0
- package/nodes/core/NodeUniform.js +3 -7
- package/nodes/core/NodeUniform.mjs +18 -0
- package/nodes/core/NodeUtils.js +39 -43
- package/nodes/core/NodeUtils.mjs +57 -0
- package/nodes/core/NodeVar.js +2 -4
- package/nodes/core/NodeVar.mjs +10 -0
- package/nodes/core/NodeVary.js +2 -4
- package/nodes/core/NodeVary.mjs +10 -0
- package/nodes/core/PropertyNode.js +4 -10
- package/nodes/core/PropertyNode.mjs +21 -0
- package/nodes/core/TempNode.js +5 -11
- package/nodes/core/TempNode.mjs +25 -0
- package/nodes/core/UniformNode.js +4 -10
- package/nodes/core/UniformNode.mjs +23 -0
- package/nodes/core/VarNode.js +3 -11
- package/nodes/core/VarNode.mjs +31 -0
- package/nodes/core/VaryNode.js +6 -15
- package/nodes/core/VaryNode.mjs +30 -0
- package/nodes/core/constants.js +20 -7
- package/nodes/core/constants.mjs +24 -0
- package/nodes/display/ColorSpaceNode.js +34 -38
- package/nodes/display/ColorSpaceNode.mjs +63 -0
- package/nodes/display/NormalMapNode.js +35 -53
- package/nodes/display/NormalMapNode.mjs +54 -0
- package/nodes/fog/FogNode.js +5 -9
- package/nodes/fog/FogNode.mjs +15 -0
- package/nodes/fog/FogRangeNode.js +5 -9
- package/nodes/fog/FogRangeNode.mjs +17 -0
- package/nodes/functions/BSDFs.js +61 -118
- package/nodes/functions/BSDFs.mjs +64 -0
- package/nodes/lights/LightContextNode.js +14 -23
- package/nodes/lights/LightContextNode.mjs +35 -0
- package/nodes/lights/LightNode.js +27 -31
- package/nodes/lights/LightNode.mjs +58 -0
- package/nodes/lights/LightsNode.js +9 -28
- package/nodes/lights/LightsNode.mjs +59 -0
- package/nodes/loaders/NodeLoader.js +27 -42
- package/nodes/loaders/NodeLoader.mjs +66 -0
- package/nodes/loaders/NodeMaterialLoader.js +4 -10
- package/nodes/loaders/NodeMaterialLoader.mjs +24 -0
- package/nodes/loaders/NodeObjectLoader.js +9 -19
- package/nodes/loaders/NodeObjectLoader.mjs +40 -0
- package/nodes/materials/LineBasicNodeMaterial.js +5 -10
- package/nodes/materials/LineBasicNodeMaterial.mjs +27 -0
- package/nodes/materials/Materials.js +14 -17
- package/nodes/materials/Materials.mjs +28 -0
- package/nodes/materials/MeshBasicNodeMaterial.js +5 -10
- package/nodes/materials/MeshBasicNodeMaterial.mjs +28 -0
- package/nodes/materials/MeshStandardNodeMaterial.js +5 -8
- package/nodes/materials/MeshStandardNodeMaterial.mjs +41 -0
- package/nodes/materials/NodeMaterial.js +20 -36
- package/nodes/materials/NodeMaterial.mjs +64 -0
- package/nodes/materials/PointsNodeMaterial.js +5 -10
- package/nodes/materials/PointsNodeMaterial.mjs +30 -0
- package/nodes/math/CondNode.js +11 -23
- package/nodes/math/CondNode.mjs +38 -0
- package/nodes/math/MathNode.js +98 -142
- package/nodes/math/MathNode.mjs +163 -0
- package/nodes/math/OperatorNode.js +24 -46
- package/nodes/math/OperatorNode.mjs +103 -0
- package/nodes/procedural/CheckerNode.js +13 -19
- package/nodes/procedural/CheckerNode.mjs +21 -0
- package/nodes/utils/ArrayElementNode.js +4 -8
- package/nodes/utils/ArrayElementNode.mjs +19 -0
- package/nodes/utils/ConvertNode.js +3 -8
- package/nodes/utils/ConvertNode.mjs +25 -0
- package/nodes/utils/JoinNode.js +7 -11
- package/nodes/utils/JoinNode.mjs +26 -0
- package/nodes/utils/MatcapUVNode.js +8 -11
- package/nodes/utils/MatcapUVNode.mjs +16 -0
- package/nodes/utils/OscNode.js +27 -33
- package/nodes/utils/OscNode.mjs +50 -0
- package/nodes/utils/SplitNode.js +6 -20
- package/nodes/utils/SplitNode.mjs +45 -0
- package/nodes/utils/SpriteSheetUVNode.js +23 -23
- package/nodes/utils/SpriteSheetUVNode.mjs +40 -0
- package/nodes/utils/TimerNode.js +20 -24
- package/nodes/utils/TimerNode.mjs +44 -0
- package/objects/GroundProjectedEnv.js +22 -37
- package/objects/GroundProjectedEnv.mjs +130 -0
- package/objects/Lensflare.js +86 -156
- package/objects/Lensflare.mjs +262 -0
- package/objects/LightningStorm.js +38 -102
- package/objects/LightningStorm.mjs +110 -0
- package/objects/MarchingCubes.js +150 -303
- package/objects/MarchingCubes.mjs +457 -0
- package/objects/Reflector.js +50 -72
- package/objects/Reflector.mjs +166 -0
- package/objects/ReflectorForSSRPass.js +80 -131
- package/objects/ReflectorForSSRPass.mjs +247 -0
- package/objects/ReflectorRTT.js +6 -7
- package/objects/ReflectorRTT.mjs +10 -0
- package/objects/Refractor.js +64 -106
- package/objects/Refractor.mjs +178 -0
- package/objects/ShadowMesh.js +8 -17
- package/objects/ShadowMesh.mjs +41 -0
- package/objects/Sky.js +119 -80
- package/objects/Sky.mjs +124 -0
- package/objects/Water.js +83 -127
- package/objects/Water.mjs +235 -0
- package/objects/Water2.js +72 -108
- package/objects/Water2.mjs +252 -0
- package/offscreen/jank.js +10 -14
- package/offscreen/jank.mjs +27 -0
- package/offscreen/offscreen.js +4 -5
- package/offscreen/offscreen.mjs +5 -0
- package/offscreen/scene.js +45 -48
- package/offscreen/scene.mjs +52 -0
- package/package.json +3 -3
- package/physics/AmmoPhysics.js +30 -71
- package/physics/AmmoPhysics.mjs +165 -0
- package/postprocessing/AdaptiveToneMappingPass.js +97 -123
- package/postprocessing/AdaptiveToneMappingPass.mjs +221 -0
- package/postprocessing/AfterimagePass.js +28 -49
- package/postprocessing/AfterimagePass.mjs +55 -0
- package/postprocessing/BloomPass.js +43 -69
- package/postprocessing/BloomPass.mjs +90 -0
- package/postprocessing/BokehPass.js +39 -69
- package/postprocessing/BokehPass.mjs +76 -0
- package/postprocessing/ClearPass.js +10 -25
- package/postprocessing/ClearPass.mjs +27 -0
- package/postprocessing/CubeTexturePass.js +28 -27
- package/postprocessing/CubeTexturePass.mjs +49 -0
- package/postprocessing/DotScreenPass.js +24 -32
- package/postprocessing/DotScreenPass.mjs +40 -0
- package/postprocessing/EffectComposer.js +39 -86
- package/postprocessing/EffectComposer.mjs +139 -0
- package/postprocessing/FilmPass.js +25 -30
- package/postprocessing/FilmPass.mjs +42 -0
- package/postprocessing/GlitchPass.js +38 -61
- package/postprocessing/GlitchPass.mjs +75 -0
- package/postprocessing/HalftonePass.js +19 -39
- package/postprocessing/HalftonePass.mjs +44 -0
- package/postprocessing/LUTPass.js +13 -38
- package/postprocessing/LUTPass.mjs +136 -0
- package/postprocessing/MaskPass.js +19 -38
- package/postprocessing/MaskPass.mjs +60 -0
- package/postprocessing/OutlinePass.js +135 -277
- package/postprocessing/OutlinePass.mjs +438 -0
- package/postprocessing/Pass.js +20 -44
- package/postprocessing/Pass.mjs +37 -0
- package/postprocessing/RenderPass.js +13 -36
- package/postprocessing/RenderPass.mjs +48 -0
- package/postprocessing/RenderPixelatedPass.js +44 -58
- package/postprocessing/RenderPixelatedPass.mjs +199 -0
- package/postprocessing/SAOPass.js +154 -189
- package/postprocessing/SAOPass.mjs +282 -0
- package/postprocessing/SMAAPass.js +64 -84
- package/postprocessing/SMAAPass.mjs +112 -0
- package/postprocessing/SSAARenderPass.js +121 -69
- package/postprocessing/SSAARenderPass.mjs +170 -0
- package/postprocessing/SSAOPass.js +123 -172
- package/postprocessing/SSAOPass.mjs +265 -0
- package/postprocessing/SSRPass.js +211 -280
- package/postprocessing/SSRPass.mjs +432 -0
- package/postprocessing/SavePass.js +20 -25
- package/postprocessing/SavePass.mjs +37 -0
- package/postprocessing/ShaderPass.js +14 -30
- package/postprocessing/ShaderPass.mjs +39 -0
- package/postprocessing/TAARenderPass.js +42 -61
- package/postprocessing/TAARenderPass.mjs +88 -0
- package/postprocessing/TexturePass.js +21 -22
- package/postprocessing/TexturePass.mjs +39 -0
- package/postprocessing/UnrealBloomPass.js +105 -213
- package/postprocessing/UnrealBloomPass.mjs +220 -0
- package/renderers/CSS2DRenderer.js +44 -56
- package/renderers/CSS2DRenderer.mjs +112 -0
- package/renderers/CSS3DRenderer.js +53 -86
- package/renderers/CSS3DRenderer.mjs +133 -0
- package/renderers/Projector.js +107 -274
- package/renderers/Projector.mjs +511 -0
- package/renderers/SVGRenderer.js +72 -182
- package/renderers/SVGRenderer.mjs +306 -0
- package/renderers/nodes/accessors/CameraNode.js +29 -40
- package/renderers/nodes/accessors/CameraNode.mjs +63 -0
- package/renderers/nodes/accessors/ModelNode.js +28 -37
- package/renderers/nodes/accessors/ModelNode.mjs +61 -0
- package/renderers/nodes/accessors/ModelViewProjectionNode.js +10 -23
- package/renderers/nodes/accessors/ModelViewProjectionNode.mjs +21 -0
- package/renderers/nodes/accessors/NormalNode.js +35 -45
- package/renderers/nodes/accessors/NormalNode.mjs +61 -0
- package/renderers/nodes/accessors/PositionNode.js +18 -19
- package/renderers/nodes/accessors/PositionNode.mjs +30 -0
- package/renderers/nodes/accessors/UVNode.js +5 -10
- package/renderers/nodes/accessors/UVNode.mjs +13 -0
- package/renderers/nodes/core/AttributeNode.js +5 -14
- package/renderers/nodes/core/AttributeNode.mjs +35 -0
- package/renderers/nodes/core/InputNode.js +4 -14
- package/renderers/nodes/core/InputNode.mjs +31 -0
- package/renderers/nodes/core/Node.js +7 -17
- package/renderers/nodes/core/Node.mjs +34 -0
- package/renderers/nodes/core/NodeAttribute.js +3 -6
- package/renderers/nodes/core/NodeAttribute.mjs +10 -0
- package/renderers/nodes/core/NodeBuilder.js +87 -154
- package/renderers/nodes/core/NodeBuilder.mjs +243 -0
- package/renderers/nodes/core/NodeFrame.js +9 -12
- package/renderers/nodes/core/NodeFrame.mjs +35 -0
- package/renderers/nodes/core/NodeSlot.js +2 -3
- package/renderers/nodes/core/NodeSlot.mjs +10 -0
- package/renderers/nodes/core/NodeUniform.js +4 -9
- package/renderers/nodes/core/NodeUniform.mjs +18 -0
- package/renderers/nodes/core/NodeVary.js +4 -7
- package/renderers/nodes/core/NodeVary.mjs +11 -0
- package/renderers/nodes/core/VaryNode.js +6 -12
- package/renderers/nodes/core/VaryNode.mjs +22 -0
- package/renderers/nodes/core/constants.js +16 -13
- package/renderers/nodes/core/constants.mjs +22 -0
- package/renderers/nodes/inputs/ColorNode.js +5 -11
- package/renderers/nodes/inputs/ColorNode.mjs +11 -0
- package/renderers/nodes/inputs/FloatNode.js +5 -11
- package/renderers/nodes/inputs/FloatNode.mjs +11 -0
- package/renderers/nodes/inputs/Matrix3Node.js +7 -13
- package/renderers/nodes/inputs/Matrix3Node.mjs +12 -0
- package/renderers/nodes/inputs/Matrix4Node.js +7 -13
- package/renderers/nodes/inputs/Matrix4Node.mjs +12 -0
- package/renderers/nodes/inputs/TextureNode.js +7 -15
- package/renderers/nodes/inputs/TextureNode.mjs +20 -0
- package/renderers/nodes/inputs/Vector2Node.js +5 -11
- package/renderers/nodes/inputs/Vector2Node.mjs +11 -0
- package/renderers/nodes/inputs/Vector3Node.js +7 -13
- package/renderers/nodes/inputs/Vector3Node.mjs +12 -0
- package/renderers/nodes/inputs/Vector4Node.js +7 -13
- package/renderers/nodes/inputs/Vector4Node.mjs +12 -0
- package/renderers/nodes/math/MathNode.js +20 -30
- package/renderers/nodes/math/MathNode.mjs +55 -0
- package/renderers/nodes/math/OperatorNode.js +4 -20
- package/renderers/nodes/math/OperatorNode.mjs +42 -0
- package/renderers/nodes/utils/SwitchNode.js +4 -9
- package/renderers/nodes/utils/SwitchNode.mjs +20 -0
- package/renderers/nodes/utils/TimerNode.js +5 -10
- package/renderers/nodes/utils/TimerNode.mjs +14 -0
- package/renderers/webgpu/WebGPU.js +14 -16
- package/renderers/webgpu/WebGPU.mjs +24 -0
- package/renderers/webgpu/WebGPUAttributes.js +16 -23
- package/renderers/webgpu/WebGPUAttributes.mjs +69 -0
- package/renderers/webgpu/WebGPUBackground.js +13 -30
- package/renderers/webgpu/WebGPUBackground.mjs +61 -0
- package/renderers/webgpu/WebGPUBinding.js +4 -7
- package/renderers/webgpu/WebGPUBinding.mjs +14 -0
- package/renderers/webgpu/WebGPUBindings.js +21 -57
- package/renderers/webgpu/WebGPUBindings.mjs +155 -0
- package/renderers/webgpu/WebGPUComputePipelines.js +14 -25
- package/renderers/webgpu/WebGPUComputePipelines.mjs +44 -0
- package/renderers/webgpu/WebGPUGeometries.js +5 -15
- package/renderers/webgpu/WebGPUGeometries.mjs +41 -0
- package/renderers/webgpu/WebGPUInfo.js +3 -8
- package/renderers/webgpu/WebGPUInfo.mjs +46 -0
- package/renderers/webgpu/WebGPUObjects.js +5 -10
- package/renderers/webgpu/WebGPUObjects.mjs +25 -0
- package/renderers/webgpu/WebGPUProperties.js +5 -11
- package/renderers/webgpu/WebGPUProperties.mjs +22 -0
- package/renderers/webgpu/WebGPURenderLists.js +20 -36
- package/renderers/webgpu/WebGPURenderLists.mjs +119 -0
- package/renderers/webgpu/WebGPURenderPipelines.js +260 -387
- package/renderers/webgpu/WebGPURenderPipelines.mjs +545 -0
- package/renderers/webgpu/WebGPURenderer.js +124 -262
- package/renderers/webgpu/WebGPURenderer.mjs +574 -0
- package/renderers/webgpu/WebGPUSampledTexture.js +18 -31
- package/renderers/webgpu/WebGPUSampledTexture.mjs +40 -0
- package/renderers/webgpu/WebGPUSampler.js +7 -12
- package/renderers/webgpu/WebGPUSampler.mjs +15 -0
- package/renderers/webgpu/WebGPUStorageBuffer.js +7 -12
- package/renderers/webgpu/WebGPUStorageBuffer.mjs +15 -0
- package/renderers/webgpu/WebGPUTextureRenderer.js +5 -11
- package/renderers/webgpu/WebGPUTextureRenderer.mjs +23 -0
- package/renderers/webgpu/WebGPUTextureUtils.js +29 -40
- package/renderers/webgpu/WebGPUTextureUtils.mjs +98 -0
- package/renderers/webgpu/WebGPUTextures.js +186 -333
- package/renderers/webgpu/WebGPUTextures.mjs +484 -0
- package/renderers/webgpu/WebGPUUniform.js +25 -51
- package/renderers/webgpu/WebGPUUniform.mjs +81 -0
- package/renderers/webgpu/WebGPUUniformsGroup.js +32 -72
- package/renderers/webgpu/WebGPUUniformsGroup.mjs +176 -0
- package/renderers/webgpu/constants.js +190 -181
- package/renderers/webgpu/constants.mjs +230 -0
- package/renderers/webgpu/nodes/ShaderLib.js +2 -2
- package/renderers/webgpu/nodes/ShaderLib.mjs +42 -0
- package/renderers/webgpu/nodes/WebGPUNodeBuilder.js +53 -124
- package/renderers/webgpu/nodes/WebGPUNodeBuilder.mjs +165 -0
- package/renderers/webgpu/nodes/WebGPUNodeUniform.js +17 -31
- package/renderers/webgpu/nodes/WebGPUNodeUniform.mjs +73 -0
- package/renderers/webgpu/nodes/WebGPUNodeUniformsGroup.js +8 -9
- package/renderers/webgpu/nodes/WebGPUNodeUniformsGroup.mjs +15 -0
- package/renderers/webgpu/nodes/WebGPUNodes.js +7 -45
- package/renderers/webgpu/nodes/WebGPUNodes.mjs +40 -0
- package/shaders/ACESFilmicToneMappingShader.js +44 -24
- package/shaders/ACESFilmicToneMappingShader.mjs +48 -0
- package/shaders/AfterimageShader.js +28 -18
- package/shaders/AfterimageShader.mjs +32 -0
- package/shaders/BasicShader.js +9 -7
- package/shaders/BasicShader.mjs +12 -0
- package/shaders/BleachBypassShader.js +31 -15
- package/shaders/BleachBypassShader.mjs +35 -0
- package/shaders/BlendShader.js +26 -19
- package/shaders/BlendShader.mjs +30 -0
- package/shaders/BokehShader.js +98 -36
- package/shaders/BokehShader.mjs +106 -0
- package/shaders/BokehShader2.js +261 -90
- package/shaders/BokehShader2.mjs +269 -0
- package/shaders/BrightnessContrastShader.js +28 -19
- package/shaders/BrightnessContrastShader.mjs +32 -0
- package/shaders/ColorCorrectionShader.js +26 -22
- package/shaders/ColorCorrectionShader.mjs +30 -0
- package/shaders/ColorifyShader.js +24 -16
- package/shaders/ColorifyShader.mjs +28 -0
- package/shaders/ConvolutionShader.js +40 -36
- package/shaders/ConvolutionShader.mjs +55 -0
- package/shaders/CopyShader.js +21 -13
- package/shaders/CopyShader.mjs +25 -0
- package/shaders/DOFMipMapShader.js +28 -21
- package/shaders/DOFMipMapShader.mjs +32 -0
- package/shaders/DepthLimitedBlurShader.js +85 -40
- package/shaders/DepthLimitedBlurShader.mjs +114 -0
- package/shaders/DigitalGlitch.js +74 -46
- package/shaders/DigitalGlitch.mjs +78 -0
- package/shaders/DotScreenShader.js +35 -27
- package/shaders/DotScreenShader.mjs +39 -0
- package/shaders/FXAAShader.js +1094 -19
- package/shaders/FXAAShader.mjs +1098 -0
- package/shaders/FilmShader.js +38 -52
- package/shaders/FilmShader.mjs +42 -0
- package/shaders/FocusShader.js +51 -24
- package/shaders/FocusShader.mjs +55 -0
- package/shaders/FreiChenShader.js +57 -24
- package/shaders/FreiChenShader.mjs +61 -0
- package/shaders/FresnelShader.js +43 -22
- package/shaders/FresnelShader.mjs +47 -0
- package/shaders/GammaCorrectionShader.js +19 -11
- package/shaders/GammaCorrectionShader.mjs +23 -0
- package/shaders/GodRaysShader.js +103 -94
- package/shaders/GodRaysShader.mjs +146 -0
- package/shaders/HalftoneShader.js +208 -65
- package/shaders/HalftoneShader.mjs +212 -0
- package/shaders/HorizontalBlurShader.js +7 -23
- package/shaders/HorizontalBlurShader.mjs +43 -0
- package/shaders/HorizontalTiltShiftShader.js +33 -21
- package/shaders/HorizontalTiltShiftShader.mjs +37 -0
- package/shaders/HueSaturationShader.js +37 -21
- package/shaders/HueSaturationShader.mjs +41 -0
- package/shaders/KaleidoShader.js +30 -22
- package/shaders/KaleidoShader.mjs +34 -0
- package/shaders/LuminosityHighPassShader.js +33 -27
- package/shaders/LuminosityHighPassShader.mjs +37 -0
- package/shaders/LuminosityShader.js +21 -11
- package/shaders/LuminosityShader.mjs +25 -0
- package/shaders/MirrorShader.js +31 -16
- package/shaders/MirrorShader.mjs +35 -0
- package/shaders/NormalMapShader.js +27 -23
- package/shaders/NormalMapShader.mjs +31 -0
- package/shaders/ParallaxShader.js +107 -48
- package/shaders/ParallaxShader.mjs +113 -0
- package/shaders/PixelShader.js +24 -16
- package/shaders/PixelShader.mjs +28 -0
- package/shaders/RGBShiftShader.js +26 -22
- package/shaders/RGBShiftShader.mjs +30 -0
- package/shaders/SAOShader.js +132 -48
- package/shaders/SAOShader.mjs +144 -0
- package/shaders/SMAAShader.js +256 -135
- package/shaders/SMAAShader.mjs +272 -0
- package/shaders/SSAOShader.js +153 -81
- package/shaders/SSAOShader.mjs +172 -0
- package/shaders/SSRShader.js +32 -87
- package/shaders/SSRShader.mjs +324 -0
- package/shaders/SepiaShader.js +25 -15
- package/shaders/SepiaShader.mjs +29 -0
- package/shaders/SobelOperatorShader.js +40 -29
- package/shaders/SobelOperatorShader.mjs +44 -0
- package/shaders/SubsurfaceScatteringShader.js +53 -39
- package/shaders/SubsurfaceScatteringShader.mjs +59 -0
- package/shaders/TechnicolorShader.js +20 -13
- package/shaders/TechnicolorShader.mjs +24 -0
- package/shaders/ToneMapShader.js +44 -28
- package/shaders/ToneMapShader.mjs +48 -0
- package/shaders/ToonShader.js +172 -96
- package/shaders/ToonShader.mjs +188 -0
- package/shaders/TriangleBlurShader.js +32 -23
- package/shaders/TriangleBlurShader.mjs +36 -0
- package/shaders/UnpackDepthRGBAShader.js +22 -14
- package/shaders/UnpackDepthRGBAShader.mjs +26 -0
- package/shaders/VerticalBlurShader.js +7 -23
- package/shaders/VerticalBlurShader.mjs +44 -0
- package/shaders/VerticalTiltShiftShader.js +33 -21
- package/shaders/VerticalTiltShiftShader.mjs +37 -0
- package/shaders/VignetteShader.js +24 -28
- package/shaders/VignetteShader.mjs +28 -0
- package/shaders/VolumeShader.js +174 -77
- package/shaders/VolumeShader.mjs +178 -0
- package/shaders/WaterRefractionShader.js +38 -6
- package/shaders/WaterRefractionShader.mjs +57 -0
- package/shaders/types.js +1 -1
- package/{custom.d.js → shaders/types.mjs} +0 -0
- package/textures/FlakesTexture.js +8 -10
- package/textures/FlakesTexture.mjs +30 -0
- package/types/helpers.js +3 -2
- package/types/helpers.mjs +4 -0
- package/utils/BufferGeometryUtils.js +251 -325
- package/utils/BufferGeometryUtils.mjs +570 -0
- package/utils/GeometryCompressionUtils.js +241 -239
- package/utils/GeometryCompressionUtils.mjs +547 -0
- package/utils/GeometryUtils.js +41 -94
- package/utils/GeometryUtils.mjs +108 -0
- package/utils/RoughnessMipmapper.js +38 -82
- package/utils/RoughnessMipmapper.mjs +213 -0
- package/utils/SceneUtils.js +15 -20
- package/utils/SceneUtils.mjs +36 -0
- package/utils/ShadowMapViewer.js +49 -95
- package/utils/ShadowMapViewer.mjs +114 -0
- package/utils/SkeletonUtils.js +74 -165
- package/utils/SkeletonUtils.mjs +292 -0
- package/utils/UVsDebug.js +32 -62
- package/utils/UVsDebug.mjs +85 -0
- package/utils/WorkerPool.js +13 -33
- package/utils/WorkerPool.mjs +62 -0
- package/webxr/ARButton.js +72 -98
- package/webxr/ARButton.mjs +119 -0
- package/webxr/OculusHandModel.js +18 -37
- package/webxr/OculusHandModel.mjs +71 -0
- package/webxr/OculusHandPointerModel.js +58 -80
- package/webxr/OculusHandPointerModel.mjs +207 -0
- package/webxr/Text2D.js +37 -19
- package/webxr/Text2D.mjs +31 -0
- package/webxr/VRButton.js +59 -90
- package/webxr/VRButton.mjs +105 -0
- package/webxr/XRControllerModelFactory.js +58 -116
- package/webxr/XRControllerModelFactory.mjs +146 -0
- package/webxr/XREstimatedLight.js +39 -66
- package/webxr/XREstimatedLight.mjs +126 -0
- package/webxr/XRHandMeshModel.js +40 -29
- package/webxr/XRHandMeshModel.mjs +73 -0
- package/webxr/XRHandModelFactory.js +28 -31
- package/webxr/XRHandModelFactory.mjs +61 -0
- package/webxr/XRHandPrimitiveModel.js +41 -27
- package/webxr/XRHandPrimitiveModel.mjs +68 -0
- package/BufferGeometryUtils-1a7a235c.js +0 -655
- package/BufferGeometryUtils-971dfde3.js +0 -1
- package/Nodes-4f766d71.js +0 -471
- package/Nodes-9aa16d74.js +0 -1
- package/animation/AnimationClipCreator.cjs.js +0 -1
- package/animation/CCDIKSolver.cjs.js +0 -1
- package/animation/MMDAnimationHelper.cjs.js +0 -1
- package/animation/MMDPhysics.cjs.js +0 -1
- package/cameras/CinematicCamera.cjs.js +0 -1
- package/controls/ArcballControls.cjs.js +0 -1
- package/controls/DeviceOrientationControls.cjs.js +0 -1
- package/controls/DragControls.cjs.js +0 -1
- package/controls/FirstPersonControls.cjs.js +0 -1
- package/controls/FlyControls.cjs.js +0 -1
- package/controls/OrbitControls.cjs.js +0 -1
- package/controls/PointerLockControls.cjs.js +0 -1
- package/controls/TrackballControls.cjs.js +0 -1
- package/controls/TransformControls.cjs.js +0 -1
- package/controls/experimental/CameraControls.cjs.js +0 -1
- package/csm/CSM.cjs.js +0 -1
- package/csm/CSMFrustum.cjs.js +0 -1
- package/csm/CSMHelper.cjs.js +0 -1
- package/csm/CSMShader.cjs.js +0 -1
- package/curves/CurveExtras.cjs.js +0 -1
- package/curves/NURBSCurve.cjs.js +0 -1
- package/curves/NURBSSurface.cjs.js +0 -1
- package/curves/NURBSUtils.cjs.js +0 -1
- package/custom.d.cjs.js +0 -1
- package/deprecated/Geometry.cjs.js +0 -1
- package/effects/AnaglyphEffect.cjs.js +0 -1
- package/effects/AsciiEffect.cjs.js +0 -1
- package/effects/OutlineEffect.cjs.js +0 -1
- package/effects/ParallaxBarrierEffect.cjs.js +0 -1
- package/effects/PeppersGhostEffect.cjs.js +0 -1
- package/effects/StereoEffect.cjs.js +0 -1
- package/environments/RoomEnvironment.cjs.js +0 -1
- package/exporters/ColladaExporter.cjs.js +0 -1
- package/exporters/DRACOExporter.cjs.js +0 -1
- package/exporters/GLTFExporter.cjs.js +0 -1
- package/exporters/MMDExporter.cjs.js +0 -1
- package/exporters/OBJExporter.cjs.js +0 -1
- package/exporters/PLYExporter.cjs.js +0 -1
- package/exporters/STLExporter.cjs.js +0 -1
- package/exporters/USDZExporter.cjs.js +0 -1
- package/geometries/BoxLineGeometry.cjs.js +0 -1
- package/geometries/ConvexGeometry.cjs.js +0 -1
- package/geometries/DecalGeometry.cjs.js +0 -1
- package/geometries/LightningStrike.cjs.js +0 -1
- package/geometries/ParametricGeometries.cjs.js +0 -1
- package/geometries/ParametricGeometry.cjs.js +0 -1
- package/geometries/RoundedBoxGeometry.cjs.js +0 -1
- package/geometries/TeapotGeometry.cjs.js +0 -1
- package/geometries/TextGeometry.cjs.js +0 -1
- package/helpers/LightProbeHelper.cjs.js +0 -1
- package/helpers/PositionalAudioHelper.cjs.js +0 -1
- package/helpers/RectAreaLightHelper.cjs.js +0 -1
- package/helpers/VertexNormalsHelper.cjs.js +0 -1
- package/helpers/VertexTangentsHelper.cjs.js +0 -1
- package/index.cjs.js +0 -1
- package/interactive/InteractiveGroup.cjs.js +0 -1
- package/interactive/InteractiveGroup.d.ts +0 -5
- package/interactive/InteractiveGroup.js +0 -87
- package/interactive/SelectionBox.cjs.js +0 -1
- package/interactive/SelectionHelper.cjs.js +0 -1
- package/libs/MeshoptDecoder.cjs.js +0 -1
- package/libs/MotionControllers.cjs.js +0 -1
- package/lights/LightProbeGenerator.cjs.js +0 -1
- package/lights/RectAreaLightUniformsLib.cjs.js +0 -1
- package/lines/Line2.cjs.js +0 -1
- package/lines/LineGeometry.cjs.js +0 -1
- package/lines/LineMaterial.cjs.js +0 -1
- package/lines/LineSegments2.cjs.js +0 -1
- package/lines/LineSegmentsGeometry.cjs.js +0 -1
- package/lines/Wireframe.cjs.js +0 -1
- package/lines/WireframeGeometry2.cjs.js +0 -1
- package/loaders/3DMLoader.cjs.js +0 -1
- package/loaders/3MFLoader.cjs.js +0 -1
- package/loaders/AMFLoader.cjs.js +0 -1
- package/loaders/AssimpLoader.cjs.js +0 -1
- package/loaders/BVHLoader.cjs.js +0 -1
- package/loaders/BasisTextureLoader.cjs.js +0 -1
- package/loaders/ColladaLoader.cjs.js +0 -1
- package/loaders/DDSLoader.cjs.js +0 -1
- package/loaders/DRACOLoader.cjs.js +0 -1
- package/loaders/EXRLoader.cjs.js +0 -1
- package/loaders/FBXLoader.cjs.js +0 -1
- package/loaders/FontLoader.cjs.js +0 -1
- package/loaders/GCodeLoader.cjs.js +0 -1
- package/loaders/GLTFLoader.cjs.js +0 -1
- package/loaders/HDRCubeTextureLoader.cjs.js +0 -1
- package/loaders/KMZLoader.cjs.js +0 -1
- package/loaders/KTX2Loader.cjs.js +0 -1
- package/loaders/KTXLoader.cjs.js +0 -1
- package/loaders/LDrawLoader.cjs.js +0 -1
- package/loaders/LUT3dlLoader.cjs.js +0 -1
- package/loaders/LUTCubeLoader.cjs.js +0 -1
- package/loaders/LWOLoader.cjs.js +0 -1
- package/loaders/LottieLoader.cjs.js +0 -1
- package/loaders/MD2Loader.cjs.js +0 -1
- package/loaders/MDDLoader.cjs.js +0 -1
- package/loaders/MMDLoader.cjs.js +0 -1
- package/loaders/MTLLoader.cjs.js +0 -1
- package/loaders/NRRDLoader.cjs.js +0 -1
- package/loaders/NodeMaterialLoader.cjs.js +0 -1
- package/loaders/OBJLoader.cjs.js +0 -1
- package/loaders/PCDLoader.cjs.js +0 -1
- package/loaders/PDBLoader.cjs.js +0 -1
- package/loaders/PLYLoader.cjs.js +0 -1
- package/loaders/PRWMLoader.cjs.js +0 -1
- package/loaders/PVRLoader.cjs.js +0 -1
- package/loaders/RGBELoader.cjs.js +0 -1
- package/loaders/RGBMLoader.cjs.js +0 -1
- package/loaders/STLLoader.cjs.js +0 -1
- package/loaders/SVGLoader.cjs.js +0 -1
- package/loaders/TDSLoader.cjs.js +0 -1
- package/loaders/TGALoader.cjs.js +0 -1
- package/loaders/TTFLoader.cjs.js +0 -1
- package/loaders/TiltLoader.cjs.js +0 -1
- package/loaders/VOXLoader.cjs.js +0 -1
- package/loaders/VRMLLoader.cjs.js +0 -1
- package/loaders/VRMLoader.cjs.js +0 -1
- package/loaders/VTKLoader.cjs.js +0 -1
- package/loaders/XLoader.cjs.js +0 -1
- package/loaders/XYZLoader.cjs.js +0 -1
- package/loaders/lwo/IFFParser.cjs.js +0 -1
- package/loaders/lwo/LWO2Parser.cjs.js +0 -1
- package/loaders/lwo/LWO3Parser.cjs.js +0 -1
- package/math/Capsule.cjs.js +0 -1
- package/math/ColorConverter.cjs.js +0 -1
- package/math/ConvexHull.cjs.js +0 -1
- package/math/ImprovedNoise.cjs.js +0 -1
- package/math/Lut.cjs.js +0 -1
- package/math/MeshSurfaceSampler.cjs.js +0 -1
- package/math/OBB.cjs.js +0 -1
- package/math/Octree.cjs.js +0 -1
- package/math/SimplexNoise.cjs.js +0 -1
- package/misc/ConvexObjectBreaker.cjs.js +0 -1
- package/misc/GPUComputationRenderer.cjs.js +0 -1
- package/misc/Gyroscope.cjs.js +0 -1
- package/misc/MD2Character.cjs.js +0 -1
- package/misc/MD2CharacterComplex.cjs.js +0 -1
- package/misc/MorphAnimMesh.cjs.js +0 -1
- package/misc/MorphBlendMesh.cjs.js +0 -1
- package/misc/ProgressiveLightmap.cjs.js +0 -1
- package/misc/RollerCoaster.cjs.js +0 -1
- package/misc/TubePainter.cjs.js +0 -1
- package/misc/Volume.cjs.js +0 -1
- package/misc/VolumeSlice.cjs.js +0 -1
- package/misc/WebGL.cjs.js +0 -1
- package/modifiers/CurveModifier.cjs.js +0 -1
- package/modifiers/EdgeSplitModifier.cjs.js +0 -1
- package/modifiers/SimplifyModifier.cjs.js +0 -1
- package/modifiers/TessellateModifier.cjs.js +0 -1
- package/nodes/Nodes.cjs.js +0 -1
- package/nodes/ShaderNode.cjs.js +0 -1
- package/nodes/accessors/BufferNode.cjs.js +0 -1
- package/nodes/accessors/CameraNode.cjs.js +0 -1
- package/nodes/accessors/CubeTextureNode.cjs.js +0 -1
- package/nodes/accessors/MaterialNode.cjs.js +0 -1
- package/nodes/accessors/MaterialReferenceNode.cjs.js +0 -1
- package/nodes/accessors/ModelNode.cjs.js +0 -1
- package/nodes/accessors/ModelViewProjectionNode.cjs.js +0 -1
- package/nodes/accessors/NormalNode.cjs.js +0 -1
- package/nodes/accessors/Object3DNode.cjs.js +0 -1
- package/nodes/accessors/PointUVNode.cjs.js +0 -1
- package/nodes/accessors/PositionNode.cjs.js +0 -1
- package/nodes/accessors/ReferenceNode.cjs.js +0 -1
- package/nodes/accessors/ReflectNode.cjs.js +0 -1
- package/nodes/accessors/SkinningNode.cjs.js +0 -1
- package/nodes/accessors/TextureNode.cjs.js +0 -1
- package/nodes/accessors/UVNode.cjs.js +0 -1
- package/nodes/core/ArrayUniformNode.cjs.js +0 -1
- package/nodes/core/AttributeNode.cjs.js +0 -1
- package/nodes/core/BypassNode.cjs.js +0 -1
- package/nodes/core/CodeNode.cjs.js +0 -1
- package/nodes/core/ConstNode.cjs.js +0 -1
- package/nodes/core/ContextNode.cjs.js +0 -1
- package/nodes/core/ExpressionNode.cjs.js +0 -1
- package/nodes/core/FunctionCallNode.cjs.js +0 -1
- package/nodes/core/FunctionNode.cjs.js +0 -1
- package/nodes/core/InputNode.cjs.js +0 -1
- package/nodes/core/Node.cjs.js +0 -1
- package/nodes/core/NodeAttribute.cjs.js +0 -1
- package/nodes/core/NodeBuilder.cjs.js +0 -1
- package/nodes/core/NodeCode.cjs.js +0 -1
- package/nodes/core/NodeFrame.cjs.js +0 -1
- package/nodes/core/NodeFunction.cjs.js +0 -1
- package/nodes/core/NodeFunction.js +0 -17
- package/nodes/core/NodeFunctionInput.cjs.js +0 -1
- package/nodes/core/NodeKeywords.cjs.js +0 -1
- package/nodes/core/NodeParser.cjs.js +0 -1
- package/nodes/core/NodeParser.js +0 -8
- package/nodes/core/NodeUniform.cjs.js +0 -1
- package/nodes/core/NodeUtils.cjs.js +0 -1
- package/nodes/core/NodeVar.cjs.js +0 -1
- package/nodes/core/NodeVary.cjs.js +0 -1
- package/nodes/core/PropertyNode.cjs.js +0 -1
- package/nodes/core/TempNode.cjs.js +0 -1
- package/nodes/core/UniformNode.cjs.js +0 -1
- package/nodes/core/VarNode.cjs.js +0 -1
- package/nodes/core/VaryNode.cjs.js +0 -1
- package/nodes/core/constants.cjs.js +0 -1
- package/nodes/display/ColorSpaceNode.cjs.js +0 -1
- package/nodes/display/NormalMapNode.cjs.js +0 -1
- package/nodes/fog/FogNode.cjs.js +0 -1
- package/nodes/fog/FogRangeNode.cjs.js +0 -1
- package/nodes/functions/BSDFs.cjs.js +0 -1
- package/nodes/functions/PhysicalMaterialFunctions.cjs.js +0 -1
- package/nodes/functions/PhysicalMaterialFunctions.js +0 -57
- package/nodes/lights/LightContextNode.cjs.js +0 -1
- package/nodes/lights/LightNode.cjs.js +0 -1
- package/nodes/lights/LightsNode.cjs.js +0 -1
- package/nodes/loaders/NodeLoader.cjs.js +0 -1
- package/nodes/loaders/NodeMaterialLoader.cjs.js +0 -1
- package/nodes/loaders/NodeObjectLoader.cjs.js +0 -1
- package/nodes/materials/LineBasicNodeMaterial.cjs.js +0 -1
- package/nodes/materials/Materials.cjs.js +0 -1
- package/nodes/materials/MeshBasicNodeMaterial.cjs.js +0 -1
- package/nodes/materials/MeshStandardNodeMaterial.cjs.js +0 -1
- package/nodes/materials/NodeMaterial.cjs.js +0 -1
- package/nodes/materials/PointsNodeMaterial.cjs.js +0 -1
- package/nodes/math/CondNode.cjs.js +0 -1
- package/nodes/math/MathNode.cjs.js +0 -1
- package/nodes/math/OperatorNode.cjs.js +0 -1
- package/nodes/parsers/GLSLNodeFunction.cjs.js +0 -1
- package/nodes/parsers/GLSLNodeFunction.js +0 -101
- package/nodes/parsers/GLSLNodeParser.cjs.js +0 -1
- package/nodes/parsers/GLSLNodeParser.js +0 -13
- package/nodes/parsers/WGSLNodeFunction.cjs.js +0 -1
- package/nodes/parsers/WGSLNodeFunction.js +0 -71
- package/nodes/parsers/WGSLNodeParser.cjs.js +0 -1
- package/nodes/parsers/WGSLNodeParser.js +0 -13
- package/nodes/procedural/CheckerNode.cjs.js +0 -1
- package/nodes/utils/ArrayElementNode.cjs.js +0 -1
- package/nodes/utils/ConvertNode.cjs.js +0 -1
- package/nodes/utils/JoinNode.cjs.js +0 -1
- package/nodes/utils/MatcapUVNode.cjs.js +0 -1
- package/nodes/utils/OscNode.cjs.js +0 -1
- package/nodes/utils/SplitNode.cjs.js +0 -1
- package/nodes/utils/SpriteSheetUVNode.cjs.js +0 -1
- package/nodes/utils/TimerNode.cjs.js +0 -1
- package/objects/GroundProjectedEnv.cjs.js +0 -1
- package/objects/Lensflare.cjs.js +0 -1
- package/objects/LightningStorm.cjs.js +0 -1
- package/objects/MarchingCubes.cjs.js +0 -1
- package/objects/Reflector.cjs.js +0 -1
- package/objects/ReflectorForSSRPass.cjs.js +0 -1
- package/objects/ReflectorRTT.cjs.js +0 -1
- package/objects/Refractor.cjs.js +0 -1
- package/objects/ShadowMesh.cjs.js +0 -1
- package/objects/Sky.cjs.js +0 -1
- package/objects/Water.cjs.js +0 -1
- package/objects/Water2.cjs.js +0 -1
- package/offscreen/jank.cjs.js +0 -1
- package/offscreen/offscreen.cjs.js +0 -1
- package/offscreen/scene.cjs.js +0 -1
- package/physics/AmmoPhysics.cjs.js +0 -1
- package/postprocessing/AdaptiveToneMappingPass.cjs.js +0 -1
- package/postprocessing/AfterimagePass.cjs.js +0 -1
- package/postprocessing/BloomPass.cjs.js +0 -1
- package/postprocessing/BokehPass.cjs.js +0 -1
- package/postprocessing/ClearPass.cjs.js +0 -1
- package/postprocessing/CubeTexturePass.cjs.js +0 -1
- package/postprocessing/DotScreenPass.cjs.js +0 -1
- package/postprocessing/EffectComposer.cjs.js +0 -1
- package/postprocessing/FilmPass.cjs.js +0 -1
- package/postprocessing/GlitchPass.cjs.js +0 -1
- package/postprocessing/HalftonePass.cjs.js +0 -1
- package/postprocessing/LUTPass.cjs.js +0 -1
- package/postprocessing/MaskPass.cjs.js +0 -1
- package/postprocessing/OutlinePass.cjs.js +0 -1
- package/postprocessing/Pass.cjs.js +0 -1
- package/postprocessing/RenderPass.cjs.js +0 -1
- package/postprocessing/RenderPixelatedPass.cjs.js +0 -1
- package/postprocessing/SAOPass.cjs.js +0 -1
- package/postprocessing/SMAAPass.cjs.js +0 -1
- package/postprocessing/SSAARenderPass.cjs.js +0 -1
- package/postprocessing/SSAOPass.cjs.js +0 -1
- package/postprocessing/SSRPass.cjs.js +0 -1
- package/postprocessing/SavePass.cjs.js +0 -1
- package/postprocessing/ShaderPass.cjs.js +0 -1
- package/postprocessing/TAARenderPass.cjs.js +0 -1
- package/postprocessing/TexturePass.cjs.js +0 -1
- package/postprocessing/UnrealBloomPass.cjs.js +0 -1
- package/renderers/CSS2DRenderer.cjs.js +0 -1
- package/renderers/CSS3DRenderer.cjs.js +0 -1
- package/renderers/Projector.cjs.js +0 -1
- package/renderers/SVGRenderer.cjs.js +0 -1
- package/renderers/nodes/accessors/CameraNode.cjs.js +0 -1
- package/renderers/nodes/accessors/ModelNode.cjs.js +0 -1
- package/renderers/nodes/accessors/ModelViewProjectionNode.cjs.js +0 -1
- package/renderers/nodes/accessors/NormalNode.cjs.js +0 -1
- package/renderers/nodes/accessors/PositionNode.cjs.js +0 -1
- package/renderers/nodes/accessors/UVNode.cjs.js +0 -1
- package/renderers/nodes/core/AttributeNode.cjs.js +0 -1
- package/renderers/nodes/core/InputNode.cjs.js +0 -1
- package/renderers/nodes/core/Node.cjs.js +0 -1
- package/renderers/nodes/core/NodeAttribute.cjs.js +0 -1
- package/renderers/nodes/core/NodeBuilder.cjs.js +0 -1
- package/renderers/nodes/core/NodeFrame.cjs.js +0 -1
- package/renderers/nodes/core/NodeSlot.cjs.js +0 -1
- package/renderers/nodes/core/NodeUniform.cjs.js +0 -1
- package/renderers/nodes/core/NodeVary.cjs.js +0 -1
- package/renderers/nodes/core/VaryNode.cjs.js +0 -1
- package/renderers/nodes/core/constants.cjs.js +0 -1
- package/renderers/nodes/inputs/ColorNode.cjs.js +0 -1
- package/renderers/nodes/inputs/FloatNode.cjs.js +0 -1
- package/renderers/nodes/inputs/Matrix3Node.cjs.js +0 -1
- package/renderers/nodes/inputs/Matrix4Node.cjs.js +0 -1
- package/renderers/nodes/inputs/TextureNode.cjs.js +0 -1
- package/renderers/nodes/inputs/Vector2Node.cjs.js +0 -1
- package/renderers/nodes/inputs/Vector3Node.cjs.js +0 -1
- package/renderers/nodes/inputs/Vector4Node.cjs.js +0 -1
- package/renderers/nodes/math/MathNode.cjs.js +0 -1
- package/renderers/nodes/math/OperatorNode.cjs.js +0 -1
- package/renderers/nodes/utils/SwitchNode.cjs.js +0 -1
- package/renderers/nodes/utils/TimerNode.cjs.js +0 -1
- package/renderers/webgpu/WebGPU.cjs.js +0 -1
- package/renderers/webgpu/WebGPUAttributes.cjs.js +0 -1
- package/renderers/webgpu/WebGPUBackground.cjs.js +0 -1
- package/renderers/webgpu/WebGPUBinding.cjs.js +0 -1
- package/renderers/webgpu/WebGPUBindings.cjs.js +0 -1
- package/renderers/webgpu/WebGPUComputePipelines.cjs.js +0 -1
- package/renderers/webgpu/WebGPUGeometries.cjs.js +0 -1
- package/renderers/webgpu/WebGPUInfo.cjs.js +0 -1
- package/renderers/webgpu/WebGPUObjects.cjs.js +0 -1
- package/renderers/webgpu/WebGPUProperties.cjs.js +0 -1
- package/renderers/webgpu/WebGPURenderLists.cjs.js +0 -1
- package/renderers/webgpu/WebGPURenderPipelines.cjs.js +0 -1
- package/renderers/webgpu/WebGPURenderer.cjs.js +0 -1
- package/renderers/webgpu/WebGPUSampledTexture.cjs.js +0 -1
- package/renderers/webgpu/WebGPUSampler.cjs.js +0 -1
- package/renderers/webgpu/WebGPUStorageBuffer.cjs.js +0 -1
- package/renderers/webgpu/WebGPUTextureRenderer.cjs.js +0 -1
- package/renderers/webgpu/WebGPUTextureUtils.cjs.js +0 -1
- package/renderers/webgpu/WebGPUTextures.cjs.js +0 -1
- package/renderers/webgpu/WebGPUUniform.cjs.js +0 -1
- package/renderers/webgpu/WebGPUUniformsGroup.cjs.js +0 -1
- package/renderers/webgpu/constants.cjs.js +0 -1
- package/renderers/webgpu/nodes/ShaderLib.cjs.js +0 -1
- package/renderers/webgpu/nodes/WebGPUNodeBuilder.cjs.js +0 -1
- package/renderers/webgpu/nodes/WebGPUNodeUniform.cjs.js +0 -1
- package/renderers/webgpu/nodes/WebGPUNodeUniformsGroup.cjs.js +0 -1
- package/renderers/webgpu/nodes/WebGPUNodes.cjs.js +0 -1
- package/shaders/ACESFilmicToneMappingShader.cjs.js +0 -1
- package/shaders/AfterimageShader.cjs.js +0 -1
- package/shaders/BasicShader.cjs.js +0 -1
- package/shaders/BleachBypassShader.cjs.js +0 -1
- package/shaders/BlendShader.cjs.js +0 -1
- package/shaders/BokehShader.cjs.js +0 -1
- package/shaders/BokehShader2.cjs.js +0 -1
- package/shaders/BrightnessContrastShader.cjs.js +0 -1
- package/shaders/ColorCorrectionShader.cjs.js +0 -1
- package/shaders/ColorifyShader.cjs.js +0 -1
- package/shaders/ConvolutionShader.cjs.js +0 -1
- package/shaders/CopyShader.cjs.js +0 -1
- package/shaders/DOFMipMapShader.cjs.js +0 -1
- package/shaders/DepthLimitedBlurShader.cjs.js +0 -1
- package/shaders/DigitalGlitch.cjs.js +0 -1
- package/shaders/DotScreenShader.cjs.js +0 -1
- package/shaders/FXAAShader.cjs.js +0 -1
- package/shaders/FilmShader.cjs.js +0 -1
- package/shaders/FocusShader.cjs.js +0 -1
- package/shaders/FreiChenShader.cjs.js +0 -1
- package/shaders/FresnelShader.cjs.js +0 -1
- package/shaders/GammaCorrectionShader.cjs.js +0 -1
- package/shaders/GodRaysShader.cjs.js +0 -1
- package/shaders/HalftoneShader.cjs.js +0 -1
- package/shaders/HorizontalBlurShader.cjs.js +0 -1
- package/shaders/HorizontalTiltShiftShader.cjs.js +0 -1
- package/shaders/HueSaturationShader.cjs.js +0 -1
- package/shaders/KaleidoShader.cjs.js +0 -1
- package/shaders/LuminosityHighPassShader.cjs.js +0 -1
- package/shaders/LuminosityShader.cjs.js +0 -1
- package/shaders/MirrorShader.cjs.js +0 -1
- package/shaders/NormalMapShader.cjs.js +0 -1
- package/shaders/ParallaxShader.cjs.js +0 -1
- package/shaders/PixelShader.cjs.js +0 -1
- package/shaders/RGBShiftShader.cjs.js +0 -1
- package/shaders/SAOShader.cjs.js +0 -1
- package/shaders/SMAAShader.cjs.js +0 -1
- package/shaders/SSAOShader.cjs.js +0 -1
- package/shaders/SSRShader.cjs.js +0 -1
- package/shaders/SepiaShader.cjs.js +0 -1
- package/shaders/SobelOperatorShader.cjs.js +0 -1
- package/shaders/SubsurfaceScatteringShader.cjs.js +0 -1
- package/shaders/TechnicolorShader.cjs.js +0 -1
- package/shaders/ToneMapShader.cjs.js +0 -1
- package/shaders/ToonShader.cjs.js +0 -1
- package/shaders/TriangleBlurShader.cjs.js +0 -1
- package/shaders/UnpackDepthRGBAShader.cjs.js +0 -1
- package/shaders/VerticalBlurShader.cjs.js +0 -1
- package/shaders/VerticalTiltShiftShader.cjs.js +0 -1
- package/shaders/VignetteShader.cjs.js +0 -1
- package/shaders/VolumeShader.cjs.js +0 -1
- package/shaders/WaterRefractionShader.cjs.js +0 -1
- package/shaders/types.cjs.js +0 -1
- package/textures/FlakesTexture.cjs.js +0 -1
- package/types/helpers.cjs.js +0 -1
- package/types/shared.cjs.js +0 -1
- package/types/shared.js +0 -1
- package/types/utils.cjs.js +0 -1
- package/types/utils.js +0 -1
- package/utils/BufferGeometryUtils.cjs.js +0 -1
- package/utils/GeometryCompressionUtils.cjs.js +0 -1
- package/utils/GeometryUtils.cjs.js +0 -1
- package/utils/LDrawUtils.cjs.js +0 -1
- package/utils/LDrawUtils.d.ts +0 -5
- package/utils/LDrawUtils.js +0 -144
- package/utils/RoughnessMipmapper.cjs.js +0 -1
- package/utils/SceneUtils.cjs.js +0 -1
- package/utils/ShadowMapViewer.cjs.js +0 -1
- package/utils/SkeletonUtils.cjs.js +0 -1
- package/utils/UVsDebug.cjs.js +0 -1
- package/utils/WorkerPool.cjs.js +0 -1
- package/webxr/ARButton.cjs.js +0 -1
- package/webxr/OculusHandModel.cjs.js +0 -1
- package/webxr/OculusHandPointerModel.cjs.js +0 -1
- package/webxr/Text2D.cjs.js +0 -1
- package/webxr/VRButton.cjs.js +0 -1
- package/webxr/XRControllerModelFactory.cjs.js +0 -1
- package/webxr/XREstimatedLight.cjs.js +0 -1
- package/webxr/XRHandMeshModel.cjs.js +0 -1
- package/webxr/XRHandModelFactory.cjs.js +0 -1
- package/webxr/XRHandPrimitiveModel.cjs.js +0 -1
package/loaders/FBXLoader.js
CHANGED
@@ -1,85 +1,63 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
* Loader loads FBX file and generates Group representing FBX scene.
|
7
|
-
* Requires FBX file to be >= 7.0 and in ASCII or >= 6400 in Binary format
|
8
|
-
* Versions lower than this may load but will probably have errors
|
9
|
-
*
|
10
|
-
* Needs Support:
|
11
|
-
* Morph normals / blend shape normals
|
12
|
-
*
|
13
|
-
* FBX format references:
|
14
|
-
* https://help.autodesk.com/view/FBX/2017/ENU/?guid=__cpp_ref_index_html (C++ SDK reference)
|
15
|
-
*
|
16
|
-
* Binary format specification:
|
17
|
-
* https://code.blender.org/2013/08/fbx-binary-file-format-specification/
|
18
|
-
*/
|
19
|
-
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
3
|
+
const THREE = require("three");
|
4
|
+
const fflate = require("fflate");
|
5
|
+
const NURBSCurve = require("../curves/NURBSCurve.js");
|
20
6
|
let fbxTree;
|
21
7
|
let connections;
|
22
8
|
let sceneGraph;
|
23
|
-
|
24
|
-
class FBXLoader extends Loader {
|
9
|
+
class FBXLoader extends THREE.Loader {
|
25
10
|
constructor(manager) {
|
26
11
|
super(manager);
|
27
12
|
}
|
28
|
-
|
29
13
|
load(url, onLoad, onProgress, onError) {
|
30
14
|
const scope = this;
|
31
|
-
const path = scope.path ===
|
32
|
-
const loader = new FileLoader(this.manager);
|
15
|
+
const path = scope.path === "" ? THREE.LoaderUtils.extractUrlBase(url) : scope.path;
|
16
|
+
const loader = new THREE.FileLoader(this.manager);
|
33
17
|
loader.setPath(scope.path);
|
34
|
-
loader.setResponseType(
|
18
|
+
loader.setResponseType("arraybuffer");
|
35
19
|
loader.setRequestHeader(scope.requestHeader);
|
36
20
|
loader.setWithCredentials(scope.withCredentials);
|
37
|
-
loader.load(
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
21
|
+
loader.load(
|
22
|
+
url,
|
23
|
+
function(buffer) {
|
24
|
+
try {
|
25
|
+
onLoad(scope.parse(buffer, path));
|
26
|
+
} catch (e) {
|
27
|
+
if (onError) {
|
28
|
+
onError(e);
|
29
|
+
} else {
|
30
|
+
console.error(e);
|
31
|
+
}
|
32
|
+
scope.manager.itemError(url);
|
45
33
|
}
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
34
|
+
},
|
35
|
+
onProgress,
|
36
|
+
onError
|
37
|
+
);
|
50
38
|
}
|
51
|
-
|
52
39
|
parse(FBXBuffer, path) {
|
53
40
|
if (isFbxFormatBinary(FBXBuffer)) {
|
54
41
|
fbxTree = new BinaryParser().parse(FBXBuffer);
|
55
42
|
} else {
|
56
43
|
const FBXText = convertArrayBufferToString(FBXBuffer);
|
57
|
-
|
58
44
|
if (!isFbxFormatASCII(FBXText)) {
|
59
|
-
throw new Error(
|
45
|
+
throw new Error("THREE.FBXLoader: Unknown format.");
|
60
46
|
}
|
61
|
-
|
62
|
-
|
63
|
-
throw new Error('THREE.FBXLoader: FBX version not supported, FileVersion: ' + getFbxVersion(FBXText));
|
47
|
+
if (getFbxVersion(FBXText) < 7e3) {
|
48
|
+
throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: " + getFbxVersion(FBXText));
|
64
49
|
}
|
65
|
-
|
66
50
|
fbxTree = new TextParser().parse(FBXText);
|
67
|
-
}
|
68
|
-
|
69
|
-
|
70
|
-
const textureLoader = new TextureLoader(this.manager).setPath(this.resourcePath || path).setCrossOrigin(this.crossOrigin);
|
51
|
+
}
|
52
|
+
const textureLoader = new THREE.TextureLoader(this.manager).setPath(this.resourcePath || path).setCrossOrigin(this.crossOrigin);
|
71
53
|
return new FBXTreeParser(textureLoader, this.manager).parse(fbxTree);
|
72
54
|
}
|
73
|
-
|
74
|
-
} // Parse the FBXTree object returned by the BinaryParser or TextParser and return a Group
|
75
|
-
|
76
|
-
|
55
|
+
}
|
77
56
|
class FBXTreeParser {
|
78
57
|
constructor(textureLoader, manager) {
|
79
58
|
this.textureLoader = textureLoader;
|
80
59
|
this.manager = manager;
|
81
60
|
}
|
82
|
-
|
83
61
|
parse() {
|
84
62
|
connections = this.parseConnections();
|
85
63
|
const images = this.parseImages();
|
@@ -89,70 +67,47 @@ class FBXTreeParser {
|
|
89
67
|
const geometryMap = new GeometryParser().parse(deformers);
|
90
68
|
this.parseScene(deformers, geometryMap, materials);
|
91
69
|
return sceneGraph;
|
92
|
-
}
|
93
|
-
// and details the connection type
|
94
|
-
|
95
|
-
|
70
|
+
}
|
96
71
|
parseConnections() {
|
97
|
-
const connectionMap = new Map();
|
98
|
-
|
99
|
-
if ('Connections' in fbxTree) {
|
72
|
+
const connectionMap = /* @__PURE__ */ new Map();
|
73
|
+
if ("Connections" in fbxTree) {
|
100
74
|
const rawConnections = fbxTree.Connections.connections;
|
101
|
-
rawConnections.forEach(function
|
75
|
+
rawConnections.forEach(function(rawConnection) {
|
102
76
|
const fromID = rawConnection[0];
|
103
77
|
const toID = rawConnection[1];
|
104
78
|
const relationship = rawConnection[2];
|
105
|
-
|
106
79
|
if (!connectionMap.has(fromID)) {
|
107
80
|
connectionMap.set(fromID, {
|
108
81
|
parents: [],
|
109
82
|
children: []
|
110
83
|
});
|
111
84
|
}
|
112
|
-
|
113
|
-
const parentRelationship = {
|
114
|
-
ID: toID,
|
115
|
-
relationship: relationship
|
116
|
-
};
|
85
|
+
const parentRelationship = { ID: toID, relationship };
|
117
86
|
connectionMap.get(fromID).parents.push(parentRelationship);
|
118
|
-
|
119
87
|
if (!connectionMap.has(toID)) {
|
120
88
|
connectionMap.set(toID, {
|
121
89
|
parents: [],
|
122
90
|
children: []
|
123
91
|
});
|
124
92
|
}
|
125
|
-
|
126
|
-
const childRelationship = {
|
127
|
-
ID: fromID,
|
128
|
-
relationship: relationship
|
129
|
-
};
|
93
|
+
const childRelationship = { ID: fromID, relationship };
|
130
94
|
connectionMap.get(toID).children.push(childRelationship);
|
131
95
|
});
|
132
96
|
}
|
133
|
-
|
134
97
|
return connectionMap;
|
135
|
-
}
|
136
|
-
// These images are connected to textures in FBXTree.Objects.Textures
|
137
|
-
// via FBXTree.Connections.
|
138
|
-
|
139
|
-
|
98
|
+
}
|
140
99
|
parseImages() {
|
141
100
|
const images = {};
|
142
101
|
const blobs = {};
|
143
|
-
|
144
|
-
if ('Video' in fbxTree.Objects) {
|
102
|
+
if ("Video" in fbxTree.Objects) {
|
145
103
|
const videoNodes = fbxTree.Objects.Video;
|
146
|
-
|
147
104
|
for (const nodeID in videoNodes) {
|
148
105
|
const videoNode = videoNodes[nodeID];
|
149
106
|
const id = parseInt(nodeID);
|
150
|
-
images[id] = videoNode.RelativeFilename || videoNode.Filename;
|
151
|
-
|
152
|
-
if ('Content' in videoNode) {
|
107
|
+
images[id] = videoNode.RelativeFilename || videoNode.Filename;
|
108
|
+
if ("Content" in videoNode) {
|
153
109
|
const arrayBufferContent = videoNode.Content instanceof ArrayBuffer && videoNode.Content.byteLength > 0;
|
154
|
-
const base64Content = typeof videoNode.Content ===
|
155
|
-
|
110
|
+
const base64Content = typeof videoNode.Content === "string" && videoNode.Content !== "";
|
156
111
|
if (arrayBufferContent || base64Content) {
|
157
112
|
const image = this.parseImage(videoNodes[nodeID]);
|
158
113
|
blobs[videoNode.RelativeFilename || videoNode.Filename] = image;
|
@@ -160,423 +115,314 @@ class FBXTreeParser {
|
|
160
115
|
}
|
161
116
|
}
|
162
117
|
}
|
163
|
-
|
164
118
|
for (const id in images) {
|
165
119
|
const filename = images[id];
|
166
|
-
if (blobs[filename] !==
|
120
|
+
if (blobs[filename] !== void 0)
|
121
|
+
images[id] = blobs[filename];
|
122
|
+
else
|
123
|
+
images[id] = images[id].split("\\").pop();
|
167
124
|
}
|
168
|
-
|
169
125
|
return images;
|
170
|
-
}
|
171
|
-
|
172
|
-
|
126
|
+
}
|
173
127
|
parseImage(videoNode) {
|
174
128
|
const content = videoNode.Content;
|
175
129
|
const fileName = videoNode.RelativeFilename || videoNode.Filename;
|
176
|
-
const extension = fileName.slice(fileName.lastIndexOf(
|
130
|
+
const extension = fileName.slice(fileName.lastIndexOf(".") + 1).toLowerCase();
|
177
131
|
let type;
|
178
|
-
|
179
132
|
switch (extension) {
|
180
|
-
case
|
181
|
-
type =
|
133
|
+
case "bmp":
|
134
|
+
type = "image/bmp";
|
182
135
|
break;
|
183
|
-
|
184
|
-
case
|
185
|
-
|
186
|
-
type = 'image/jpeg';
|
136
|
+
case "jpg":
|
137
|
+
case "jpeg":
|
138
|
+
type = "image/jpeg";
|
187
139
|
break;
|
188
|
-
|
189
|
-
|
190
|
-
type = 'image/png';
|
140
|
+
case "png":
|
141
|
+
type = "image/png";
|
191
142
|
break;
|
192
|
-
|
193
|
-
|
194
|
-
type = 'image/tiff';
|
143
|
+
case "tif":
|
144
|
+
type = "image/tiff";
|
195
145
|
break;
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
console.warn('FBXLoader: TGA loader not found, skipping ', fileName);
|
146
|
+
case "tga":
|
147
|
+
if (this.manager.getHandler(".tga") === null) {
|
148
|
+
console.warn("FBXLoader: TGA loader not found, skipping ", fileName);
|
200
149
|
}
|
201
|
-
|
202
|
-
type = 'image/tga';
|
150
|
+
type = "image/tga";
|
203
151
|
break;
|
204
|
-
|
205
152
|
default:
|
206
153
|
console.warn('FBXLoader: Image type "' + extension + '" is not supported.');
|
207
154
|
return;
|
208
155
|
}
|
209
|
-
|
210
|
-
|
211
|
-
// ASCII format
|
212
|
-
return 'data:' + type + ';base64,' + content;
|
156
|
+
if (typeof content === "string") {
|
157
|
+
return "data:" + type + ";base64," + content;
|
213
158
|
} else {
|
214
|
-
// Binary Format
|
215
159
|
const array = new Uint8Array(content);
|
216
|
-
return window.URL.createObjectURL(new Blob([array], {
|
217
|
-
|
218
|
-
|
219
|
-
}
|
220
|
-
} // Parse nodes in FBXTree.Objects.Texture
|
221
|
-
// These contain details such as UV scaling, cropping, rotation etc and are connected
|
222
|
-
// to images in FBXTree.Objects.Video
|
223
|
-
|
224
|
-
|
160
|
+
return window.URL.createObjectURL(new Blob([array], { type }));
|
161
|
+
}
|
162
|
+
}
|
225
163
|
parseTextures(images) {
|
226
|
-
const textureMap = new Map();
|
227
|
-
|
228
|
-
if ('Texture' in fbxTree.Objects) {
|
164
|
+
const textureMap = /* @__PURE__ */ new Map();
|
165
|
+
if ("Texture" in fbxTree.Objects) {
|
229
166
|
const textureNodes = fbxTree.Objects.Texture;
|
230
|
-
|
231
167
|
for (const nodeID in textureNodes) {
|
232
168
|
const texture = this.parseTexture(textureNodes[nodeID], images);
|
233
169
|
textureMap.set(parseInt(nodeID), texture);
|
234
170
|
}
|
235
171
|
}
|
236
|
-
|
237
172
|
return textureMap;
|
238
|
-
}
|
239
|
-
|
240
|
-
|
173
|
+
}
|
241
174
|
parseTexture(textureNode, images) {
|
242
175
|
const texture = this.loadTexture(textureNode, images);
|
243
176
|
texture.ID = textureNode.id;
|
244
177
|
texture.name = textureNode.attrName;
|
245
178
|
const wrapModeU = textureNode.WrapModeU;
|
246
179
|
const wrapModeV = textureNode.WrapModeV;
|
247
|
-
const valueU = wrapModeU !==
|
248
|
-
const valueV = wrapModeV !==
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
texture.wrapT = valueV === 0 ? RepeatWrapping : ClampToEdgeWrapping;
|
253
|
-
|
254
|
-
if ('Scaling' in textureNode) {
|
180
|
+
const valueU = wrapModeU !== void 0 ? wrapModeU.value : 0;
|
181
|
+
const valueV = wrapModeV !== void 0 ? wrapModeV.value : 0;
|
182
|
+
texture.wrapS = valueU === 0 ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping;
|
183
|
+
texture.wrapT = valueV === 0 ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping;
|
184
|
+
if ("Scaling" in textureNode) {
|
255
185
|
const values = textureNode.Scaling.value;
|
256
186
|
texture.repeat.x = values[0];
|
257
187
|
texture.repeat.y = values[1];
|
258
188
|
}
|
259
|
-
|
260
189
|
return texture;
|
261
|
-
}
|
262
|
-
|
263
|
-
|
190
|
+
}
|
264
191
|
loadTexture(textureNode, images) {
|
265
192
|
let fileName;
|
266
193
|
const currentPath = this.textureLoader.path;
|
267
194
|
const children = connections.get(textureNode.id).children;
|
268
|
-
|
269
|
-
if (children !== undefined && children.length > 0 && images[children[0].ID] !== undefined) {
|
195
|
+
if (children !== void 0 && children.length > 0 && images[children[0].ID] !== void 0) {
|
270
196
|
fileName = images[children[0].ID];
|
271
|
-
|
272
|
-
|
273
|
-
this.textureLoader.setPath(undefined);
|
197
|
+
if (fileName.indexOf("blob:") === 0 || fileName.indexOf("data:") === 0) {
|
198
|
+
this.textureLoader.setPath(void 0);
|
274
199
|
}
|
275
200
|
}
|
276
|
-
|
277
201
|
let texture;
|
278
202
|
const extension = textureNode.FileName.slice(-3).toLowerCase();
|
279
|
-
|
280
|
-
|
281
|
-
const loader = this.manager.getHandler('.tga');
|
282
|
-
|
203
|
+
if (extension === "tga") {
|
204
|
+
const loader = this.manager.getHandler(".tga");
|
283
205
|
if (loader === null) {
|
284
|
-
console.warn(
|
285
|
-
texture = new Texture();
|
206
|
+
console.warn("FBXLoader: TGA loader not found, creating placeholder texture for", textureNode.RelativeFilename);
|
207
|
+
texture = new THREE.Texture();
|
286
208
|
} else {
|
287
209
|
loader.setPath(this.textureLoader.path);
|
288
210
|
texture = loader.load(fileName);
|
289
211
|
}
|
290
|
-
} else if (extension ===
|
291
|
-
console.warn(
|
292
|
-
|
212
|
+
} else if (extension === "psd") {
|
213
|
+
console.warn(
|
214
|
+
"FBXLoader: PSD textures are not supported, creating placeholder texture for",
|
215
|
+
textureNode.RelativeFilename
|
216
|
+
);
|
217
|
+
texture = new THREE.Texture();
|
293
218
|
} else {
|
294
219
|
texture = this.textureLoader.load(fileName);
|
295
220
|
}
|
296
|
-
|
297
221
|
this.textureLoader.setPath(currentPath);
|
298
222
|
return texture;
|
299
|
-
}
|
300
|
-
|
301
|
-
|
223
|
+
}
|
302
224
|
parseMaterials(textureMap) {
|
303
|
-
const materialMap = new Map();
|
304
|
-
|
305
|
-
if ('Material' in fbxTree.Objects) {
|
225
|
+
const materialMap = /* @__PURE__ */ new Map();
|
226
|
+
if ("Material" in fbxTree.Objects) {
|
306
227
|
const materialNodes = fbxTree.Objects.Material;
|
307
|
-
|
308
228
|
for (const nodeID in materialNodes) {
|
309
229
|
const material = this.parseMaterial(materialNodes[nodeID], textureMap);
|
310
|
-
if (material !== null)
|
230
|
+
if (material !== null)
|
231
|
+
materialMap.set(parseInt(nodeID), material);
|
311
232
|
}
|
312
233
|
}
|
313
|
-
|
314
234
|
return materialMap;
|
315
|
-
}
|
316
|
-
// Materials are connected to texture maps in FBXTree.Objects.Textures
|
317
|
-
// FBX format currently only supports Lambert and Phong shading models
|
318
|
-
|
319
|
-
|
235
|
+
}
|
320
236
|
parseMaterial(materialNode, textureMap) {
|
321
237
|
const ID = materialNode.id;
|
322
238
|
const name = materialNode.attrName;
|
323
|
-
let type = materialNode.ShadingModel;
|
324
|
-
|
325
|
-
if (typeof type === 'object') {
|
239
|
+
let type = materialNode.ShadingModel;
|
240
|
+
if (typeof type === "object") {
|
326
241
|
type = type.value;
|
327
|
-
}
|
328
|
-
|
329
|
-
|
330
|
-
if (!connections.has(ID)) return null;
|
242
|
+
}
|
243
|
+
if (!connections.has(ID))
|
244
|
+
return null;
|
331
245
|
const parameters = this.parseParameters(materialNode, textureMap, ID);
|
332
246
|
let material;
|
333
|
-
|
334
247
|
switch (type.toLowerCase()) {
|
335
|
-
case
|
336
|
-
material = new MeshPhongMaterial();
|
248
|
+
case "phong":
|
249
|
+
material = new THREE.MeshPhongMaterial();
|
337
250
|
break;
|
338
|
-
|
339
|
-
|
340
|
-
material = new MeshLambertMaterial();
|
251
|
+
case "lambert":
|
252
|
+
material = new THREE.MeshLambertMaterial();
|
341
253
|
break;
|
342
|
-
|
343
254
|
default:
|
344
255
|
console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.', type);
|
345
|
-
material = new MeshPhongMaterial();
|
256
|
+
material = new THREE.MeshPhongMaterial();
|
346
257
|
break;
|
347
258
|
}
|
348
|
-
|
349
259
|
material.setValues(parameters);
|
350
260
|
material.name = name;
|
351
261
|
return material;
|
352
|
-
}
|
353
|
-
// Also parse the texture map and return any textures associated with the material
|
354
|
-
|
355
|
-
|
262
|
+
}
|
356
263
|
parseParameters(materialNode, textureMap, ID) {
|
357
264
|
const parameters = {};
|
358
|
-
|
359
265
|
if (materialNode.BumpFactor) {
|
360
266
|
parameters.bumpScale = materialNode.BumpFactor.value;
|
361
267
|
}
|
362
|
-
|
363
268
|
if (materialNode.Diffuse) {
|
364
|
-
parameters.color = new Color().fromArray(materialNode.Diffuse.value);
|
365
|
-
} else if (materialNode.DiffuseColor && (materialNode.DiffuseColor.type ===
|
366
|
-
|
367
|
-
parameters.color = new Color().fromArray(materialNode.DiffuseColor.value);
|
269
|
+
parameters.color = new THREE.Color().fromArray(materialNode.Diffuse.value);
|
270
|
+
} else if (materialNode.DiffuseColor && (materialNode.DiffuseColor.type === "Color" || materialNode.DiffuseColor.type === "ColorRGB")) {
|
271
|
+
parameters.color = new THREE.Color().fromArray(materialNode.DiffuseColor.value);
|
368
272
|
}
|
369
|
-
|
370
273
|
if (materialNode.DisplacementFactor) {
|
371
274
|
parameters.displacementScale = materialNode.DisplacementFactor.value;
|
372
275
|
}
|
373
|
-
|
374
276
|
if (materialNode.Emissive) {
|
375
|
-
parameters.emissive = new Color().fromArray(materialNode.Emissive.value);
|
376
|
-
} else if (materialNode.EmissiveColor && (materialNode.EmissiveColor.type ===
|
377
|
-
|
378
|
-
parameters.emissive = new Color().fromArray(materialNode.EmissiveColor.value);
|
277
|
+
parameters.emissive = new THREE.Color().fromArray(materialNode.Emissive.value);
|
278
|
+
} else if (materialNode.EmissiveColor && (materialNode.EmissiveColor.type === "Color" || materialNode.EmissiveColor.type === "ColorRGB")) {
|
279
|
+
parameters.emissive = new THREE.Color().fromArray(materialNode.EmissiveColor.value);
|
379
280
|
}
|
380
|
-
|
381
281
|
if (materialNode.EmissiveFactor) {
|
382
282
|
parameters.emissiveIntensity = parseFloat(materialNode.EmissiveFactor.value);
|
383
283
|
}
|
384
|
-
|
385
284
|
if (materialNode.Opacity) {
|
386
285
|
parameters.opacity = parseFloat(materialNode.Opacity.value);
|
387
286
|
}
|
388
|
-
|
389
|
-
if (parameters.opacity < 1.0) {
|
287
|
+
if (parameters.opacity < 1) {
|
390
288
|
parameters.transparent = true;
|
391
289
|
}
|
392
|
-
|
393
290
|
if (materialNode.ReflectionFactor) {
|
394
291
|
parameters.reflectivity = materialNode.ReflectionFactor.value;
|
395
292
|
}
|
396
|
-
|
397
293
|
if (materialNode.Shininess) {
|
398
294
|
parameters.shininess = materialNode.Shininess.value;
|
399
295
|
}
|
400
|
-
|
401
296
|
if (materialNode.Specular) {
|
402
|
-
parameters.specular = new Color().fromArray(materialNode.Specular.value);
|
403
|
-
} else if (materialNode.SpecularColor && materialNode.SpecularColor.type ===
|
404
|
-
|
405
|
-
parameters.specular = new Color().fromArray(materialNode.SpecularColor.value);
|
297
|
+
parameters.specular = new THREE.Color().fromArray(materialNode.Specular.value);
|
298
|
+
} else if (materialNode.SpecularColor && materialNode.SpecularColor.type === "Color") {
|
299
|
+
parameters.specular = new THREE.Color().fromArray(materialNode.SpecularColor.value);
|
406
300
|
}
|
407
|
-
|
408
301
|
const scope = this;
|
409
|
-
connections.get(ID).children.forEach(function
|
302
|
+
connections.get(ID).children.forEach(function(child) {
|
410
303
|
const type = child.relationship;
|
411
|
-
|
412
304
|
switch (type) {
|
413
|
-
case
|
305
|
+
case "Bump":
|
414
306
|
parameters.bumpMap = scope.getTexture(textureMap, child.ID);
|
415
307
|
break;
|
416
|
-
|
417
|
-
case 'Maya|TEX_ao_map':
|
308
|
+
case "Maya|TEX_ao_map":
|
418
309
|
parameters.aoMap = scope.getTexture(textureMap, child.ID);
|
419
310
|
break;
|
420
|
-
|
421
|
-
case
|
422
|
-
case 'Maya|TEX_color_map':
|
311
|
+
case "DiffuseColor":
|
312
|
+
case "Maya|TEX_color_map":
|
423
313
|
parameters.map = scope.getTexture(textureMap, child.ID);
|
424
|
-
|
425
|
-
|
426
|
-
parameters.map.encoding = sRGBEncoding;
|
314
|
+
if (parameters.map !== void 0) {
|
315
|
+
parameters.map.encoding = THREE.sRGBEncoding;
|
427
316
|
}
|
428
|
-
|
429
317
|
break;
|
430
|
-
|
431
|
-
case 'DisplacementColor':
|
318
|
+
case "DisplacementColor":
|
432
319
|
parameters.displacementMap = scope.getTexture(textureMap, child.ID);
|
433
320
|
break;
|
434
|
-
|
435
|
-
case 'EmissiveColor':
|
321
|
+
case "EmissiveColor":
|
436
322
|
parameters.emissiveMap = scope.getTexture(textureMap, child.ID);
|
437
|
-
|
438
|
-
|
439
|
-
parameters.emissiveMap.encoding = sRGBEncoding;
|
323
|
+
if (parameters.emissiveMap !== void 0) {
|
324
|
+
parameters.emissiveMap.encoding = THREE.sRGBEncoding;
|
440
325
|
}
|
441
|
-
|
442
326
|
break;
|
443
|
-
|
444
|
-
case
|
445
|
-
case 'Maya|TEX_normal_map':
|
327
|
+
case "NormalMap":
|
328
|
+
case "Maya|TEX_normal_map":
|
446
329
|
parameters.normalMap = scope.getTexture(textureMap, child.ID);
|
447
330
|
break;
|
448
|
-
|
449
|
-
case 'ReflectionColor':
|
331
|
+
case "ReflectionColor":
|
450
332
|
parameters.envMap = scope.getTexture(textureMap, child.ID);
|
451
|
-
|
452
|
-
|
453
|
-
parameters.envMap.
|
454
|
-
parameters.envMap.encoding = sRGBEncoding;
|
333
|
+
if (parameters.envMap !== void 0) {
|
334
|
+
parameters.envMap.mapping = THREE.EquirectangularReflectionMapping;
|
335
|
+
parameters.envMap.encoding = THREE.sRGBEncoding;
|
455
336
|
}
|
456
|
-
|
457
337
|
break;
|
458
|
-
|
459
|
-
case 'SpecularColor':
|
338
|
+
case "SpecularColor":
|
460
339
|
parameters.specularMap = scope.getTexture(textureMap, child.ID);
|
461
|
-
|
462
|
-
|
463
|
-
parameters.specularMap.encoding = sRGBEncoding;
|
340
|
+
if (parameters.specularMap !== void 0) {
|
341
|
+
parameters.specularMap.encoding = THREE.sRGBEncoding;
|
464
342
|
}
|
465
|
-
|
466
343
|
break;
|
467
|
-
|
468
|
-
case
|
469
|
-
case 'TransparencyFactor':
|
344
|
+
case "TransparentColor":
|
345
|
+
case "TransparencyFactor":
|
470
346
|
parameters.alphaMap = scope.getTexture(textureMap, child.ID);
|
471
347
|
parameters.transparent = true;
|
472
348
|
break;
|
473
|
-
|
474
|
-
case
|
475
|
-
case
|
476
|
-
|
477
|
-
case 'SpecularFactor': // AKA specularLevel
|
478
|
-
|
479
|
-
case 'VectorDisplacementColor': // NOTE: Seems to be a copy of DisplacementColor
|
480
|
-
|
349
|
+
case "AmbientColor":
|
350
|
+
case "ShininessExponent":
|
351
|
+
case "SpecularFactor":
|
352
|
+
case "VectorDisplacementColor":
|
481
353
|
default:
|
482
|
-
console.warn(
|
354
|
+
console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.", type);
|
483
355
|
break;
|
484
356
|
}
|
485
357
|
});
|
486
358
|
return parameters;
|
487
|
-
}
|
488
|
-
|
489
|
-
|
359
|
+
}
|
490
360
|
getTexture(textureMap, id) {
|
491
|
-
|
492
|
-
|
493
|
-
console.warn('THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer.');
|
361
|
+
if ("LayeredTexture" in fbxTree.Objects && id in fbxTree.Objects.LayeredTexture) {
|
362
|
+
console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer.");
|
494
363
|
id = connections.get(id).children[0].ID;
|
495
364
|
}
|
496
|
-
|
497
365
|
return textureMap.get(id);
|
498
|
-
}
|
499
|
-
// Deformer node can contain skinning or Vertex Cache animation data, however only skinning is supported here
|
500
|
-
// Generates map of Skeleton-like objects for use later when generating and binding skeletons.
|
501
|
-
|
502
|
-
|
366
|
+
}
|
503
367
|
parseDeformers() {
|
504
368
|
const skeletons = {};
|
505
369
|
const morphTargets = {};
|
506
|
-
|
507
|
-
if ('Deformer' in fbxTree.Objects) {
|
370
|
+
if ("Deformer" in fbxTree.Objects) {
|
508
371
|
const DeformerNodes = fbxTree.Objects.Deformer;
|
509
|
-
|
510
372
|
for (const nodeID in DeformerNodes) {
|
511
373
|
const deformerNode = DeformerNodes[nodeID];
|
512
374
|
const relationships = connections.get(parseInt(nodeID));
|
513
|
-
|
514
|
-
if (deformerNode.attrType === 'Skin') {
|
375
|
+
if (deformerNode.attrType === "Skin") {
|
515
376
|
const skeleton = this.parseSkeleton(relationships, DeformerNodes);
|
516
377
|
skeleton.ID = nodeID;
|
517
|
-
|
518
378
|
if (relationships.parents.length > 1) {
|
519
|
-
console.warn(
|
379
|
+
console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported.");
|
520
380
|
}
|
521
|
-
|
522
381
|
skeleton.geometryID = relationships.parents[0].ID;
|
523
382
|
skeletons[nodeID] = skeleton;
|
524
|
-
} else if (deformerNode.attrType ===
|
383
|
+
} else if (deformerNode.attrType === "BlendShape") {
|
525
384
|
const morphTarget = {
|
526
385
|
id: nodeID
|
527
386
|
};
|
528
387
|
morphTarget.rawTargets = this.parseMorphTargets(relationships, DeformerNodes);
|
529
388
|
morphTarget.id = nodeID;
|
530
|
-
|
531
389
|
if (relationships.parents.length > 1) {
|
532
|
-
console.warn(
|
390
|
+
console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported.");
|
533
391
|
}
|
534
|
-
|
535
392
|
morphTargets[nodeID] = morphTarget;
|
536
393
|
}
|
537
394
|
}
|
538
395
|
}
|
539
|
-
|
540
396
|
return {
|
541
|
-
skeletons
|
542
|
-
morphTargets
|
397
|
+
skeletons,
|
398
|
+
morphTargets
|
543
399
|
};
|
544
|
-
}
|
545
|
-
// The top level skeleton node has type 'Skin' and sub nodes have type 'Cluster'
|
546
|
-
// Each skin node represents a skeleton and each cluster node represents a bone
|
547
|
-
|
548
|
-
|
400
|
+
}
|
549
401
|
parseSkeleton(relationships, deformerNodes) {
|
550
402
|
const rawBones = [];
|
551
|
-
relationships.children.forEach(function
|
403
|
+
relationships.children.forEach(function(child) {
|
552
404
|
const boneNode = deformerNodes[child.ID];
|
553
|
-
if (boneNode.attrType !==
|
405
|
+
if (boneNode.attrType !== "Cluster")
|
406
|
+
return;
|
554
407
|
const rawBone = {
|
555
408
|
ID: child.ID,
|
556
409
|
indices: [],
|
557
410
|
weights: [],
|
558
|
-
transformLink: new Matrix4().fromArray(boneNode.TransformLink.a)
|
559
|
-
// linkMode: boneNode.Mode,
|
560
|
-
|
411
|
+
transformLink: new THREE.Matrix4().fromArray(boneNode.TransformLink.a)
|
561
412
|
};
|
562
|
-
|
563
|
-
if ('Indexes' in boneNode) {
|
413
|
+
if ("Indexes" in boneNode) {
|
564
414
|
rawBone.indices = boneNode.Indexes.a;
|
565
415
|
rawBone.weights = boneNode.Weights.a;
|
566
416
|
}
|
567
|
-
|
568
417
|
rawBones.push(rawBone);
|
569
418
|
});
|
570
419
|
return {
|
571
|
-
rawBones
|
420
|
+
rawBones,
|
572
421
|
bones: []
|
573
422
|
};
|
574
|
-
}
|
575
|
-
|
576
|
-
|
423
|
+
}
|
577
424
|
parseMorphTargets(relationships, deformerNodes) {
|
578
425
|
const rawMorphTargets = [];
|
579
|
-
|
580
426
|
for (let i = 0; i < relationships.children.length; i++) {
|
581
427
|
const child = relationships.children[i];
|
582
428
|
const morphTargetNode = deformerNodes[child.ID];
|
@@ -586,126 +432,105 @@ class FBXTreeParser {
|
|
586
432
|
id: morphTargetNode.id,
|
587
433
|
fullWeights: morphTargetNode.FullWeights.a
|
588
434
|
};
|
589
|
-
if (morphTargetNode.attrType !==
|
590
|
-
|
591
|
-
|
435
|
+
if (morphTargetNode.attrType !== "BlendShapeChannel")
|
436
|
+
return;
|
437
|
+
rawMorphTarget.geoID = connections.get(parseInt(child.ID)).children.filter(function(child2) {
|
438
|
+
return child2.relationship === void 0;
|
592
439
|
})[0].ID;
|
593
440
|
rawMorphTargets.push(rawMorphTarget);
|
594
441
|
}
|
595
|
-
|
596
442
|
return rawMorphTargets;
|
597
|
-
}
|
598
|
-
|
599
|
-
|
443
|
+
}
|
600
444
|
parseScene(deformers, geometryMap, materialMap) {
|
601
|
-
sceneGraph = new Group();
|
445
|
+
sceneGraph = new THREE.Group();
|
602
446
|
const modelMap = this.parseModels(deformers.skeletons, geometryMap, materialMap);
|
603
447
|
const modelNodes = fbxTree.Objects.Model;
|
604
448
|
const scope = this;
|
605
|
-
modelMap.forEach(function
|
449
|
+
modelMap.forEach(function(model) {
|
606
450
|
const modelNode = modelNodes[model.ID];
|
607
451
|
scope.setLookAtProperties(model, modelNode);
|
608
452
|
const parentConnections = connections.get(model.ID).parents;
|
609
|
-
parentConnections.forEach(function
|
453
|
+
parentConnections.forEach(function(connection) {
|
610
454
|
const parent = modelMap.get(connection.ID);
|
611
|
-
if (parent !==
|
455
|
+
if (parent !== void 0)
|
456
|
+
parent.add(model);
|
612
457
|
});
|
613
|
-
|
614
458
|
if (model.parent === null) {
|
615
459
|
sceneGraph.add(model);
|
616
460
|
}
|
617
461
|
});
|
618
462
|
this.bindSkeleton(deformers.skeletons, geometryMap, modelMap);
|
619
463
|
this.createAmbientLight();
|
620
|
-
sceneGraph.traverse(function
|
464
|
+
sceneGraph.traverse(function(node) {
|
621
465
|
if (node.userData.transformData) {
|
622
466
|
if (node.parent) {
|
623
467
|
node.userData.transformData.parentMatrix = node.parent.matrix;
|
624
468
|
node.userData.transformData.parentMatrixWorld = node.parent.matrixWorld;
|
625
469
|
}
|
626
|
-
|
627
470
|
const transform = generateTransform(node.userData.transformData);
|
628
471
|
node.applyMatrix4(transform);
|
629
472
|
node.updateWorldMatrix();
|
630
473
|
}
|
631
474
|
});
|
632
|
-
const animations = new AnimationParser().parse();
|
633
|
-
|
475
|
+
const animations = new AnimationParser().parse();
|
634
476
|
if (sceneGraph.children.length === 1 && sceneGraph.children[0].isGroup) {
|
635
477
|
sceneGraph.children[0].animations = animations;
|
636
478
|
sceneGraph = sceneGraph.children[0];
|
637
479
|
}
|
638
|
-
|
639
480
|
sceneGraph.animations = animations;
|
640
|
-
}
|
641
|
-
|
642
|
-
|
481
|
+
}
|
643
482
|
parseModels(skeletons, geometryMap, materialMap) {
|
644
|
-
const modelMap = new Map();
|
483
|
+
const modelMap = /* @__PURE__ */ new Map();
|
645
484
|
const modelNodes = fbxTree.Objects.Model;
|
646
|
-
|
647
485
|
for (const nodeID in modelNodes) {
|
648
486
|
const id = parseInt(nodeID);
|
649
487
|
const node = modelNodes[nodeID];
|
650
488
|
const relationships = connections.get(id);
|
651
489
|
let model = this.buildSkeleton(relationships, skeletons, id, node.attrName);
|
652
|
-
|
653
490
|
if (!model) {
|
654
491
|
switch (node.attrType) {
|
655
|
-
case
|
492
|
+
case "Camera":
|
656
493
|
model = this.createCamera(relationships);
|
657
494
|
break;
|
658
|
-
|
659
|
-
case 'Light':
|
495
|
+
case "Light":
|
660
496
|
model = this.createLight(relationships);
|
661
497
|
break;
|
662
|
-
|
663
|
-
case 'Mesh':
|
498
|
+
case "Mesh":
|
664
499
|
model = this.createMesh(relationships, geometryMap, materialMap);
|
665
500
|
break;
|
666
|
-
|
667
|
-
case 'NurbsCurve':
|
501
|
+
case "NurbsCurve":
|
668
502
|
model = this.createCurve(relationships, geometryMap);
|
669
503
|
break;
|
670
|
-
|
671
|
-
case
|
672
|
-
|
673
|
-
model = new Bone();
|
504
|
+
case "LimbNode":
|
505
|
+
case "Root":
|
506
|
+
model = new THREE.Bone();
|
674
507
|
break;
|
675
|
-
|
676
|
-
case 'Null':
|
508
|
+
case "Null":
|
677
509
|
default:
|
678
|
-
model = new Group();
|
510
|
+
model = new THREE.Group();
|
679
511
|
break;
|
680
512
|
}
|
681
|
-
|
682
|
-
model.name = node.attrName ? PropertyBinding.sanitizeNodeName(node.attrName) : '';
|
513
|
+
model.name = node.attrName ? THREE.PropertyBinding.sanitizeNodeName(node.attrName) : "";
|
683
514
|
model.ID = id;
|
684
515
|
}
|
685
|
-
|
686
516
|
this.getTransformData(model, node);
|
687
517
|
modelMap.set(id, model);
|
688
518
|
}
|
689
|
-
|
690
519
|
return modelMap;
|
691
520
|
}
|
692
|
-
|
693
521
|
buildSkeleton(relationships, skeletons, id, name) {
|
694
522
|
let bone = null;
|
695
|
-
relationships.parents.forEach(function
|
523
|
+
relationships.parents.forEach(function(parent) {
|
696
524
|
for (const ID in skeletons) {
|
697
525
|
const skeleton = skeletons[ID];
|
698
|
-
skeleton.rawBones.forEach(function
|
526
|
+
skeleton.rawBones.forEach(function(rawBone, i) {
|
699
527
|
if (rawBone.ID === parent.ID) {
|
700
528
|
const subBone = bone;
|
701
|
-
bone = new Bone();
|
702
|
-
bone.matrixWorld.copy(rawBone.transformLink);
|
703
|
-
|
704
|
-
bone.name = name ? PropertyBinding.sanitizeNodeName(name) : '';
|
529
|
+
bone = new THREE.Bone();
|
530
|
+
bone.matrixWorld.copy(rawBone.transformLink);
|
531
|
+
bone.name = name ? THREE.PropertyBinding.sanitizeNodeName(name) : "";
|
705
532
|
bone.ID = id;
|
706
|
-
skeleton.bones[i] = bone;
|
707
|
-
// duplicate the bone here and and it as a child of the first bone
|
708
|
-
|
533
|
+
skeleton.bones[i] = bone;
|
709
534
|
if (subBone !== null) {
|
710
535
|
bone.add(subBone);
|
711
536
|
}
|
@@ -714,502 +539,415 @@ class FBXTreeParser {
|
|
714
539
|
}
|
715
540
|
});
|
716
541
|
return bone;
|
717
|
-
}
|
718
|
-
|
719
|
-
|
542
|
+
}
|
720
543
|
createCamera(relationships) {
|
721
544
|
let model;
|
722
545
|
let cameraAttribute;
|
723
|
-
relationships.children.forEach(function
|
546
|
+
relationships.children.forEach(function(child) {
|
724
547
|
const attr = fbxTree.Objects.NodeAttribute[child.ID];
|
725
|
-
|
726
|
-
if (attr !== undefined) {
|
548
|
+
if (attr !== void 0) {
|
727
549
|
cameraAttribute = attr;
|
728
550
|
}
|
729
551
|
});
|
730
|
-
|
731
|
-
|
732
|
-
model = new Object3D();
|
552
|
+
if (cameraAttribute === void 0) {
|
553
|
+
model = new THREE.Object3D();
|
733
554
|
} else {
|
734
555
|
let type = 0;
|
735
|
-
|
736
|
-
if (cameraAttribute.CameraProjectionType !== undefined && cameraAttribute.CameraProjectionType.value === 1) {
|
556
|
+
if (cameraAttribute.CameraProjectionType !== void 0 && cameraAttribute.CameraProjectionType.value === 1) {
|
737
557
|
type = 1;
|
738
558
|
}
|
739
|
-
|
740
559
|
let nearClippingPlane = 1;
|
741
|
-
|
742
|
-
|
743
|
-
nearClippingPlane = cameraAttribute.NearPlane.value / 1000;
|
560
|
+
if (cameraAttribute.NearPlane !== void 0) {
|
561
|
+
nearClippingPlane = cameraAttribute.NearPlane.value / 1e3;
|
744
562
|
}
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
if (cameraAttribute.FarPlane !== undefined) {
|
749
|
-
farClippingPlane = cameraAttribute.FarPlane.value / 1000;
|
563
|
+
let farClippingPlane = 1e3;
|
564
|
+
if (cameraAttribute.FarPlane !== void 0) {
|
565
|
+
farClippingPlane = cameraAttribute.FarPlane.value / 1e3;
|
750
566
|
}
|
751
|
-
|
752
567
|
let width = window.innerWidth;
|
753
568
|
let height = window.innerHeight;
|
754
|
-
|
755
|
-
if (cameraAttribute.AspectWidth !== undefined && cameraAttribute.AspectHeight !== undefined) {
|
569
|
+
if (cameraAttribute.AspectWidth !== void 0 && cameraAttribute.AspectHeight !== void 0) {
|
756
570
|
width = cameraAttribute.AspectWidth.value;
|
757
571
|
height = cameraAttribute.AspectHeight.value;
|
758
572
|
}
|
759
|
-
|
760
573
|
const aspect = width / height;
|
761
574
|
let fov = 45;
|
762
|
-
|
763
|
-
if (cameraAttribute.FieldOfView !== undefined) {
|
575
|
+
if (cameraAttribute.FieldOfView !== void 0) {
|
764
576
|
fov = cameraAttribute.FieldOfView.value;
|
765
577
|
}
|
766
|
-
|
767
578
|
const focalLength = cameraAttribute.FocalLength ? cameraAttribute.FocalLength.value : null;
|
768
|
-
|
769
579
|
switch (type) {
|
770
580
|
case 0:
|
771
|
-
|
772
|
-
|
773
|
-
|
581
|
+
model = new THREE.PerspectiveCamera(fov, aspect, nearClippingPlane, farClippingPlane);
|
582
|
+
if (focalLength !== null)
|
583
|
+
model.setFocalLength(focalLength);
|
774
584
|
break;
|
775
|
-
|
776
585
|
case 1:
|
777
|
-
|
778
|
-
|
586
|
+
model = new THREE.OrthographicCamera(
|
587
|
+
-width / 2,
|
588
|
+
width / 2,
|
589
|
+
height / 2,
|
590
|
+
-height / 2,
|
591
|
+
nearClippingPlane,
|
592
|
+
farClippingPlane
|
593
|
+
);
|
779
594
|
break;
|
780
|
-
|
781
595
|
default:
|
782
|
-
console.warn(
|
783
|
-
model = new Object3D();
|
596
|
+
console.warn("THREE.FBXLoader: Unknown camera type " + type + ".");
|
597
|
+
model = new THREE.Object3D();
|
784
598
|
break;
|
785
599
|
}
|
786
600
|
}
|
787
|
-
|
788
601
|
return model;
|
789
|
-
}
|
790
|
-
|
791
|
-
|
602
|
+
}
|
792
603
|
createLight(relationships) {
|
793
604
|
let model;
|
794
605
|
let lightAttribute;
|
795
|
-
relationships.children.forEach(function
|
606
|
+
relationships.children.forEach(function(child) {
|
796
607
|
const attr = fbxTree.Objects.NodeAttribute[child.ID];
|
797
|
-
|
798
|
-
if (attr !== undefined) {
|
608
|
+
if (attr !== void 0) {
|
799
609
|
lightAttribute = attr;
|
800
610
|
}
|
801
611
|
});
|
802
|
-
|
803
|
-
|
804
|
-
model = new Object3D();
|
612
|
+
if (lightAttribute === void 0) {
|
613
|
+
model = new THREE.Object3D();
|
805
614
|
} else {
|
806
|
-
let type;
|
807
|
-
|
808
|
-
if (lightAttribute.LightType === undefined) {
|
615
|
+
let type;
|
616
|
+
if (lightAttribute.LightType === void 0) {
|
809
617
|
type = 0;
|
810
618
|
} else {
|
811
619
|
type = lightAttribute.LightType.value;
|
812
620
|
}
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
if (lightAttribute.Color !== undefined) {
|
817
|
-
color = new Color().fromArray(lightAttribute.Color.value);
|
621
|
+
let color = 16777215;
|
622
|
+
if (lightAttribute.Color !== void 0) {
|
623
|
+
color = new THREE.Color().fromArray(lightAttribute.Color.value);
|
818
624
|
}
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
if (lightAttribute.CastLightOnObject !== undefined && lightAttribute.CastLightOnObject.value === 0) {
|
625
|
+
let intensity = lightAttribute.Intensity === void 0 ? 1 : lightAttribute.Intensity.value / 100;
|
626
|
+
if (lightAttribute.CastLightOnObject !== void 0 && lightAttribute.CastLightOnObject.value === 0) {
|
823
627
|
intensity = 0;
|
824
628
|
}
|
825
|
-
|
826
629
|
let distance = 0;
|
827
|
-
|
828
|
-
|
829
|
-
if (lightAttribute.EnableFarAttenuation !== undefined && lightAttribute.EnableFarAttenuation.value === 0) {
|
630
|
+
if (lightAttribute.FarAttenuationEnd !== void 0) {
|
631
|
+
if (lightAttribute.EnableFarAttenuation !== void 0 && lightAttribute.EnableFarAttenuation.value === 0) {
|
830
632
|
distance = 0;
|
831
633
|
} else {
|
832
634
|
distance = lightAttribute.FarAttenuationEnd.value;
|
833
635
|
}
|
834
|
-
}
|
835
|
-
|
836
|
-
|
636
|
+
}
|
837
637
|
const decay = 1;
|
838
|
-
|
839
638
|
switch (type) {
|
840
639
|
case 0:
|
841
|
-
|
842
|
-
model = new PointLight(color, intensity, distance, decay);
|
640
|
+
model = new THREE.PointLight(color, intensity, distance, decay);
|
843
641
|
break;
|
844
|
-
|
845
642
|
case 1:
|
846
|
-
|
847
|
-
model = new DirectionalLight(color, intensity);
|
643
|
+
model = new THREE.DirectionalLight(color, intensity);
|
848
644
|
break;
|
849
|
-
|
850
645
|
case 2:
|
851
|
-
// Spot
|
852
646
|
let angle = Math.PI / 3;
|
853
|
-
|
854
|
-
|
855
|
-
angle = MathUtils.degToRad(lightAttribute.InnerAngle.value);
|
647
|
+
if (lightAttribute.InnerAngle !== void 0) {
|
648
|
+
angle = THREE.MathUtils.degToRad(lightAttribute.InnerAngle.value);
|
856
649
|
}
|
857
|
-
|
858
650
|
let penumbra = 0;
|
859
|
-
|
860
|
-
|
861
|
-
// TODO: this is not correct - FBX calculates outer and inner angle in degrees
|
862
|
-
// with OuterAngle > InnerAngle && OuterAngle <= Math.PI
|
863
|
-
// while three.js uses a penumbra between (0, 1) to attenuate the inner angle
|
864
|
-
penumbra = MathUtils.degToRad(lightAttribute.OuterAngle.value);
|
651
|
+
if (lightAttribute.OuterAngle !== void 0) {
|
652
|
+
penumbra = THREE.MathUtils.degToRad(lightAttribute.OuterAngle.value);
|
865
653
|
penumbra = Math.max(penumbra, 1);
|
866
654
|
}
|
867
|
-
|
868
|
-
model = new SpotLight(color, intensity, distance, angle, penumbra, decay);
|
655
|
+
model = new THREE.SpotLight(color, intensity, distance, angle, penumbra, decay);
|
869
656
|
break;
|
870
|
-
|
871
657
|
default:
|
872
|
-
console.warn(
|
873
|
-
|
658
|
+
console.warn(
|
659
|
+
"THREE.FBXLoader: Unknown light type " + lightAttribute.LightType.value + ", defaulting to a PointLight."
|
660
|
+
);
|
661
|
+
model = new THREE.PointLight(color, intensity);
|
874
662
|
break;
|
875
663
|
}
|
876
|
-
|
877
|
-
if (lightAttribute.CastShadows !== undefined && lightAttribute.CastShadows.value === 1) {
|
664
|
+
if (lightAttribute.CastShadows !== void 0 && lightAttribute.CastShadows.value === 1) {
|
878
665
|
model.castShadow = true;
|
879
666
|
}
|
880
667
|
}
|
881
|
-
|
882
668
|
return model;
|
883
669
|
}
|
884
|
-
|
885
670
|
createMesh(relationships, geometryMap, materialMap) {
|
886
671
|
let model;
|
887
672
|
let geometry = null;
|
888
673
|
let material = null;
|
889
|
-
const materials = [];
|
890
|
-
|
891
|
-
relationships.children.forEach(function (child) {
|
674
|
+
const materials = [];
|
675
|
+
relationships.children.forEach(function(child) {
|
892
676
|
if (geometryMap.has(child.ID)) {
|
893
677
|
geometry = geometryMap.get(child.ID);
|
894
678
|
}
|
895
|
-
|
896
679
|
if (materialMap.has(child.ID)) {
|
897
680
|
materials.push(materialMap.get(child.ID));
|
898
681
|
}
|
899
682
|
});
|
900
|
-
|
901
683
|
if (materials.length > 1) {
|
902
684
|
material = materials;
|
903
685
|
} else if (materials.length > 0) {
|
904
686
|
material = materials[0];
|
905
687
|
} else {
|
906
|
-
material = new MeshPhongMaterial({
|
907
|
-
color: 0xcccccc
|
908
|
-
});
|
688
|
+
material = new THREE.MeshPhongMaterial({ color: 13421772 });
|
909
689
|
materials.push(material);
|
910
690
|
}
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
material.vertexColors = true;
|
691
|
+
if ("color" in geometry.attributes) {
|
692
|
+
materials.forEach(function(material2) {
|
693
|
+
material2.vertexColors = true;
|
915
694
|
});
|
916
695
|
}
|
917
|
-
|
918
696
|
if (geometry.FBX_Deformer) {
|
919
|
-
model = new SkinnedMesh(geometry, material);
|
697
|
+
model = new THREE.SkinnedMesh(geometry, material);
|
920
698
|
model.normalizeSkinWeights();
|
921
699
|
} else {
|
922
|
-
model = new Mesh(geometry, material);
|
700
|
+
model = new THREE.Mesh(geometry, material);
|
923
701
|
}
|
924
|
-
|
925
702
|
return model;
|
926
703
|
}
|
927
|
-
|
928
704
|
createCurve(relationships, geometryMap) {
|
929
|
-
const geometry = relationships.children.reduce(function
|
930
|
-
if (geometryMap.has(child.ID))
|
705
|
+
const geometry = relationships.children.reduce(function(geo, child) {
|
706
|
+
if (geometryMap.has(child.ID))
|
707
|
+
geo = geometryMap.get(child.ID);
|
931
708
|
return geo;
|
932
|
-
}, null);
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
linewidth: 1
|
937
|
-
});
|
938
|
-
return new Line(geometry, material);
|
939
|
-
} // parse the model node for transform data
|
940
|
-
|
941
|
-
|
709
|
+
}, null);
|
710
|
+
const material = new THREE.LineBasicMaterial({ color: 3342591, linewidth: 1 });
|
711
|
+
return new THREE.Line(geometry, material);
|
712
|
+
}
|
942
713
|
getTransformData(model, modelNode) {
|
943
714
|
const transformData = {};
|
944
|
-
if (
|
945
|
-
|
946
|
-
if (
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
if (
|
951
|
-
|
952
|
-
if (
|
953
|
-
|
954
|
-
if (
|
715
|
+
if ("InheritType" in modelNode)
|
716
|
+
transformData.inheritType = parseInt(modelNode.InheritType.value);
|
717
|
+
if ("RotationOrder" in modelNode)
|
718
|
+
transformData.eulerOrder = getEulerOrder(modelNode.RotationOrder.value);
|
719
|
+
else
|
720
|
+
transformData.eulerOrder = "ZYX";
|
721
|
+
if ("Lcl_Translation" in modelNode)
|
722
|
+
transformData.translation = modelNode.Lcl_Translation.value;
|
723
|
+
if ("PreRotation" in modelNode)
|
724
|
+
transformData.preRotation = modelNode.PreRotation.value;
|
725
|
+
if ("Lcl_Rotation" in modelNode)
|
726
|
+
transformData.rotation = modelNode.Lcl_Rotation.value;
|
727
|
+
if ("PostRotation" in modelNode)
|
728
|
+
transformData.postRotation = modelNode.PostRotation.value;
|
729
|
+
if ("Lcl_Scaling" in modelNode)
|
730
|
+
transformData.scale = modelNode.Lcl_Scaling.value;
|
731
|
+
if ("ScalingOffset" in modelNode)
|
732
|
+
transformData.scalingOffset = modelNode.ScalingOffset.value;
|
733
|
+
if ("ScalingPivot" in modelNode)
|
734
|
+
transformData.scalingPivot = modelNode.ScalingPivot.value;
|
735
|
+
if ("RotationOffset" in modelNode)
|
736
|
+
transformData.rotationOffset = modelNode.RotationOffset.value;
|
737
|
+
if ("RotationPivot" in modelNode)
|
738
|
+
transformData.rotationPivot = modelNode.RotationPivot.value;
|
955
739
|
model.userData.transformData = transformData;
|
956
740
|
}
|
957
|
-
|
958
741
|
setLookAtProperties(model, modelNode) {
|
959
|
-
if (
|
742
|
+
if ("LookAtProperty" in modelNode) {
|
960
743
|
const children = connections.get(model.ID).children;
|
961
|
-
children.forEach(function
|
962
|
-
if (child.relationship ===
|
744
|
+
children.forEach(function(child) {
|
745
|
+
if (child.relationship === "LookAtProperty") {
|
963
746
|
const lookAtTarget = fbxTree.Objects.Model[child.ID];
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
if (model.target !== undefined) {
|
747
|
+
if ("Lcl_Translation" in lookAtTarget) {
|
748
|
+
const pos = lookAtTarget.Lcl_Translation.value;
|
749
|
+
if (model.target !== void 0) {
|
969
750
|
model.target.position.fromArray(pos);
|
970
751
|
sceneGraph.add(model.target);
|
971
752
|
} else {
|
972
|
-
|
973
|
-
model.lookAt(new Vector3().fromArray(pos));
|
753
|
+
model.lookAt(new THREE.Vector3().fromArray(pos));
|
974
754
|
}
|
975
755
|
}
|
976
756
|
}
|
977
757
|
});
|
978
758
|
}
|
979
759
|
}
|
980
|
-
|
981
760
|
bindSkeleton(skeletons, geometryMap, modelMap) {
|
982
761
|
const bindMatrices = this.parsePoseNodes();
|
983
|
-
|
984
762
|
for (const ID in skeletons) {
|
985
763
|
const skeleton = skeletons[ID];
|
986
764
|
const parents = connections.get(parseInt(skeleton.ID)).parents;
|
987
|
-
parents.forEach(function
|
765
|
+
parents.forEach(function(parent) {
|
988
766
|
if (geometryMap.has(parent.ID)) {
|
989
767
|
const geoID = parent.ID;
|
990
768
|
const geoRelationships = connections.get(geoID);
|
991
|
-
geoRelationships.parents.forEach(function
|
769
|
+
geoRelationships.parents.forEach(function(geoConnParent) {
|
992
770
|
if (modelMap.has(geoConnParent.ID)) {
|
993
771
|
const model = modelMap.get(geoConnParent.ID);
|
994
|
-
model.bind(new Skeleton(skeleton.bones), bindMatrices[geoConnParent.ID]);
|
772
|
+
model.bind(new THREE.Skeleton(skeleton.bones), bindMatrices[geoConnParent.ID]);
|
995
773
|
}
|
996
774
|
});
|
997
775
|
}
|
998
776
|
});
|
999
777
|
}
|
1000
778
|
}
|
1001
|
-
|
1002
779
|
parsePoseNodes() {
|
1003
780
|
const bindMatrices = {};
|
1004
|
-
|
1005
|
-
if ('Pose' in fbxTree.Objects) {
|
781
|
+
if ("Pose" in fbxTree.Objects) {
|
1006
782
|
const BindPoseNode = fbxTree.Objects.Pose;
|
1007
|
-
|
1008
783
|
for (const nodeID in BindPoseNode) {
|
1009
|
-
if (BindPoseNode[nodeID].attrType ===
|
784
|
+
if (BindPoseNode[nodeID].attrType === "BindPose" && BindPoseNode[nodeID].NbPoseNodes > 0) {
|
1010
785
|
const poseNodes = BindPoseNode[nodeID].PoseNode;
|
1011
|
-
|
1012
786
|
if (Array.isArray(poseNodes)) {
|
1013
|
-
poseNodes.forEach(function
|
1014
|
-
bindMatrices[poseNode.Node] = new Matrix4().fromArray(poseNode.Matrix.a);
|
787
|
+
poseNodes.forEach(function(poseNode) {
|
788
|
+
bindMatrices[poseNode.Node] = new THREE.Matrix4().fromArray(poseNode.Matrix.a);
|
1015
789
|
});
|
1016
790
|
} else {
|
1017
|
-
bindMatrices[poseNodes.Node] = new Matrix4().fromArray(poseNodes.Matrix.a);
|
791
|
+
bindMatrices[poseNodes.Node] = new THREE.Matrix4().fromArray(poseNodes.Matrix.a);
|
1018
792
|
}
|
1019
793
|
}
|
1020
794
|
}
|
1021
795
|
}
|
1022
|
-
|
1023
796
|
return bindMatrices;
|
1024
|
-
}
|
1025
|
-
|
1026
|
-
|
797
|
+
}
|
1027
798
|
createAmbientLight() {
|
1028
|
-
if (
|
799
|
+
if ("GlobalSettings" in fbxTree && "AmbientColor" in fbxTree.GlobalSettings) {
|
1029
800
|
const ambientColor = fbxTree.GlobalSettings.AmbientColor.value;
|
1030
801
|
const r = ambientColor[0];
|
1031
802
|
const g = ambientColor[1];
|
1032
803
|
const b = ambientColor[2];
|
1033
|
-
|
1034
804
|
if (r !== 0 || g !== 0 || b !== 0) {
|
1035
|
-
const color = new Color(r, g, b);
|
1036
|
-
sceneGraph.add(new AmbientLight(color, 1));
|
805
|
+
const color = new THREE.Color(r, g, b);
|
806
|
+
sceneGraph.add(new THREE.AmbientLight(color, 1));
|
1037
807
|
}
|
1038
808
|
}
|
1039
809
|
}
|
1040
|
-
|
1041
|
-
} // parse Geometry data from FBXTree and return map of BufferGeometries
|
1042
|
-
|
1043
|
-
|
810
|
+
}
|
1044
811
|
class GeometryParser {
|
1045
|
-
// Parse nodes in FBXTree.Objects.Geometry
|
1046
812
|
parse(deformers) {
|
1047
|
-
const geometryMap = new Map();
|
1048
|
-
|
1049
|
-
if ('Geometry' in fbxTree.Objects) {
|
813
|
+
const geometryMap = /* @__PURE__ */ new Map();
|
814
|
+
if ("Geometry" in fbxTree.Objects) {
|
1050
815
|
const geoNodes = fbxTree.Objects.Geometry;
|
1051
|
-
|
1052
816
|
for (const nodeID in geoNodes) {
|
1053
817
|
const relationships = connections.get(parseInt(nodeID));
|
1054
818
|
const geo = this.parseGeometry(relationships, geoNodes[nodeID], deformers);
|
1055
819
|
geometryMap.set(parseInt(nodeID), geo);
|
1056
820
|
}
|
1057
821
|
}
|
1058
|
-
|
1059
822
|
return geometryMap;
|
1060
|
-
}
|
1061
|
-
|
1062
|
-
|
823
|
+
}
|
1063
824
|
parseGeometry(relationships, geoNode, deformers) {
|
1064
825
|
switch (geoNode.attrType) {
|
1065
|
-
case
|
826
|
+
case "Mesh":
|
1066
827
|
return this.parseMeshGeometry(relationships, geoNode, deformers);
|
1067
|
-
|
1068
|
-
case
|
828
|
+
break;
|
829
|
+
case "NurbsCurve":
|
1069
830
|
return this.parseNurbsGeometry(geoNode);
|
831
|
+
break;
|
1070
832
|
}
|
1071
|
-
}
|
1072
|
-
|
1073
|
-
|
833
|
+
}
|
1074
834
|
parseMeshGeometry(relationships, geoNode, deformers) {
|
1075
835
|
const skeletons = deformers.skeletons;
|
1076
836
|
const morphTargets = [];
|
1077
|
-
const modelNodes = relationships.parents.map(function
|
837
|
+
const modelNodes = relationships.parents.map(function(parent) {
|
1078
838
|
return fbxTree.Objects.Model[parent.ID];
|
1079
|
-
});
|
1080
|
-
|
1081
|
-
|
1082
|
-
const skeleton = relationships.children.reduce(function
|
1083
|
-
if (skeletons[child.ID] !==
|
1084
|
-
|
839
|
+
});
|
840
|
+
if (modelNodes.length === 0)
|
841
|
+
return;
|
842
|
+
const skeleton = relationships.children.reduce(function(skeleton2, child) {
|
843
|
+
if (skeletons[child.ID] !== void 0)
|
844
|
+
skeleton2 = skeletons[child.ID];
|
845
|
+
return skeleton2;
|
1085
846
|
}, null);
|
1086
|
-
relationships.children.forEach(function
|
1087
|
-
if (deformers.morphTargets[child.ID] !==
|
847
|
+
relationships.children.forEach(function(child) {
|
848
|
+
if (deformers.morphTargets[child.ID] !== void 0) {
|
1088
849
|
morphTargets.push(deformers.morphTargets[child.ID]);
|
1089
850
|
}
|
1090
|
-
});
|
1091
|
-
// if there is more than one model associated with the geometry this may cause problems
|
1092
|
-
|
851
|
+
});
|
1093
852
|
const modelNode = modelNodes[0];
|
1094
853
|
const transformData = {};
|
1095
|
-
if (
|
1096
|
-
|
1097
|
-
if (
|
1098
|
-
|
1099
|
-
if (
|
854
|
+
if ("RotationOrder" in modelNode)
|
855
|
+
transformData.eulerOrder = getEulerOrder(modelNode.RotationOrder.value);
|
856
|
+
if ("InheritType" in modelNode)
|
857
|
+
transformData.inheritType = parseInt(modelNode.InheritType.value);
|
858
|
+
if ("GeometricTranslation" in modelNode)
|
859
|
+
transformData.translation = modelNode.GeometricTranslation.value;
|
860
|
+
if ("GeometricRotation" in modelNode)
|
861
|
+
transformData.rotation = modelNode.GeometricRotation.value;
|
862
|
+
if ("GeometricScaling" in modelNode)
|
863
|
+
transformData.scale = modelNode.GeometricScaling.value;
|
1100
864
|
const transform = generateTransform(transformData);
|
1101
865
|
return this.genGeometry(geoNode, skeleton, morphTargets, transform);
|
1102
|
-
}
|
1103
|
-
|
1104
|
-
|
866
|
+
}
|
1105
867
|
genGeometry(geoNode, skeleton, morphTargets, preTransform) {
|
1106
|
-
const geo = new BufferGeometry();
|
1107
|
-
if (geoNode.attrName)
|
868
|
+
const geo = new THREE.BufferGeometry();
|
869
|
+
if (geoNode.attrName)
|
870
|
+
geo.name = geoNode.attrName;
|
1108
871
|
const geoInfo = this.parseGeoNode(geoNode, skeleton);
|
1109
872
|
const buffers = this.genBuffers(geoInfo);
|
1110
|
-
const positionAttribute = new Float32BufferAttribute(buffers.vertex, 3);
|
873
|
+
const positionAttribute = new THREE.Float32BufferAttribute(buffers.vertex, 3);
|
1111
874
|
positionAttribute.applyMatrix4(preTransform);
|
1112
|
-
geo.setAttribute(
|
1113
|
-
|
875
|
+
geo.setAttribute("position", positionAttribute);
|
1114
876
|
if (buffers.colors.length > 0) {
|
1115
|
-
geo.setAttribute(
|
877
|
+
geo.setAttribute("color", new THREE.Float32BufferAttribute(buffers.colors, 3));
|
1116
878
|
}
|
1117
|
-
|
1118
879
|
if (skeleton) {
|
1119
|
-
geo.setAttribute(
|
1120
|
-
geo.setAttribute(
|
1121
|
-
|
880
|
+
geo.setAttribute("skinIndex", new THREE.Uint16BufferAttribute(buffers.weightsIndices, 4));
|
881
|
+
geo.setAttribute("skinWeight", new THREE.Float32BufferAttribute(buffers.vertexWeights, 4));
|
1122
882
|
geo.FBX_Deformer = skeleton;
|
1123
883
|
}
|
1124
|
-
|
1125
884
|
if (buffers.normal.length > 0) {
|
1126
|
-
const normalMatrix = new Matrix3().getNormalMatrix(preTransform);
|
1127
|
-
const normalAttribute = new Float32BufferAttribute(buffers.normal, 3);
|
885
|
+
const normalMatrix = new THREE.Matrix3().getNormalMatrix(preTransform);
|
886
|
+
const normalAttribute = new THREE.Float32BufferAttribute(buffers.normal, 3);
|
1128
887
|
normalAttribute.applyNormalMatrix(normalMatrix);
|
1129
|
-
geo.setAttribute(
|
888
|
+
geo.setAttribute("normal", normalAttribute);
|
1130
889
|
}
|
1131
|
-
|
1132
|
-
|
1133
|
-
// subsequent uv buffers are called 'uv1', 'uv2', ...
|
1134
|
-
let name = 'uv' + (i + 1).toString(); // the first uv buffer is just called 'uv'
|
1135
|
-
|
890
|
+
buffers.uvs.forEach(function(uvBuffer, i) {
|
891
|
+
let name = "uv" + (i + 1).toString();
|
1136
892
|
if (i === 0) {
|
1137
|
-
name =
|
893
|
+
name = "uv";
|
1138
894
|
}
|
1139
|
-
|
1140
|
-
geo.setAttribute(name, new Float32BufferAttribute(buffers.uvs[i], 2));
|
895
|
+
geo.setAttribute(name, new THREE.Float32BufferAttribute(buffers.uvs[i], 2));
|
1141
896
|
});
|
1142
|
-
|
1143
|
-
if (geoInfo.material && geoInfo.material.mappingType !== 'AllSame') {
|
1144
|
-
// Convert the material indices of each vertex into rendering groups on the geometry.
|
897
|
+
if (geoInfo.material && geoInfo.material.mappingType !== "AllSame") {
|
1145
898
|
let prevMaterialIndex = buffers.materialIndex[0];
|
1146
899
|
let startIndex = 0;
|
1147
|
-
buffers.materialIndex.forEach(function
|
900
|
+
buffers.materialIndex.forEach(function(currentIndex, i) {
|
1148
901
|
if (currentIndex !== prevMaterialIndex) {
|
1149
902
|
geo.addGroup(startIndex, i - startIndex, prevMaterialIndex);
|
1150
903
|
prevMaterialIndex = currentIndex;
|
1151
904
|
startIndex = i;
|
1152
905
|
}
|
1153
|
-
});
|
1154
|
-
|
906
|
+
});
|
1155
907
|
if (geo.groups.length > 0) {
|
1156
908
|
const lastGroup = geo.groups[geo.groups.length - 1];
|
1157
909
|
const lastIndex = lastGroup.start + lastGroup.count;
|
1158
|
-
|
1159
910
|
if (lastIndex !== buffers.materialIndex.length) {
|
1160
911
|
geo.addGroup(lastIndex, buffers.materialIndex.length - lastIndex, prevMaterialIndex);
|
1161
912
|
}
|
1162
|
-
}
|
1163
|
-
// using one of them
|
1164
|
-
|
1165
|
-
|
913
|
+
}
|
1166
914
|
if (geo.groups.length === 0) {
|
1167
915
|
geo.addGroup(0, buffers.materialIndex.length, buffers.materialIndex[0]);
|
1168
916
|
}
|
1169
917
|
}
|
1170
|
-
|
1171
918
|
this.addMorphTargets(geo, geoNode, morphTargets, preTransform);
|
1172
919
|
return geo;
|
1173
920
|
}
|
1174
|
-
|
1175
921
|
parseGeoNode(geoNode, skeleton) {
|
1176
922
|
const geoInfo = {};
|
1177
|
-
geoInfo.vertexPositions = geoNode.Vertices !==
|
1178
|
-
geoInfo.vertexIndices = geoNode.PolygonVertexIndex !==
|
1179
|
-
|
923
|
+
geoInfo.vertexPositions = geoNode.Vertices !== void 0 ? geoNode.Vertices.a : [];
|
924
|
+
geoInfo.vertexIndices = geoNode.PolygonVertexIndex !== void 0 ? geoNode.PolygonVertexIndex.a : [];
|
1180
925
|
if (geoNode.LayerElementColor) {
|
1181
926
|
geoInfo.color = this.parseVertexColors(geoNode.LayerElementColor[0]);
|
1182
927
|
}
|
1183
|
-
|
1184
928
|
if (geoNode.LayerElementMaterial) {
|
1185
929
|
geoInfo.material = this.parseMaterialIndices(geoNode.LayerElementMaterial[0]);
|
1186
930
|
}
|
1187
|
-
|
1188
931
|
if (geoNode.LayerElementNormal) {
|
1189
932
|
geoInfo.normal = this.parseNormals(geoNode.LayerElementNormal[0]);
|
1190
933
|
}
|
1191
|
-
|
1192
934
|
if (geoNode.LayerElementUV) {
|
1193
935
|
geoInfo.uv = [];
|
1194
936
|
let i = 0;
|
1195
|
-
|
1196
937
|
while (geoNode.LayerElementUV[i]) {
|
1197
938
|
if (geoNode.LayerElementUV[i].UV) {
|
1198
939
|
geoInfo.uv.push(this.parseUVs(geoNode.LayerElementUV[i]));
|
1199
940
|
}
|
1200
|
-
|
1201
941
|
i++;
|
1202
942
|
}
|
1203
943
|
}
|
1204
|
-
|
1205
944
|
geoInfo.weightTable = {};
|
1206
|
-
|
1207
945
|
if (skeleton !== null) {
|
1208
946
|
geoInfo.skeleton = skeleton;
|
1209
|
-
skeleton.rawBones.forEach(function
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
947
|
+
skeleton.rawBones.forEach(function(rawBone, i) {
|
948
|
+
rawBone.indices.forEach(function(index, j) {
|
949
|
+
if (geoInfo.weightTable[index] === void 0)
|
950
|
+
geoInfo.weightTable[index] = [];
|
1213
951
|
geoInfo.weightTable[index].push({
|
1214
952
|
id: i,
|
1215
953
|
weight: rawBone.weights[j]
|
@@ -1217,10 +955,8 @@ class GeometryParser {
|
|
1217
955
|
});
|
1218
956
|
});
|
1219
957
|
}
|
1220
|
-
|
1221
958
|
return geoInfo;
|
1222
959
|
}
|
1223
|
-
|
1224
960
|
genBuffers(geoInfo) {
|
1225
961
|
const buffers = {
|
1226
962
|
vertex: [],
|
@@ -1233,8 +969,7 @@ class GeometryParser {
|
|
1233
969
|
};
|
1234
970
|
let polygonIndex = 0;
|
1235
971
|
let faceLength = 0;
|
1236
|
-
let displayedWeightsWarning = false;
|
1237
|
-
|
972
|
+
let displayedWeightsWarning = false;
|
1238
973
|
let facePositionIndexes = [];
|
1239
974
|
let faceNormals = [];
|
1240
975
|
let faceColors = [];
|
@@ -1242,51 +977,40 @@ class GeometryParser {
|
|
1242
977
|
let faceWeights = [];
|
1243
978
|
let faceWeightIndices = [];
|
1244
979
|
const scope = this;
|
1245
|
-
geoInfo.vertexIndices.forEach(function
|
980
|
+
geoInfo.vertexIndices.forEach(function(vertexIndex, polygonVertexIndex) {
|
1246
981
|
let materialIndex;
|
1247
|
-
let endOfFace = false;
|
1248
|
-
// A cube with quad faces looks like this:
|
1249
|
-
// PolygonVertexIndex: *24 {
|
1250
|
-
// a: 0, 1, 3, -3, 2, 3, 5, -5, 4, 5, 7, -7, 6, 7, 1, -1, 1, 7, 5, -4, 6, 0, 2, -5
|
1251
|
-
// }
|
1252
|
-
// Negative numbers mark the end of a face - first face here is 0, 1, 3, -3
|
1253
|
-
// to find index of last vertex bit shift the index: ^ - 1
|
1254
|
-
|
982
|
+
let endOfFace = false;
|
1255
983
|
if (vertexIndex < 0) {
|
1256
|
-
vertexIndex = vertexIndex ^ -1;
|
1257
|
-
|
984
|
+
vertexIndex = vertexIndex ^ -1;
|
1258
985
|
endOfFace = true;
|
1259
986
|
}
|
1260
|
-
|
1261
987
|
let weightIndices = [];
|
1262
988
|
let weights = [];
|
1263
989
|
facePositionIndexes.push(vertexIndex * 3, vertexIndex * 3 + 1, vertexIndex * 3 + 2);
|
1264
|
-
|
1265
990
|
if (geoInfo.color) {
|
1266
991
|
const data = getData(polygonVertexIndex, polygonIndex, vertexIndex, geoInfo.color);
|
1267
992
|
faceColors.push(data[0], data[1], data[2]);
|
1268
993
|
}
|
1269
|
-
|
1270
994
|
if (geoInfo.skeleton) {
|
1271
|
-
if (geoInfo.weightTable[vertexIndex] !==
|
1272
|
-
geoInfo.weightTable[vertexIndex].forEach(function
|
995
|
+
if (geoInfo.weightTable[vertexIndex] !== void 0) {
|
996
|
+
geoInfo.weightTable[vertexIndex].forEach(function(wt) {
|
1273
997
|
weights.push(wt.weight);
|
1274
998
|
weightIndices.push(wt.id);
|
1275
999
|
});
|
1276
1000
|
}
|
1277
|
-
|
1278
1001
|
if (weights.length > 4) {
|
1279
1002
|
if (!displayedWeightsWarning) {
|
1280
|
-
console.warn(
|
1003
|
+
console.warn(
|
1004
|
+
"THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."
|
1005
|
+
);
|
1281
1006
|
displayedWeightsWarning = true;
|
1282
1007
|
}
|
1283
|
-
|
1284
1008
|
const wIndex = [0, 0, 0, 0];
|
1285
1009
|
const Weight = [0, 0, 0, 0];
|
1286
|
-
weights.forEach(function
|
1010
|
+
weights.forEach(function(weight, weightIndex) {
|
1287
1011
|
let currentWeight = weight;
|
1288
1012
|
let currentIndex = weightIndices[weightIndex];
|
1289
|
-
Weight.forEach(function
|
1013
|
+
Weight.forEach(function(comparedWeight, comparedWeightIndex, comparedWeightArray) {
|
1290
1014
|
if (currentWeight > comparedWeight) {
|
1291
1015
|
comparedWeightArray[comparedWeightIndex] = currentWeight;
|
1292
1016
|
currentWeight = comparedWeight;
|
@@ -1298,49 +1022,49 @@ class GeometryParser {
|
|
1298
1022
|
});
|
1299
1023
|
weightIndices = wIndex;
|
1300
1024
|
weights = Weight;
|
1301
|
-
}
|
1302
|
-
|
1303
|
-
|
1025
|
+
}
|
1304
1026
|
while (weights.length < 4) {
|
1305
1027
|
weights.push(0);
|
1306
1028
|
weightIndices.push(0);
|
1307
1029
|
}
|
1308
|
-
|
1309
1030
|
for (let i = 0; i < 4; ++i) {
|
1310
1031
|
faceWeights.push(weights[i]);
|
1311
1032
|
faceWeightIndices.push(weightIndices[i]);
|
1312
1033
|
}
|
1313
1034
|
}
|
1314
|
-
|
1315
1035
|
if (geoInfo.normal) {
|
1316
1036
|
const data = getData(polygonVertexIndex, polygonIndex, vertexIndex, geoInfo.normal);
|
1317
1037
|
faceNormals.push(data[0], data[1], data[2]);
|
1318
1038
|
}
|
1319
|
-
|
1320
|
-
if (geoInfo.material && geoInfo.material.mappingType !== 'AllSame') {
|
1039
|
+
if (geoInfo.material && geoInfo.material.mappingType !== "AllSame") {
|
1321
1040
|
materialIndex = getData(polygonVertexIndex, polygonIndex, vertexIndex, geoInfo.material)[0];
|
1322
1041
|
}
|
1323
|
-
|
1324
1042
|
if (geoInfo.uv) {
|
1325
|
-
geoInfo.uv.forEach(function
|
1043
|
+
geoInfo.uv.forEach(function(uv, i) {
|
1326
1044
|
const data = getData(polygonVertexIndex, polygonIndex, vertexIndex, uv);
|
1327
|
-
|
1328
|
-
if (faceUVs[i] === undefined) {
|
1045
|
+
if (faceUVs[i] === void 0) {
|
1329
1046
|
faceUVs[i] = [];
|
1330
1047
|
}
|
1331
|
-
|
1332
1048
|
faceUVs[i].push(data[0]);
|
1333
1049
|
faceUVs[i].push(data[1]);
|
1334
1050
|
});
|
1335
1051
|
}
|
1336
|
-
|
1337
1052
|
faceLength++;
|
1338
|
-
|
1339
1053
|
if (endOfFace) {
|
1340
|
-
scope.genFace(
|
1054
|
+
scope.genFace(
|
1055
|
+
buffers,
|
1056
|
+
geoInfo,
|
1057
|
+
facePositionIndexes,
|
1058
|
+
materialIndex,
|
1059
|
+
faceNormals,
|
1060
|
+
faceColors,
|
1061
|
+
faceUVs,
|
1062
|
+
faceWeights,
|
1063
|
+
faceWeightIndices,
|
1064
|
+
faceLength
|
1065
|
+
);
|
1341
1066
|
polygonIndex++;
|
1342
|
-
faceLength = 0;
|
1343
|
-
|
1067
|
+
faceLength = 0;
|
1344
1068
|
facePositionIndexes = [];
|
1345
1069
|
faceNormals = [];
|
1346
1070
|
faceColors = [];
|
@@ -1350,9 +1074,7 @@ class GeometryParser {
|
|
1350
1074
|
}
|
1351
1075
|
});
|
1352
1076
|
return buffers;
|
1353
|
-
}
|
1354
|
-
|
1355
|
-
|
1077
|
+
}
|
1356
1078
|
genFace(buffers, geoInfo, facePositionIndexes, materialIndex, faceNormals, faceColors, faceUVs, faceWeights, faceWeightIndices, faceLength) {
|
1357
1079
|
for (let i = 2; i < faceLength; i++) {
|
1358
1080
|
buffers.vertex.push(geoInfo.vertexPositions[facePositionIndexes[0]]);
|
@@ -1364,7 +1086,6 @@ class GeometryParser {
|
|
1364
1086
|
buffers.vertex.push(geoInfo.vertexPositions[facePositionIndexes[i * 3]]);
|
1365
1087
|
buffers.vertex.push(geoInfo.vertexPositions[facePositionIndexes[i * 3 + 1]]);
|
1366
1088
|
buffers.vertex.push(geoInfo.vertexPositions[facePositionIndexes[i * 3 + 2]]);
|
1367
|
-
|
1368
1089
|
if (geoInfo.skeleton) {
|
1369
1090
|
buffers.vertexWeights.push(faceWeights[0]);
|
1370
1091
|
buffers.vertexWeights.push(faceWeights[1]);
|
@@ -1391,7 +1112,6 @@ class GeometryParser {
|
|
1391
1112
|
buffers.weightsIndices.push(faceWeightIndices[i * 4 + 2]);
|
1392
1113
|
buffers.weightsIndices.push(faceWeightIndices[i * 4 + 3]);
|
1393
1114
|
}
|
1394
|
-
|
1395
1115
|
if (geoInfo.color) {
|
1396
1116
|
buffers.colors.push(faceColors[0]);
|
1397
1117
|
buffers.colors.push(faceColors[1]);
|
@@ -1403,13 +1123,11 @@ class GeometryParser {
|
|
1403
1123
|
buffers.colors.push(faceColors[i * 3 + 1]);
|
1404
1124
|
buffers.colors.push(faceColors[i * 3 + 2]);
|
1405
1125
|
}
|
1406
|
-
|
1407
|
-
if (geoInfo.material && geoInfo.material.mappingType !== 'AllSame') {
|
1126
|
+
if (geoInfo.material && geoInfo.material.mappingType !== "AllSame") {
|
1408
1127
|
buffers.materialIndex.push(materialIndex);
|
1409
1128
|
buffers.materialIndex.push(materialIndex);
|
1410
1129
|
buffers.materialIndex.push(materialIndex);
|
1411
1130
|
}
|
1412
|
-
|
1413
1131
|
if (geoInfo.normal) {
|
1414
1132
|
buffers.normal.push(faceNormals[0]);
|
1415
1133
|
buffers.normal.push(faceNormals[1]);
|
@@ -1421,10 +1139,10 @@ class GeometryParser {
|
|
1421
1139
|
buffers.normal.push(faceNormals[i * 3 + 1]);
|
1422
1140
|
buffers.normal.push(faceNormals[i * 3 + 2]);
|
1423
1141
|
}
|
1424
|
-
|
1425
1142
|
if (geoInfo.uv) {
|
1426
|
-
geoInfo.uv.forEach(function
|
1427
|
-
if (buffers.uvs[j] ===
|
1143
|
+
geoInfo.uv.forEach(function(uv, j) {
|
1144
|
+
if (buffers.uvs[j] === void 0)
|
1145
|
+
buffers.uvs[j] = [];
|
1428
1146
|
buffers.uvs[j].push(faceUVs[j][0]);
|
1429
1147
|
buffers.uvs[j].push(faceUVs[j][1]);
|
1430
1148
|
buffers.uvs[j].push(faceUVs[j][(i - 1) * 2]);
|
@@ -1435,234 +1153,181 @@ class GeometryParser {
|
|
1435
1153
|
}
|
1436
1154
|
}
|
1437
1155
|
}
|
1438
|
-
|
1439
1156
|
addMorphTargets(parentGeo, parentGeoNode, morphTargets, preTransform) {
|
1440
|
-
if (morphTargets.length === 0)
|
1157
|
+
if (morphTargets.length === 0)
|
1158
|
+
return;
|
1441
1159
|
parentGeo.morphTargetsRelative = true;
|
1442
|
-
parentGeo.morphAttributes.position = [];
|
1443
|
-
|
1160
|
+
parentGeo.morphAttributes.position = [];
|
1444
1161
|
const scope = this;
|
1445
|
-
morphTargets.forEach(function
|
1446
|
-
morphTarget.rawTargets.forEach(function
|
1162
|
+
morphTargets.forEach(function(morphTarget) {
|
1163
|
+
morphTarget.rawTargets.forEach(function(rawTarget) {
|
1447
1164
|
const morphGeoNode = fbxTree.Objects.Geometry[rawTarget.geoID];
|
1448
|
-
|
1449
|
-
if (morphGeoNode !== undefined) {
|
1165
|
+
if (morphGeoNode !== void 0) {
|
1450
1166
|
scope.genMorphGeometry(parentGeo, parentGeoNode, morphGeoNode, preTransform, rawTarget.name);
|
1451
1167
|
}
|
1452
1168
|
});
|
1453
1169
|
});
|
1454
|
-
}
|
1455
|
-
// in FBXTree.Objects.Geometry, however it can only have attributes for position, normal
|
1456
|
-
// and a special attribute Index defining which vertices of the original geometry are affected
|
1457
|
-
// Normal and position attributes only have data for the vertices that are affected by the morph
|
1458
|
-
|
1459
|
-
|
1170
|
+
}
|
1460
1171
|
genMorphGeometry(parentGeo, parentGeoNode, morphGeoNode, preTransform, name) {
|
1461
|
-
const vertexIndices = parentGeoNode.PolygonVertexIndex !==
|
1462
|
-
const morphPositionsSparse = morphGeoNode.Vertices !==
|
1463
|
-
const indices = morphGeoNode.Indexes !==
|
1172
|
+
const vertexIndices = parentGeoNode.PolygonVertexIndex !== void 0 ? parentGeoNode.PolygonVertexIndex.a : [];
|
1173
|
+
const morphPositionsSparse = morphGeoNode.Vertices !== void 0 ? morphGeoNode.Vertices.a : [];
|
1174
|
+
const indices = morphGeoNode.Indexes !== void 0 ? morphGeoNode.Indexes.a : [];
|
1464
1175
|
const length = parentGeo.attributes.position.count * 3;
|
1465
1176
|
const morphPositions = new Float32Array(length);
|
1466
|
-
|
1467
1177
|
for (let i = 0; i < indices.length; i++) {
|
1468
1178
|
const morphIndex = indices[i] * 3;
|
1469
1179
|
morphPositions[morphIndex] = morphPositionsSparse[i * 3];
|
1470
1180
|
morphPositions[morphIndex + 1] = morphPositionsSparse[i * 3 + 1];
|
1471
1181
|
morphPositions[morphIndex + 2] = morphPositionsSparse[i * 3 + 2];
|
1472
|
-
}
|
1473
|
-
|
1474
|
-
|
1182
|
+
}
|
1475
1183
|
const morphGeoInfo = {
|
1476
|
-
vertexIndices
|
1184
|
+
vertexIndices,
|
1477
1185
|
vertexPositions: morphPositions
|
1478
1186
|
};
|
1479
1187
|
const morphBuffers = this.genBuffers(morphGeoInfo);
|
1480
|
-
const positionAttribute = new Float32BufferAttribute(morphBuffers.vertex, 3);
|
1188
|
+
const positionAttribute = new THREE.Float32BufferAttribute(morphBuffers.vertex, 3);
|
1481
1189
|
positionAttribute.name = name || morphGeoNode.attrName;
|
1482
1190
|
positionAttribute.applyMatrix4(preTransform);
|
1483
1191
|
parentGeo.morphAttributes.position.push(positionAttribute);
|
1484
|
-
}
|
1485
|
-
|
1486
|
-
|
1192
|
+
}
|
1487
1193
|
parseNormals(NormalNode) {
|
1488
1194
|
const mappingType = NormalNode.MappingInformationType;
|
1489
1195
|
const referenceType = NormalNode.ReferenceInformationType;
|
1490
1196
|
const buffer = NormalNode.Normals.a;
|
1491
1197
|
let indexBuffer = [];
|
1492
|
-
|
1493
|
-
|
1494
|
-
if ('NormalIndex' in NormalNode) {
|
1198
|
+
if (referenceType === "IndexToDirect") {
|
1199
|
+
if ("NormalIndex" in NormalNode) {
|
1495
1200
|
indexBuffer = NormalNode.NormalIndex.a;
|
1496
|
-
} else if (
|
1201
|
+
} else if ("NormalsIndex" in NormalNode) {
|
1497
1202
|
indexBuffer = NormalNode.NormalsIndex.a;
|
1498
1203
|
}
|
1499
1204
|
}
|
1500
|
-
|
1501
1205
|
return {
|
1502
1206
|
dataSize: 3,
|
1503
|
-
buffer
|
1207
|
+
buffer,
|
1504
1208
|
indices: indexBuffer,
|
1505
|
-
mappingType
|
1506
|
-
referenceType
|
1209
|
+
mappingType,
|
1210
|
+
referenceType
|
1507
1211
|
};
|
1508
|
-
}
|
1509
|
-
|
1510
|
-
|
1212
|
+
}
|
1511
1213
|
parseUVs(UVNode) {
|
1512
1214
|
const mappingType = UVNode.MappingInformationType;
|
1513
1215
|
const referenceType = UVNode.ReferenceInformationType;
|
1514
1216
|
const buffer = UVNode.UV.a;
|
1515
1217
|
let indexBuffer = [];
|
1516
|
-
|
1517
|
-
if (referenceType === 'IndexToDirect') {
|
1218
|
+
if (referenceType === "IndexToDirect") {
|
1518
1219
|
indexBuffer = UVNode.UVIndex.a;
|
1519
1220
|
}
|
1520
|
-
|
1521
1221
|
return {
|
1522
1222
|
dataSize: 2,
|
1523
|
-
buffer
|
1223
|
+
buffer,
|
1524
1224
|
indices: indexBuffer,
|
1525
|
-
mappingType
|
1526
|
-
referenceType
|
1225
|
+
mappingType,
|
1226
|
+
referenceType
|
1527
1227
|
};
|
1528
|
-
}
|
1529
|
-
|
1530
|
-
|
1228
|
+
}
|
1531
1229
|
parseVertexColors(ColorNode) {
|
1532
1230
|
const mappingType = ColorNode.MappingInformationType;
|
1533
1231
|
const referenceType = ColorNode.ReferenceInformationType;
|
1534
1232
|
const buffer = ColorNode.Colors.a;
|
1535
1233
|
let indexBuffer = [];
|
1536
|
-
|
1537
|
-
if (referenceType === 'IndexToDirect') {
|
1234
|
+
if (referenceType === "IndexToDirect") {
|
1538
1235
|
indexBuffer = ColorNode.ColorIndex.a;
|
1539
1236
|
}
|
1540
|
-
|
1541
1237
|
return {
|
1542
1238
|
dataSize: 4,
|
1543
|
-
buffer
|
1239
|
+
buffer,
|
1544
1240
|
indices: indexBuffer,
|
1545
|
-
mappingType
|
1546
|
-
referenceType
|
1241
|
+
mappingType,
|
1242
|
+
referenceType
|
1547
1243
|
};
|
1548
|
-
}
|
1549
|
-
|
1550
|
-
|
1244
|
+
}
|
1551
1245
|
parseMaterialIndices(MaterialNode) {
|
1552
1246
|
const mappingType = MaterialNode.MappingInformationType;
|
1553
1247
|
const referenceType = MaterialNode.ReferenceInformationType;
|
1554
|
-
|
1555
|
-
if (mappingType === 'NoMappingInformation') {
|
1248
|
+
if (mappingType === "NoMappingInformation") {
|
1556
1249
|
return {
|
1557
1250
|
dataSize: 1,
|
1558
1251
|
buffer: [0],
|
1559
1252
|
indices: [0],
|
1560
|
-
mappingType:
|
1561
|
-
referenceType
|
1253
|
+
mappingType: "AllSame",
|
1254
|
+
referenceType
|
1562
1255
|
};
|
1563
1256
|
}
|
1564
|
-
|
1565
|
-
const materialIndexBuffer = MaterialNode.Materials.a; // Since materials are stored as indices, there's a bit of a mismatch between FBX and what
|
1566
|
-
// we expect.So we create an intermediate buffer that points to the index in the buffer,
|
1567
|
-
// for conforming with the other functions we've written for other data.
|
1568
|
-
|
1257
|
+
const materialIndexBuffer = MaterialNode.Materials.a;
|
1569
1258
|
const materialIndices = [];
|
1570
|
-
|
1571
1259
|
for (let i = 0; i < materialIndexBuffer.length; ++i) {
|
1572
1260
|
materialIndices.push(i);
|
1573
1261
|
}
|
1574
|
-
|
1575
1262
|
return {
|
1576
1263
|
dataSize: 1,
|
1577
1264
|
buffer: materialIndexBuffer,
|
1578
1265
|
indices: materialIndices,
|
1579
|
-
mappingType
|
1580
|
-
referenceType
|
1266
|
+
mappingType,
|
1267
|
+
referenceType
|
1581
1268
|
};
|
1582
|
-
}
|
1583
|
-
|
1584
|
-
|
1269
|
+
}
|
1585
1270
|
parseNurbsGeometry(geoNode) {
|
1586
|
-
if (NURBSCurve ===
|
1587
|
-
console.error(
|
1588
|
-
|
1271
|
+
if (NURBSCurve.NURBSCurve === void 0) {
|
1272
|
+
console.error(
|
1273
|
+
"THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."
|
1274
|
+
);
|
1275
|
+
return new THREE.BufferGeometry();
|
1589
1276
|
}
|
1590
|
-
|
1591
1277
|
const order = parseInt(geoNode.Order);
|
1592
|
-
|
1593
1278
|
if (isNaN(order)) {
|
1594
|
-
console.error(
|
1595
|
-
return new BufferGeometry();
|
1279
|
+
console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s", geoNode.Order, geoNode.id);
|
1280
|
+
return new THREE.BufferGeometry();
|
1596
1281
|
}
|
1597
|
-
|
1598
1282
|
const degree = order - 1;
|
1599
1283
|
const knots = geoNode.KnotVector.a;
|
1600
1284
|
const controlPoints = [];
|
1601
1285
|
const pointsValues = geoNode.Points.a;
|
1602
|
-
|
1603
1286
|
for (let i = 0, l = pointsValues.length; i < l; i += 4) {
|
1604
|
-
controlPoints.push(new Vector4().fromArray(pointsValues, i));
|
1287
|
+
controlPoints.push(new THREE.Vector4().fromArray(pointsValues, i));
|
1605
1288
|
}
|
1606
|
-
|
1607
1289
|
let startKnot, endKnot;
|
1608
|
-
|
1609
|
-
if (geoNode.Form === 'Closed') {
|
1290
|
+
if (geoNode.Form === "Closed") {
|
1610
1291
|
controlPoints.push(controlPoints[0]);
|
1611
|
-
} else if (geoNode.Form ===
|
1292
|
+
} else if (geoNode.Form === "Periodic") {
|
1612
1293
|
startKnot = degree;
|
1613
1294
|
endKnot = knots.length - 1 - startKnot;
|
1614
|
-
|
1615
1295
|
for (let i = 0; i < degree; ++i) {
|
1616
1296
|
controlPoints.push(controlPoints[i]);
|
1617
1297
|
}
|
1618
1298
|
}
|
1619
|
-
|
1620
|
-
const curve = new NURBSCurve(degree, knots, controlPoints, startKnot, endKnot);
|
1299
|
+
const curve = new NURBSCurve.NURBSCurve(degree, knots, controlPoints, startKnot, endKnot);
|
1621
1300
|
const points = curve.getPoints(controlPoints.length * 12);
|
1622
|
-
return new BufferGeometry().setFromPoints(points);
|
1301
|
+
return new THREE.BufferGeometry().setFromPoints(points);
|
1623
1302
|
}
|
1624
|
-
|
1625
|
-
} // parse animation data from FBXTree
|
1626
|
-
|
1627
|
-
|
1303
|
+
}
|
1628
1304
|
class AnimationParser {
|
1629
|
-
// take raw animation clips and turn them into three.js animation clips
|
1630
1305
|
parse() {
|
1631
1306
|
const animationClips = [];
|
1632
1307
|
const rawClips = this.parseClips();
|
1633
|
-
|
1634
|
-
if (rawClips !== undefined) {
|
1308
|
+
if (rawClips !== void 0) {
|
1635
1309
|
for (const key in rawClips) {
|
1636
1310
|
const rawClip = rawClips[key];
|
1637
1311
|
const clip = this.addClip(rawClip);
|
1638
1312
|
animationClips.push(clip);
|
1639
1313
|
}
|
1640
1314
|
}
|
1641
|
-
|
1642
1315
|
return animationClips;
|
1643
1316
|
}
|
1644
|
-
|
1645
1317
|
parseClips() {
|
1646
|
-
|
1647
|
-
|
1648
|
-
if (fbxTree.Objects.AnimationCurve === undefined) return undefined;
|
1318
|
+
if (fbxTree.Objects.AnimationCurve === void 0)
|
1319
|
+
return void 0;
|
1649
1320
|
const curveNodesMap = this.parseAnimationCurveNodes();
|
1650
1321
|
this.parseAnimationCurves(curveNodesMap);
|
1651
1322
|
const layersMap = this.parseAnimationLayers(curveNodesMap);
|
1652
1323
|
const rawClips = this.parseAnimStacks(layersMap);
|
1653
1324
|
return rawClips;
|
1654
|
-
}
|
1655
|
-
// each AnimationCurveNode holds data for an animation transform for a model (e.g. left arm rotation )
|
1656
|
-
// and is referenced by an AnimationLayer
|
1657
|
-
|
1658
|
-
|
1325
|
+
}
|
1659
1326
|
parseAnimationCurveNodes() {
|
1660
1327
|
const rawCurveNodes = fbxTree.Objects.AnimationCurveNode;
|
1661
|
-
const curveNodesMap = new Map();
|
1662
|
-
|
1328
|
+
const curveNodesMap = /* @__PURE__ */ new Map();
|
1663
1329
|
for (const nodeID in rawCurveNodes) {
|
1664
1330
|
const rawCurveNode = rawCurveNodes[nodeID];
|
1665
|
-
|
1666
1331
|
if (rawCurveNode.attrName.match(/S|R|T|DeformPercent/) !== null) {
|
1667
1332
|
const curveNode = {
|
1668
1333
|
id: rawCurveNode.id,
|
@@ -1672,21 +1337,10 @@ class AnimationParser {
|
|
1672
1337
|
curveNodesMap.set(curveNode.id, curveNode);
|
1673
1338
|
}
|
1674
1339
|
}
|
1675
|
-
|
1676
1340
|
return curveNodesMap;
|
1677
|
-
}
|
1678
|
-
// previously parsed AnimationCurveNodes. Each AnimationCurve holds data for a single animated
|
1679
|
-
// axis ( e.g. times and values of x rotation)
|
1680
|
-
|
1681
|
-
|
1341
|
+
}
|
1682
1342
|
parseAnimationCurves(curveNodesMap) {
|
1683
|
-
const rawCurves = fbxTree.Objects.AnimationCurve;
|
1684
|
-
// e.g. position times: [0, 0.4, 0. 8]
|
1685
|
-
// position values: [7.23538335023477e-7, 93.67518615722656, -0.9982695579528809, 7.23538335023477e-7, 93.67518615722656, -0.9982695579528809, 7.235384487103147e-7, 93.67520904541016, -0.9982695579528809]
|
1686
|
-
// clearly, this should be optimised to
|
1687
|
-
// times: [0], positions [7.23538335023477e-7, 93.67518615722656, -0.9982695579528809]
|
1688
|
-
// this shows up in nearly every FBX file, and generally time array is length > 100
|
1689
|
-
|
1343
|
+
const rawCurves = fbxTree.Objects.AnimationCurve;
|
1690
1344
|
for (const nodeID in rawCurves) {
|
1691
1345
|
const animationCurve = {
|
1692
1346
|
id: rawCurves[nodeID].id,
|
@@ -1694,96 +1348,83 @@ class AnimationParser {
|
|
1694
1348
|
values: rawCurves[nodeID].KeyValueFloat.a
|
1695
1349
|
};
|
1696
1350
|
const relationships = connections.get(animationCurve.id);
|
1697
|
-
|
1698
|
-
if (relationships !== undefined) {
|
1351
|
+
if (relationships !== void 0) {
|
1699
1352
|
const animationCurveID = relationships.parents[0].ID;
|
1700
1353
|
const animationCurveRelationship = relationships.parents[0].relationship;
|
1701
|
-
|
1702
1354
|
if (animationCurveRelationship.match(/X/)) {
|
1703
|
-
curveNodesMap.get(animationCurveID).curves[
|
1355
|
+
curveNodesMap.get(animationCurveID).curves["x"] = animationCurve;
|
1704
1356
|
} else if (animationCurveRelationship.match(/Y/)) {
|
1705
|
-
curveNodesMap.get(animationCurveID).curves[
|
1357
|
+
curveNodesMap.get(animationCurveID).curves["y"] = animationCurve;
|
1706
1358
|
} else if (animationCurveRelationship.match(/Z/)) {
|
1707
|
-
curveNodesMap.get(animationCurveID).curves[
|
1359
|
+
curveNodesMap.get(animationCurveID).curves["z"] = animationCurve;
|
1708
1360
|
} else if (animationCurveRelationship.match(/d|DeformPercent/) && curveNodesMap.has(animationCurveID)) {
|
1709
|
-
curveNodesMap.get(animationCurveID).curves[
|
1361
|
+
curveNodesMap.get(animationCurveID).curves["morph"] = animationCurve;
|
1710
1362
|
}
|
1711
1363
|
}
|
1712
1364
|
}
|
1713
|
-
}
|
1714
|
-
// to various AnimationCurveNodes and is referenced by an AnimationStack node
|
1715
|
-
// note: theoretically a stack can have multiple layers, however in practice there always seems to be one per stack
|
1716
|
-
|
1717
|
-
|
1365
|
+
}
|
1718
1366
|
parseAnimationLayers(curveNodesMap) {
|
1719
1367
|
const rawLayers = fbxTree.Objects.AnimationLayer;
|
1720
|
-
const layersMap = new Map();
|
1721
|
-
|
1368
|
+
const layersMap = /* @__PURE__ */ new Map();
|
1722
1369
|
for (const nodeID in rawLayers) {
|
1723
1370
|
const layerCurveNodes = [];
|
1724
1371
|
const connection = connections.get(parseInt(nodeID));
|
1725
|
-
|
1726
|
-
if (connection !== undefined) {
|
1727
|
-
// all the animationCurveNodes used in the layer
|
1372
|
+
if (connection !== void 0) {
|
1728
1373
|
const children = connection.children;
|
1729
|
-
children.forEach(function
|
1374
|
+
children.forEach(function(child, i) {
|
1730
1375
|
if (curveNodesMap.has(child.ID)) {
|
1731
|
-
const curveNode = curveNodesMap.get(child.ID);
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
return parent.relationship !== undefined;
|
1376
|
+
const curveNode = curveNodesMap.get(child.ID);
|
1377
|
+
if (curveNode.curves.x !== void 0 || curveNode.curves.y !== void 0 || curveNode.curves.z !== void 0) {
|
1378
|
+
if (layerCurveNodes[i] === void 0) {
|
1379
|
+
const modelID = connections.get(child.ID).parents.filter(function(parent) {
|
1380
|
+
return parent.relationship !== void 0;
|
1737
1381
|
})[0].ID;
|
1738
|
-
|
1739
|
-
if (modelID !== undefined) {
|
1382
|
+
if (modelID !== void 0) {
|
1740
1383
|
const rawModel = fbxTree.Objects.Model[modelID.toString()];
|
1741
|
-
|
1742
|
-
|
1743
|
-
console.warn('THREE.FBXLoader: Encountered a unused curve.', child);
|
1384
|
+
if (rawModel === void 0) {
|
1385
|
+
console.warn("THREE.FBXLoader: Encountered a unused curve.", child);
|
1744
1386
|
return;
|
1745
1387
|
}
|
1746
|
-
|
1747
1388
|
const node = {
|
1748
|
-
modelName: rawModel.attrName ? PropertyBinding.sanitizeNodeName(rawModel.attrName) :
|
1389
|
+
modelName: rawModel.attrName ? THREE.PropertyBinding.sanitizeNodeName(rawModel.attrName) : "",
|
1749
1390
|
ID: rawModel.id,
|
1750
1391
|
initialPosition: [0, 0, 0],
|
1751
1392
|
initialRotation: [0, 0, 0],
|
1752
1393
|
initialScale: [1, 1, 1]
|
1753
1394
|
};
|
1754
|
-
sceneGraph.traverse(function
|
1755
|
-
if (
|
1756
|
-
node.transform =
|
1757
|
-
if (
|
1395
|
+
sceneGraph.traverse(function(child2) {
|
1396
|
+
if (child2.ID === rawModel.id) {
|
1397
|
+
node.transform = child2.matrix;
|
1398
|
+
if (child2.userData.transformData)
|
1399
|
+
node.eulerOrder = child2.userData.transformData.eulerOrder;
|
1758
1400
|
}
|
1759
1401
|
});
|
1760
|
-
if (!node.transform)
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
if (
|
1402
|
+
if (!node.transform)
|
1403
|
+
node.transform = new THREE.Matrix4();
|
1404
|
+
if ("PreRotation" in rawModel)
|
1405
|
+
node.preRotation = rawModel.PreRotation.value;
|
1406
|
+
if ("PostRotation" in rawModel)
|
1407
|
+
node.postRotation = rawModel.PostRotation.value;
|
1765
1408
|
layerCurveNodes[i] = node;
|
1766
1409
|
}
|
1767
1410
|
}
|
1768
|
-
|
1769
|
-
|
1770
|
-
} else if (curveNode.curves.morph !==
|
1771
|
-
if (layerCurveNodes[i] ===
|
1772
|
-
const deformerID = connections.get(child.ID).parents.filter(function
|
1773
|
-
return parent.relationship !==
|
1411
|
+
if (layerCurveNodes[i])
|
1412
|
+
layerCurveNodes[i][curveNode.attr] = curveNode;
|
1413
|
+
} else if (curveNode.curves.morph !== void 0) {
|
1414
|
+
if (layerCurveNodes[i] === void 0) {
|
1415
|
+
const deformerID = connections.get(child.ID).parents.filter(function(parent) {
|
1416
|
+
return parent.relationship !== void 0;
|
1774
1417
|
})[0].ID;
|
1775
1418
|
const morpherID = connections.get(deformerID).parents[0].ID;
|
1776
|
-
const geoID = connections.get(morpherID).parents[0].ID;
|
1777
|
-
|
1419
|
+
const geoID = connections.get(morpherID).parents[0].ID;
|
1778
1420
|
const modelID = connections.get(geoID).parents[0].ID;
|
1779
1421
|
const rawModel = fbxTree.Objects.Model[modelID];
|
1780
1422
|
const node = {
|
1781
|
-
modelName: rawModel.attrName ? PropertyBinding.sanitizeNodeName(rawModel.attrName) :
|
1423
|
+
modelName: rawModel.attrName ? THREE.PropertyBinding.sanitizeNodeName(rawModel.attrName) : "",
|
1782
1424
|
morphName: fbxTree.Objects.Deformer[deformerID].attrName
|
1783
1425
|
};
|
1784
1426
|
layerCurveNodes[i] = node;
|
1785
1427
|
}
|
1786
|
-
|
1787
1428
|
layerCurveNodes[i][curveNode.attr] = curveNode;
|
1788
1429
|
}
|
1789
1430
|
}
|
@@ -1791,194 +1432,182 @@ class AnimationParser {
|
|
1791
1432
|
layersMap.set(parseInt(nodeID), layerCurveNodes);
|
1792
1433
|
}
|
1793
1434
|
}
|
1794
|
-
|
1795
1435
|
return layersMap;
|
1796
|
-
}
|
1797
|
-
// hierarchy. Each Stack node will be used to create a AnimationClip
|
1798
|
-
|
1799
|
-
|
1436
|
+
}
|
1800
1437
|
parseAnimStacks(layersMap) {
|
1801
|
-
const rawStacks = fbxTree.Objects.AnimationStack;
|
1802
|
-
|
1438
|
+
const rawStacks = fbxTree.Objects.AnimationStack;
|
1803
1439
|
const rawClips = {};
|
1804
|
-
|
1805
1440
|
for (const nodeID in rawStacks) {
|
1806
1441
|
const children = connections.get(parseInt(nodeID)).children;
|
1807
|
-
|
1808
1442
|
if (children.length > 1) {
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1443
|
+
console.warn(
|
1444
|
+
"THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers."
|
1445
|
+
);
|
1812
1446
|
}
|
1813
|
-
|
1814
1447
|
const layer = layersMap.get(children[0].ID);
|
1815
1448
|
rawClips[nodeID] = {
|
1816
1449
|
name: rawStacks[nodeID].attrName,
|
1817
|
-
layer
|
1450
|
+
layer
|
1818
1451
|
};
|
1819
1452
|
}
|
1820
|
-
|
1821
1453
|
return rawClips;
|
1822
1454
|
}
|
1823
|
-
|
1824
1455
|
addClip(rawClip) {
|
1825
1456
|
let tracks = [];
|
1826
1457
|
const scope = this;
|
1827
|
-
rawClip.layer.forEach(function
|
1458
|
+
rawClip.layer.forEach(function(rawTracks) {
|
1828
1459
|
tracks = tracks.concat(scope.generateTracks(rawTracks));
|
1829
1460
|
});
|
1830
|
-
return new AnimationClip(rawClip.name, -1, tracks);
|
1461
|
+
return new THREE.AnimationClip(rawClip.name, -1, tracks);
|
1831
1462
|
}
|
1832
|
-
|
1833
1463
|
generateTracks(rawTracks) {
|
1834
1464
|
const tracks = [];
|
1835
|
-
let initialPosition = new Vector3();
|
1836
|
-
let initialRotation = new Quaternion();
|
1837
|
-
let initialScale = new Vector3();
|
1838
|
-
if (rawTracks.transform)
|
1465
|
+
let initialPosition = new THREE.Vector3();
|
1466
|
+
let initialRotation = new THREE.Quaternion();
|
1467
|
+
let initialScale = new THREE.Vector3();
|
1468
|
+
if (rawTracks.transform)
|
1469
|
+
rawTracks.transform.decompose(initialPosition, initialRotation, initialScale);
|
1839
1470
|
initialPosition = initialPosition.toArray();
|
1840
|
-
initialRotation = new Euler().setFromQuaternion(initialRotation, rawTracks.eulerOrder).toArray();
|
1471
|
+
initialRotation = new THREE.Euler().setFromQuaternion(initialRotation, rawTracks.eulerOrder).toArray();
|
1841
1472
|
initialScale = initialScale.toArray();
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
}
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1473
|
+
if (rawTracks.T !== void 0 && Object.keys(rawTracks.T.curves).length > 0) {
|
1474
|
+
const positionTrack = this.generateVectorTrack(
|
1475
|
+
rawTracks.modelName,
|
1476
|
+
rawTracks.T.curves,
|
1477
|
+
initialPosition,
|
1478
|
+
"position"
|
1479
|
+
);
|
1480
|
+
if (positionTrack !== void 0)
|
1481
|
+
tracks.push(positionTrack);
|
1482
|
+
}
|
1483
|
+
if (rawTracks.R !== void 0 && Object.keys(rawTracks.R.curves).length > 0) {
|
1484
|
+
const rotationTrack = this.generateRotationTrack(
|
1485
|
+
rawTracks.modelName,
|
1486
|
+
rawTracks.R.curves,
|
1487
|
+
initialRotation,
|
1488
|
+
rawTracks.preRotation,
|
1489
|
+
rawTracks.postRotation,
|
1490
|
+
rawTracks.eulerOrder
|
1491
|
+
);
|
1492
|
+
if (rotationTrack !== void 0)
|
1493
|
+
tracks.push(rotationTrack);
|
1494
|
+
}
|
1495
|
+
if (rawTracks.S !== void 0 && Object.keys(rawTracks.S.curves).length > 0) {
|
1496
|
+
const scaleTrack = this.generateVectorTrack(rawTracks.modelName, rawTracks.S.curves, initialScale, "scale");
|
1497
|
+
if (scaleTrack !== void 0)
|
1498
|
+
tracks.push(scaleTrack);
|
1499
|
+
}
|
1500
|
+
if (rawTracks.DeformPercent !== void 0) {
|
1859
1501
|
const morphTrack = this.generateMorphTrack(rawTracks);
|
1860
|
-
if (morphTrack !==
|
1502
|
+
if (morphTrack !== void 0)
|
1503
|
+
tracks.push(morphTrack);
|
1861
1504
|
}
|
1862
|
-
|
1863
1505
|
return tracks;
|
1864
1506
|
}
|
1865
|
-
|
1866
1507
|
generateVectorTrack(modelName, curves, initialValue, type) {
|
1867
1508
|
const times = this.getTimesForAllAxes(curves);
|
1868
1509
|
const values = this.getKeyframeTrackValues(times, curves, initialValue);
|
1869
|
-
return new VectorKeyframeTrack(modelName +
|
1510
|
+
return new THREE.VectorKeyframeTrack(modelName + "." + type, times, values);
|
1870
1511
|
}
|
1871
|
-
|
1872
1512
|
generateRotationTrack(modelName, curves, initialValue, preRotation, postRotation, eulerOrder) {
|
1873
|
-
if (curves.x !==
|
1513
|
+
if (curves.x !== void 0) {
|
1874
1514
|
this.interpolateRotations(curves.x);
|
1875
|
-
curves.x.values = curves.x.values.map(MathUtils.degToRad);
|
1515
|
+
curves.x.values = curves.x.values.map(THREE.MathUtils.degToRad);
|
1876
1516
|
}
|
1877
|
-
|
1878
|
-
if (curves.y !== undefined) {
|
1517
|
+
if (curves.y !== void 0) {
|
1879
1518
|
this.interpolateRotations(curves.y);
|
1880
|
-
curves.y.values = curves.y.values.map(MathUtils.degToRad);
|
1519
|
+
curves.y.values = curves.y.values.map(THREE.MathUtils.degToRad);
|
1881
1520
|
}
|
1882
|
-
|
1883
|
-
if (curves.z !== undefined) {
|
1521
|
+
if (curves.z !== void 0) {
|
1884
1522
|
this.interpolateRotations(curves.z);
|
1885
|
-
curves.z.values = curves.z.values.map(MathUtils.degToRad);
|
1523
|
+
curves.z.values = curves.z.values.map(THREE.MathUtils.degToRad);
|
1886
1524
|
}
|
1887
|
-
|
1888
1525
|
const times = this.getTimesForAllAxes(curves);
|
1889
1526
|
const values = this.getKeyframeTrackValues(times, curves, initialValue);
|
1890
|
-
|
1891
|
-
|
1892
|
-
preRotation = preRotation.map(MathUtils.degToRad);
|
1527
|
+
if (preRotation !== void 0) {
|
1528
|
+
preRotation = preRotation.map(THREE.MathUtils.degToRad);
|
1893
1529
|
preRotation.push(eulerOrder);
|
1894
|
-
preRotation = new Euler().fromArray(preRotation);
|
1895
|
-
preRotation = new Quaternion().setFromEuler(preRotation);
|
1530
|
+
preRotation = new THREE.Euler().fromArray(preRotation);
|
1531
|
+
preRotation = new THREE.Quaternion().setFromEuler(preRotation);
|
1896
1532
|
}
|
1897
|
-
|
1898
|
-
|
1899
|
-
postRotation = postRotation.map(MathUtils.degToRad);
|
1533
|
+
if (postRotation !== void 0) {
|
1534
|
+
postRotation = postRotation.map(THREE.MathUtils.degToRad);
|
1900
1535
|
postRotation.push(eulerOrder);
|
1901
|
-
postRotation = new Euler().fromArray(postRotation);
|
1902
|
-
postRotation = new Quaternion().setFromEuler(postRotation).invert();
|
1536
|
+
postRotation = new THREE.Euler().fromArray(postRotation);
|
1537
|
+
postRotation = new THREE.Quaternion().setFromEuler(postRotation).invert();
|
1903
1538
|
}
|
1904
|
-
|
1905
|
-
const
|
1906
|
-
const euler = new Euler();
|
1539
|
+
const quaternion = new THREE.Quaternion();
|
1540
|
+
const euler = new THREE.Euler();
|
1907
1541
|
const quaternionValues = [];
|
1908
|
-
|
1909
1542
|
for (let i = 0; i < values.length; i += 3) {
|
1910
1543
|
euler.set(values[i], values[i + 1], values[i + 2], eulerOrder);
|
1911
1544
|
quaternion.setFromEuler(euler);
|
1912
|
-
if (preRotation !==
|
1913
|
-
|
1545
|
+
if (preRotation !== void 0)
|
1546
|
+
quaternion.premultiply(preRotation);
|
1547
|
+
if (postRotation !== void 0)
|
1548
|
+
quaternion.multiply(postRotation);
|
1914
1549
|
quaternion.toArray(quaternionValues, i / 3 * 4);
|
1915
1550
|
}
|
1916
|
-
|
1917
|
-
return new QuaternionKeyframeTrack(modelName + '.quaternion', times, quaternionValues);
|
1551
|
+
return new THREE.QuaternionKeyframeTrack(modelName + ".quaternion", times, quaternionValues);
|
1918
1552
|
}
|
1919
|
-
|
1920
1553
|
generateMorphTrack(rawTracks) {
|
1921
1554
|
const curves = rawTracks.DeformPercent.curves.morph;
|
1922
|
-
const values = curves.values.map(function
|
1555
|
+
const values = curves.values.map(function(val) {
|
1923
1556
|
return val / 100;
|
1924
1557
|
});
|
1925
1558
|
const morphNum = sceneGraph.getObjectByName(rawTracks.modelName).morphTargetDictionary[rawTracks.morphName];
|
1926
|
-
return new NumberKeyframeTrack(
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1559
|
+
return new THREE.NumberKeyframeTrack(
|
1560
|
+
rawTracks.modelName + ".morphTargetInfluences[" + morphNum + "]",
|
1561
|
+
curves.times,
|
1562
|
+
values
|
1563
|
+
);
|
1564
|
+
}
|
1931
1565
|
getTimesForAllAxes(curves) {
|
1932
|
-
let times = [];
|
1933
|
-
|
1934
|
-
|
1935
|
-
if (curves.y !==
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1566
|
+
let times = [];
|
1567
|
+
if (curves.x !== void 0)
|
1568
|
+
times = times.concat(curves.x.times);
|
1569
|
+
if (curves.y !== void 0)
|
1570
|
+
times = times.concat(curves.y.times);
|
1571
|
+
if (curves.z !== void 0)
|
1572
|
+
times = times.concat(curves.z.times);
|
1573
|
+
times = times.sort(function(a, b) {
|
1939
1574
|
return a - b;
|
1940
|
-
});
|
1941
|
-
|
1575
|
+
});
|
1942
1576
|
if (times.length > 1) {
|
1943
1577
|
let targetIndex = 1;
|
1944
1578
|
let lastValue = times[0];
|
1945
|
-
|
1946
1579
|
for (let i = 1; i < times.length; i++) {
|
1947
1580
|
const currentValue = times[i];
|
1948
|
-
|
1949
1581
|
if (currentValue !== lastValue) {
|
1950
1582
|
times[targetIndex] = currentValue;
|
1951
1583
|
lastValue = currentValue;
|
1952
1584
|
targetIndex++;
|
1953
1585
|
}
|
1954
1586
|
}
|
1955
|
-
|
1956
1587
|
times = times.slice(0, targetIndex);
|
1957
1588
|
}
|
1958
|
-
|
1959
1589
|
return times;
|
1960
1590
|
}
|
1961
|
-
|
1962
1591
|
getKeyframeTrackValues(times, curves, initialValue) {
|
1963
1592
|
const prevValue = initialValue;
|
1964
1593
|
const values = [];
|
1965
1594
|
let xIndex = -1;
|
1966
1595
|
let yIndex = -1;
|
1967
1596
|
let zIndex = -1;
|
1968
|
-
times.forEach(function
|
1969
|
-
if (curves.x)
|
1970
|
-
|
1971
|
-
if (curves.
|
1972
|
-
|
1597
|
+
times.forEach(function(time) {
|
1598
|
+
if (curves.x)
|
1599
|
+
xIndex = curves.x.times.indexOf(time);
|
1600
|
+
if (curves.y)
|
1601
|
+
yIndex = curves.y.times.indexOf(time);
|
1602
|
+
if (curves.z)
|
1603
|
+
zIndex = curves.z.times.indexOf(time);
|
1973
1604
|
if (xIndex !== -1) {
|
1974
1605
|
const xValue = curves.x.values[xIndex];
|
1975
1606
|
values.push(xValue);
|
1976
1607
|
prevValue[0] = xValue;
|
1977
1608
|
} else {
|
1978
|
-
// otherwise use the x value from the previous frame
|
1979
1609
|
values.push(prevValue[0]);
|
1980
1610
|
}
|
1981
|
-
|
1982
1611
|
if (yIndex !== -1) {
|
1983
1612
|
const yValue = curves.y.values[yIndex];
|
1984
1613
|
values.push(yValue);
|
@@ -1986,7 +1615,6 @@ class AnimationParser {
|
|
1986
1615
|
} else {
|
1987
1616
|
values.push(prevValue[1]);
|
1988
1617
|
}
|
1989
|
-
|
1990
1618
|
if (zIndex !== -1) {
|
1991
1619
|
const zValue = curves.z.values[zIndex];
|
1992
1620
|
values.push(zValue);
|
@@ -1996,17 +1624,12 @@ class AnimationParser {
|
|
1996
1624
|
}
|
1997
1625
|
});
|
1998
1626
|
return values;
|
1999
|
-
}
|
2000
|
-
// These will be converted to quaternions which don't support values greater than
|
2001
|
-
// PI, so we'll interpolate large rotations
|
2002
|
-
|
2003
|
-
|
1627
|
+
}
|
2004
1628
|
interpolateRotations(curve) {
|
2005
1629
|
for (let i = 1; i < curve.values.length; i++) {
|
2006
1630
|
const initialValue = curve.values[i - 1];
|
2007
1631
|
const valuesSpan = curve.values[i] - initialValue;
|
2008
1632
|
const absoluteSpan = Math.abs(valuesSpan);
|
2009
|
-
|
2010
1633
|
if (absoluteSpan >= 180) {
|
2011
1634
|
const numSubIntervals = absoluteSpan / 180;
|
2012
1635
|
const step = valuesSpan / numSubIntervals;
|
@@ -2017,67 +1640,56 @@ class AnimationParser {
|
|
2017
1640
|
let nextTime = initialTime + interval;
|
2018
1641
|
const interpolatedTimes = [];
|
2019
1642
|
const interpolatedValues = [];
|
2020
|
-
|
2021
1643
|
while (nextTime < curve.times[i]) {
|
2022
1644
|
interpolatedTimes.push(nextTime);
|
2023
1645
|
nextTime += interval;
|
2024
1646
|
interpolatedValues.push(nextValue);
|
2025
1647
|
nextValue += step;
|
2026
1648
|
}
|
2027
|
-
|
2028
1649
|
curve.times = inject(curve.times, i, interpolatedTimes);
|
2029
1650
|
curve.values = inject(curve.values, i, interpolatedValues);
|
2030
1651
|
}
|
2031
1652
|
}
|
2032
1653
|
}
|
2033
|
-
|
2034
|
-
} // parse an FBX file in ASCII format
|
2035
|
-
|
2036
|
-
|
1654
|
+
}
|
2037
1655
|
class TextParser {
|
2038
1656
|
getPrevNode() {
|
2039
1657
|
return this.nodeStack[this.currentIndent - 2];
|
2040
1658
|
}
|
2041
|
-
|
2042
1659
|
getCurrentNode() {
|
2043
1660
|
return this.nodeStack[this.currentIndent - 1];
|
2044
1661
|
}
|
2045
|
-
|
2046
1662
|
getCurrentProp() {
|
2047
1663
|
return this.currentProp;
|
2048
1664
|
}
|
2049
|
-
|
2050
1665
|
pushStack(node) {
|
2051
1666
|
this.nodeStack.push(node);
|
2052
1667
|
this.currentIndent += 1;
|
2053
1668
|
}
|
2054
|
-
|
2055
1669
|
popStack() {
|
2056
1670
|
this.nodeStack.pop();
|
2057
1671
|
this.currentIndent -= 1;
|
2058
1672
|
}
|
2059
|
-
|
2060
1673
|
setCurrentProp(val, name) {
|
2061
1674
|
this.currentProp = val;
|
2062
1675
|
this.currentPropName = name;
|
2063
1676
|
}
|
2064
|
-
|
2065
1677
|
parse(text) {
|
2066
1678
|
this.currentIndent = 0;
|
2067
1679
|
this.allNodes = new FBXTree();
|
2068
1680
|
this.nodeStack = [];
|
2069
1681
|
this.currentProp = [];
|
2070
|
-
this.currentPropName =
|
1682
|
+
this.currentPropName = "";
|
2071
1683
|
const scope = this;
|
2072
1684
|
const split = text.split(/[\r\n]+/);
|
2073
|
-
split.forEach(function
|
1685
|
+
split.forEach(function(line, i) {
|
2074
1686
|
const matchComment = line.match(/^[\s\t]*;/);
|
2075
1687
|
const matchEmpty = line.match(/^[\s\t]*$/);
|
2076
|
-
if (matchComment || matchEmpty)
|
2077
|
-
|
2078
|
-
const
|
2079
|
-
const
|
2080
|
-
|
1688
|
+
if (matchComment || matchEmpty)
|
1689
|
+
return;
|
1690
|
+
const matchBeginning = line.match("^\\t{" + scope.currentIndent + "}(\\w+):(.*){", "");
|
1691
|
+
const matchProperty = line.match("^\\t{" + scope.currentIndent + "}(\\w+):[\\s\\t\\r\\n](.*)");
|
1692
|
+
const matchEnd = line.match("^\\t{" + (scope.currentIndent - 1) + "}}");
|
2081
1693
|
if (matchBeginning) {
|
2082
1694
|
scope.parseNodeBegin(line, matchBeginning);
|
2083
1695
|
} else if (matchProperty) {
|
@@ -2085,179 +1697,141 @@ class TextParser {
|
|
2085
1697
|
} else if (matchEnd) {
|
2086
1698
|
scope.popStack();
|
2087
1699
|
} else if (line.match(/^[^\s\t}]/)) {
|
2088
|
-
// large arrays are split over multiple lines terminated with a ',' character
|
2089
|
-
// if this is encountered the line needs to be joined to the previous line
|
2090
1700
|
scope.parseNodePropertyContinued(line);
|
2091
1701
|
}
|
2092
1702
|
});
|
2093
1703
|
return this.allNodes;
|
2094
1704
|
}
|
2095
|
-
|
2096
1705
|
parseNodeBegin(line, property) {
|
2097
|
-
const nodeName = property[1].trim().replace(/^"/,
|
2098
|
-
const nodeAttrs = property[2].split(
|
2099
|
-
return attr.trim().replace(/^"/,
|
1706
|
+
const nodeName = property[1].trim().replace(/^"/, "").replace(/"$/, "");
|
1707
|
+
const nodeAttrs = property[2].split(",").map(function(attr) {
|
1708
|
+
return attr.trim().replace(/^"/, "").replace(/"$/, "");
|
2100
1709
|
});
|
2101
|
-
const node = {
|
2102
|
-
name: nodeName
|
2103
|
-
};
|
1710
|
+
const node = { name: nodeName };
|
2104
1711
|
const attrs = this.parseNodeAttr(nodeAttrs);
|
2105
|
-
const currentNode = this.getCurrentNode();
|
2106
|
-
|
1712
|
+
const currentNode = this.getCurrentNode();
|
2107
1713
|
if (this.currentIndent === 0) {
|
2108
1714
|
this.allNodes.add(nodeName, node);
|
2109
1715
|
} else {
|
2110
|
-
// a subnode
|
2111
|
-
// if the subnode already exists, append it
|
2112
1716
|
if (nodeName in currentNode) {
|
2113
|
-
|
2114
|
-
if (nodeName === 'PoseNode') {
|
1717
|
+
if (nodeName === "PoseNode") {
|
2115
1718
|
currentNode.PoseNode.push(node);
|
2116
|
-
} else if (currentNode[nodeName].id !==
|
1719
|
+
} else if (currentNode[nodeName].id !== void 0) {
|
2117
1720
|
currentNode[nodeName] = {};
|
2118
1721
|
currentNode[nodeName][currentNode[nodeName].id] = currentNode[nodeName];
|
2119
1722
|
}
|
2120
|
-
|
2121
|
-
|
2122
|
-
} else if (typeof attrs.id ===
|
1723
|
+
if (attrs.id !== "")
|
1724
|
+
currentNode[nodeName][attrs.id] = node;
|
1725
|
+
} else if (typeof attrs.id === "number") {
|
2123
1726
|
currentNode[nodeName] = {};
|
2124
1727
|
currentNode[nodeName][attrs.id] = node;
|
2125
|
-
} else if (nodeName !==
|
2126
|
-
if (nodeName ===
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
if (attrs.
|
1728
|
+
} else if (nodeName !== "Properties70") {
|
1729
|
+
if (nodeName === "PoseNode")
|
1730
|
+
currentNode[nodeName] = [node];
|
1731
|
+
else
|
1732
|
+
currentNode[nodeName] = node;
|
1733
|
+
}
|
1734
|
+
}
|
1735
|
+
if (typeof attrs.id === "number")
|
1736
|
+
node.id = attrs.id;
|
1737
|
+
if (attrs.name !== "")
|
1738
|
+
node.attrName = attrs.name;
|
1739
|
+
if (attrs.type !== "")
|
1740
|
+
node.attrType = attrs.type;
|
2133
1741
|
this.pushStack(node);
|
2134
1742
|
}
|
2135
|
-
|
2136
1743
|
parseNodeAttr(attrs) {
|
2137
1744
|
let id = attrs[0];
|
2138
|
-
|
2139
|
-
if (attrs[0] !== '') {
|
1745
|
+
if (attrs[0] !== "") {
|
2140
1746
|
id = parseInt(attrs[0]);
|
2141
|
-
|
2142
1747
|
if (isNaN(id)) {
|
2143
1748
|
id = attrs[0];
|
2144
1749
|
}
|
2145
1750
|
}
|
2146
|
-
|
2147
|
-
let name = '',
|
2148
|
-
type = '';
|
2149
|
-
|
1751
|
+
let name = "", type = "";
|
2150
1752
|
if (attrs.length > 1) {
|
2151
|
-
name = attrs[1].replace(/^(\w+)::/,
|
1753
|
+
name = attrs[1].replace(/^(\w+)::/, "");
|
2152
1754
|
type = attrs[2];
|
2153
1755
|
}
|
2154
|
-
|
2155
|
-
return {
|
2156
|
-
id: id,
|
2157
|
-
name: name,
|
2158
|
-
type: type
|
2159
|
-
};
|
1756
|
+
return { id, name, type };
|
2160
1757
|
}
|
2161
|
-
|
2162
1758
|
parseNodeProperty(line, property, contentLine) {
|
2163
|
-
let propName = property[1].replace(/^"/,
|
2164
|
-
let propValue = property[2].replace(/^"/,
|
2165
|
-
|
2166
|
-
|
2167
|
-
|
2168
|
-
if (propName === 'Content' && propValue === ',') {
|
2169
|
-
propValue = contentLine.replace(/"/g, '').replace(/,$/, '').trim();
|
2170
|
-
}
|
2171
|
-
|
1759
|
+
let propName = property[1].replace(/^"/, "").replace(/"$/, "").trim();
|
1760
|
+
let propValue = property[2].replace(/^"/, "").replace(/"$/, "").trim();
|
1761
|
+
if (propName === "Content" && propValue === ",") {
|
1762
|
+
propValue = contentLine.replace(/"/g, "").replace(/,$/, "").trim();
|
1763
|
+
}
|
2172
1764
|
const currentNode = this.getCurrentNode();
|
2173
1765
|
const parentName = currentNode.name;
|
2174
|
-
|
2175
|
-
if (parentName === 'Properties70') {
|
1766
|
+
if (parentName === "Properties70") {
|
2176
1767
|
this.parseNodeSpecialProperty(line, propName, propValue);
|
2177
1768
|
return;
|
2178
|
-
}
|
2179
|
-
|
2180
|
-
|
2181
|
-
if (propName === 'C') {
|
2182
|
-
const connProps = propValue.split(',').slice(1);
|
1769
|
+
}
|
1770
|
+
if (propName === "C") {
|
1771
|
+
const connProps = propValue.split(",").slice(1);
|
2183
1772
|
const from = parseInt(connProps[0]);
|
2184
1773
|
const to = parseInt(connProps[1]);
|
2185
|
-
let rest = propValue.split(
|
2186
|
-
rest = rest.map(function
|
2187
|
-
return elem.trim().replace(/^"/,
|
1774
|
+
let rest = propValue.split(",").slice(3);
|
1775
|
+
rest = rest.map(function(elem) {
|
1776
|
+
return elem.trim().replace(/^"/, "");
|
2188
1777
|
});
|
2189
|
-
propName =
|
1778
|
+
propName = "connections";
|
2190
1779
|
propValue = [from, to];
|
2191
1780
|
append(propValue, rest);
|
2192
|
-
|
2193
|
-
if (currentNode[propName] === undefined) {
|
1781
|
+
if (currentNode[propName] === void 0) {
|
2194
1782
|
currentNode[propName] = [];
|
2195
1783
|
}
|
2196
|
-
}
|
2197
|
-
|
2198
|
-
|
2199
|
-
if (propName === 'Node') currentNode.id = propValue; // connections
|
2200
|
-
|
1784
|
+
}
|
1785
|
+
if (propName === "Node")
|
1786
|
+
currentNode.id = propValue;
|
2201
1787
|
if (propName in currentNode && Array.isArray(currentNode[propName])) {
|
2202
1788
|
currentNode[propName].push(propValue);
|
2203
1789
|
} else {
|
2204
|
-
if (propName !==
|
1790
|
+
if (propName !== "a")
|
1791
|
+
currentNode[propName] = propValue;
|
1792
|
+
else
|
1793
|
+
currentNode.a = propValue;
|
2205
1794
|
}
|
2206
|
-
|
2207
|
-
|
2208
|
-
|
2209
|
-
if (propName === 'a' && propValue.slice(-1) !== ',') {
|
1795
|
+
this.setCurrentProp(currentNode, propName);
|
1796
|
+
if (propName === "a" && propValue.slice(-1) !== ",") {
|
2210
1797
|
currentNode.a = parseNumberArray(propValue);
|
2211
1798
|
}
|
2212
1799
|
}
|
2213
|
-
|
2214
1800
|
parseNodePropertyContinued(line) {
|
2215
1801
|
const currentNode = this.getCurrentNode();
|
2216
|
-
currentNode.a += line;
|
2217
|
-
|
2218
|
-
|
2219
|
-
if (line.slice(-1) !== ',') {
|
1802
|
+
currentNode.a += line;
|
1803
|
+
if (line.slice(-1) !== ",") {
|
2220
1804
|
currentNode.a = parseNumberArray(currentNode.a);
|
2221
1805
|
}
|
2222
|
-
}
|
2223
|
-
|
2224
|
-
|
1806
|
+
}
|
2225
1807
|
parseNodeSpecialProperty(line, propName, propValue) {
|
2226
|
-
|
2227
|
-
|
2228
|
-
// into array like below
|
2229
|
-
// ["Lcl Scaling", "Lcl Scaling", "", "A", "1,1,1" ]
|
2230
|
-
const props = propValue.split('",').map(function (prop) {
|
2231
|
-
return prop.trim().replace(/^\"/, '').replace(/\s/, '_');
|
1808
|
+
const props = propValue.split('",').map(function(prop) {
|
1809
|
+
return prop.trim().replace(/^\"/, "").replace(/\s/, "_");
|
2232
1810
|
});
|
2233
1811
|
const innerPropName = props[0];
|
2234
1812
|
const innerPropType1 = props[1];
|
2235
1813
|
const innerPropType2 = props[2];
|
2236
1814
|
const innerPropFlag = props[3];
|
2237
|
-
let innerPropValue = props[4];
|
2238
|
-
|
1815
|
+
let innerPropValue = props[4];
|
2239
1816
|
switch (innerPropType1) {
|
2240
|
-
case
|
2241
|
-
case
|
2242
|
-
case
|
2243
|
-
case
|
2244
|
-
case
|
2245
|
-
case
|
2246
|
-
case
|
1817
|
+
case "int":
|
1818
|
+
case "enum":
|
1819
|
+
case "bool":
|
1820
|
+
case "ULongLong":
|
1821
|
+
case "double":
|
1822
|
+
case "Number":
|
1823
|
+
case "FieldOfView":
|
2247
1824
|
innerPropValue = parseFloat(innerPropValue);
|
2248
1825
|
break;
|
2249
|
-
|
2250
|
-
case
|
2251
|
-
case
|
2252
|
-
case
|
2253
|
-
case
|
2254
|
-
case
|
2255
|
-
case 'Lcl_Scaling':
|
1826
|
+
case "Color":
|
1827
|
+
case "ColorRGB":
|
1828
|
+
case "Vector3D":
|
1829
|
+
case "Lcl_Translation":
|
1830
|
+
case "Lcl_Rotation":
|
1831
|
+
case "Lcl_Scaling":
|
2256
1832
|
innerPropValue = parseNumberArray(innerPropValue);
|
2257
1833
|
break;
|
2258
|
-
}
|
2259
|
-
|
2260
|
-
|
1834
|
+
}
|
2261
1835
|
this.getPrevNode()[innerPropName] = {
|
2262
1836
|
type: innerPropType1,
|
2263
1837
|
type2: innerPropType2,
|
@@ -2266,361 +1840,272 @@ class TextParser {
|
|
2266
1840
|
};
|
2267
1841
|
this.setCurrentProp(this.getPrevNode(), innerPropName);
|
2268
1842
|
}
|
2269
|
-
|
2270
|
-
} // Parse an FBX file in Binary format
|
2271
|
-
|
2272
|
-
|
1843
|
+
}
|
2273
1844
|
class BinaryParser {
|
2274
1845
|
parse(buffer) {
|
2275
1846
|
const reader = new BinaryReader(buffer);
|
2276
|
-
reader.skip(23);
|
2277
|
-
|
1847
|
+
reader.skip(23);
|
2278
1848
|
const version = reader.getUint32();
|
2279
|
-
|
2280
1849
|
if (version < 6400) {
|
2281
|
-
throw new Error(
|
1850
|
+
throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: " + version);
|
2282
1851
|
}
|
2283
|
-
|
2284
1852
|
const allNodes = new FBXTree();
|
2285
|
-
|
2286
1853
|
while (!this.endOfContent(reader)) {
|
2287
1854
|
const node = this.parseNode(reader, version);
|
2288
|
-
if (node !== null)
|
1855
|
+
if (node !== null)
|
1856
|
+
allNodes.add(node.name, node);
|
2289
1857
|
}
|
2290
|
-
|
2291
1858
|
return allNodes;
|
2292
|
-
}
|
2293
|
-
|
2294
|
-
|
1859
|
+
}
|
2295
1860
|
endOfContent(reader) {
|
2296
|
-
// footer size: 160bytes + 16-byte alignment padding
|
2297
|
-
// - 16bytes: magic
|
2298
|
-
// - padding til 16-byte alignment (at least 1byte?)
|
2299
|
-
// (seems like some exporters embed fixed 15 or 16bytes?)
|
2300
|
-
// - 4bytes: magic
|
2301
|
-
// - 4bytes: version
|
2302
|
-
// - 120bytes: zero
|
2303
|
-
// - 16bytes: magic
|
2304
1861
|
if (reader.size() % 16 === 0) {
|
2305
|
-
return (reader.getOffset() + 160 + 16 & ~
|
1862
|
+
return (reader.getOffset() + 160 + 16 & ~15) >= reader.size();
|
2306
1863
|
} else {
|
2307
1864
|
return reader.getOffset() + 160 + 16 >= reader.size();
|
2308
1865
|
}
|
2309
|
-
}
|
2310
|
-
|
2311
|
-
|
1866
|
+
}
|
2312
1867
|
parseNode(reader, version) {
|
2313
|
-
const node = {};
|
2314
|
-
|
1868
|
+
const node = {};
|
2315
1869
|
const endOffset = version >= 7500 ? reader.getUint64() : reader.getUint32();
|
2316
1870
|
const numProperties = version >= 7500 ? reader.getUint64() : reader.getUint32();
|
2317
|
-
version >= 7500 ? reader.getUint64() : reader.getUint32();
|
2318
|
-
|
1871
|
+
version >= 7500 ? reader.getUint64() : reader.getUint32();
|
2319
1872
|
const nameLen = reader.getUint8();
|
2320
|
-
const name = reader.getString(nameLen);
|
2321
|
-
|
2322
|
-
|
1873
|
+
const name = reader.getString(nameLen);
|
1874
|
+
if (endOffset === 0)
|
1875
|
+
return null;
|
2323
1876
|
const propertyList = [];
|
2324
|
-
|
2325
1877
|
for (let i = 0; i < numProperties; i++) {
|
2326
1878
|
propertyList.push(this.parseProperty(reader));
|
2327
|
-
}
|
2328
|
-
|
2329
|
-
|
2330
|
-
const
|
2331
|
-
const attrName = propertyList.length > 1 ? propertyList[1] : '';
|
2332
|
-
const attrType = propertyList.length > 2 ? propertyList[2] : ''; // check if this node represents just a single property
|
2333
|
-
// like (name, 0) set or (name2, [0, 1, 2]) set of {name: 0, name2: [0, 1, 2]}
|
2334
|
-
|
1879
|
+
}
|
1880
|
+
const id = propertyList.length > 0 ? propertyList[0] : "";
|
1881
|
+
const attrName = propertyList.length > 1 ? propertyList[1] : "";
|
1882
|
+
const attrType = propertyList.length > 2 ? propertyList[2] : "";
|
2335
1883
|
node.singleProperty = numProperties === 1 && reader.getOffset() === endOffset ? true : false;
|
2336
|
-
|
2337
1884
|
while (endOffset > reader.getOffset()) {
|
2338
1885
|
const subNode = this.parseNode(reader, version);
|
2339
|
-
if (subNode !== null)
|
2340
|
-
|
2341
|
-
|
2342
|
-
node.propertyList = propertyList;
|
2343
|
-
|
2344
|
-
|
2345
|
-
if (attrName !==
|
2346
|
-
|
2347
|
-
if (
|
1886
|
+
if (subNode !== null)
|
1887
|
+
this.parseSubNode(name, node, subNode);
|
1888
|
+
}
|
1889
|
+
node.propertyList = propertyList;
|
1890
|
+
if (typeof id === "number")
|
1891
|
+
node.id = id;
|
1892
|
+
if (attrName !== "")
|
1893
|
+
node.attrName = attrName;
|
1894
|
+
if (attrType !== "")
|
1895
|
+
node.attrType = attrType;
|
1896
|
+
if (name !== "")
|
1897
|
+
node.name = name;
|
2348
1898
|
return node;
|
2349
1899
|
}
|
2350
|
-
|
2351
1900
|
parseSubNode(name, node, subNode) {
|
2352
|
-
// special case: child node is single property
|
2353
1901
|
if (subNode.singleProperty === true) {
|
2354
1902
|
const value = subNode.propertyList[0];
|
2355
|
-
|
2356
1903
|
if (Array.isArray(value)) {
|
2357
1904
|
node[subNode.name] = subNode;
|
2358
1905
|
subNode.a = value;
|
2359
1906
|
} else {
|
2360
1907
|
node[subNode.name] = value;
|
2361
1908
|
}
|
2362
|
-
} else if (name ===
|
1909
|
+
} else if (name === "Connections" && subNode.name === "C") {
|
2363
1910
|
const array = [];
|
2364
|
-
subNode.propertyList.forEach(function
|
2365
|
-
|
2366
|
-
|
1911
|
+
subNode.propertyList.forEach(function(property, i) {
|
1912
|
+
if (i !== 0)
|
1913
|
+
array.push(property);
|
2367
1914
|
});
|
2368
|
-
|
2369
|
-
if (node.connections === undefined) {
|
1915
|
+
if (node.connections === void 0) {
|
2370
1916
|
node.connections = [];
|
2371
1917
|
}
|
2372
|
-
|
2373
1918
|
node.connections.push(array);
|
2374
|
-
} else if (subNode.name ===
|
1919
|
+
} else if (subNode.name === "Properties70") {
|
2375
1920
|
const keys = Object.keys(subNode);
|
2376
|
-
keys.forEach(function
|
1921
|
+
keys.forEach(function(key) {
|
2377
1922
|
node[key] = subNode[key];
|
2378
1923
|
});
|
2379
|
-
} else if (name ===
|
1924
|
+
} else if (name === "Properties70" && subNode.name === "P") {
|
2380
1925
|
let innerPropName = subNode.propertyList[0];
|
2381
1926
|
let innerPropType1 = subNode.propertyList[1];
|
2382
1927
|
const innerPropType2 = subNode.propertyList[2];
|
2383
1928
|
const innerPropFlag = subNode.propertyList[3];
|
2384
1929
|
let innerPropValue;
|
2385
|
-
if (innerPropName.indexOf(
|
2386
|
-
|
2387
|
-
|
2388
|
-
|
1930
|
+
if (innerPropName.indexOf("Lcl ") === 0)
|
1931
|
+
innerPropName = innerPropName.replace("Lcl ", "Lcl_");
|
1932
|
+
if (innerPropType1.indexOf("Lcl ") === 0)
|
1933
|
+
innerPropType1 = innerPropType1.replace("Lcl ", "Lcl_");
|
1934
|
+
if (innerPropType1 === "Color" || innerPropType1 === "ColorRGB" || innerPropType1 === "Vector" || innerPropType1 === "Vector3D" || innerPropType1.indexOf("Lcl_") === 0) {
|
2389
1935
|
innerPropValue = [subNode.propertyList[4], subNode.propertyList[5], subNode.propertyList[6]];
|
2390
1936
|
} else {
|
2391
1937
|
innerPropValue = subNode.propertyList[4];
|
2392
|
-
}
|
2393
|
-
|
2394
|
-
|
1938
|
+
}
|
2395
1939
|
node[innerPropName] = {
|
2396
1940
|
type: innerPropType1,
|
2397
1941
|
type2: innerPropType2,
|
2398
1942
|
flag: innerPropFlag,
|
2399
1943
|
value: innerPropValue
|
2400
1944
|
};
|
2401
|
-
} else if (node[subNode.name] ===
|
2402
|
-
if (typeof subNode.id ===
|
1945
|
+
} else if (node[subNode.name] === void 0) {
|
1946
|
+
if (typeof subNode.id === "number") {
|
2403
1947
|
node[subNode.name] = {};
|
2404
1948
|
node[subNode.name][subNode.id] = subNode;
|
2405
1949
|
} else {
|
2406
1950
|
node[subNode.name] = subNode;
|
2407
1951
|
}
|
2408
1952
|
} else {
|
2409
|
-
if (subNode.name ===
|
1953
|
+
if (subNode.name === "PoseNode") {
|
2410
1954
|
if (!Array.isArray(node[subNode.name])) {
|
2411
1955
|
node[subNode.name] = [node[subNode.name]];
|
2412
1956
|
}
|
2413
|
-
|
2414
1957
|
node[subNode.name].push(subNode);
|
2415
|
-
} else if (node[subNode.name][subNode.id] ===
|
1958
|
+
} else if (node[subNode.name][subNode.id] === void 0) {
|
2416
1959
|
node[subNode.name][subNode.id] = subNode;
|
2417
1960
|
}
|
2418
1961
|
}
|
2419
1962
|
}
|
2420
|
-
|
2421
1963
|
parseProperty(reader) {
|
2422
1964
|
const type = reader.getString(1);
|
2423
1965
|
let length;
|
2424
|
-
|
2425
1966
|
switch (type) {
|
2426
|
-
case
|
1967
|
+
case "C":
|
2427
1968
|
return reader.getBoolean();
|
2428
|
-
|
2429
|
-
case 'D':
|
1969
|
+
case "D":
|
2430
1970
|
return reader.getFloat64();
|
2431
|
-
|
2432
|
-
case 'F':
|
1971
|
+
case "F":
|
2433
1972
|
return reader.getFloat32();
|
2434
|
-
|
2435
|
-
case 'I':
|
1973
|
+
case "I":
|
2436
1974
|
return reader.getInt32();
|
2437
|
-
|
2438
|
-
case 'L':
|
1975
|
+
case "L":
|
2439
1976
|
return reader.getInt64();
|
2440
|
-
|
2441
|
-
case 'R':
|
1977
|
+
case "R":
|
2442
1978
|
length = reader.getUint32();
|
2443
1979
|
return reader.getArrayBuffer(length);
|
2444
|
-
|
2445
|
-
case 'S':
|
1980
|
+
case "S":
|
2446
1981
|
length = reader.getUint32();
|
2447
1982
|
return reader.getString(length);
|
2448
|
-
|
2449
|
-
case 'Y':
|
1983
|
+
case "Y":
|
2450
1984
|
return reader.getInt16();
|
2451
|
-
|
2452
|
-
case
|
2453
|
-
case
|
2454
|
-
case
|
2455
|
-
case
|
2456
|
-
case
|
2457
|
-
case 'l':
|
1985
|
+
case "b":
|
1986
|
+
case "c":
|
1987
|
+
case "d":
|
1988
|
+
case "f":
|
1989
|
+
case "i":
|
1990
|
+
case "l":
|
2458
1991
|
const arrayLength = reader.getUint32();
|
2459
|
-
const encoding = reader.getUint32();
|
2460
|
-
|
1992
|
+
const encoding = reader.getUint32();
|
2461
1993
|
const compressedLength = reader.getUint32();
|
2462
|
-
|
2463
1994
|
if (encoding === 0) {
|
2464
1995
|
switch (type) {
|
2465
|
-
case
|
2466
|
-
case
|
1996
|
+
case "b":
|
1997
|
+
case "c":
|
2467
1998
|
return reader.getBooleanArray(arrayLength);
|
2468
|
-
|
2469
|
-
case 'd':
|
1999
|
+
case "d":
|
2470
2000
|
return reader.getFloat64Array(arrayLength);
|
2471
|
-
|
2472
|
-
case 'f':
|
2001
|
+
case "f":
|
2473
2002
|
return reader.getFloat32Array(arrayLength);
|
2474
|
-
|
2475
|
-
case 'i':
|
2003
|
+
case "i":
|
2476
2004
|
return reader.getInt32Array(arrayLength);
|
2477
|
-
|
2478
|
-
case 'l':
|
2005
|
+
case "l":
|
2479
2006
|
return reader.getInt64Array(arrayLength);
|
2480
2007
|
}
|
2481
2008
|
}
|
2482
|
-
|
2483
|
-
const data = unzlibSync(new Uint8Array(reader.getArrayBuffer(compressedLength))); // eslint-disable-line no-undef
|
2484
|
-
|
2009
|
+
const data = fflate.unzlibSync(new Uint8Array(reader.getArrayBuffer(compressedLength)));
|
2485
2010
|
const reader2 = new BinaryReader(data.buffer);
|
2486
|
-
|
2487
2011
|
switch (type) {
|
2488
|
-
case
|
2489
|
-
case
|
2012
|
+
case "b":
|
2013
|
+
case "c":
|
2490
2014
|
return reader2.getBooleanArray(arrayLength);
|
2491
|
-
|
2492
|
-
case 'd':
|
2015
|
+
case "d":
|
2493
2016
|
return reader2.getFloat64Array(arrayLength);
|
2494
|
-
|
2495
|
-
case 'f':
|
2017
|
+
case "f":
|
2496
2018
|
return reader2.getFloat32Array(arrayLength);
|
2497
|
-
|
2498
|
-
case 'i':
|
2019
|
+
case "i":
|
2499
2020
|
return reader2.getInt32Array(arrayLength);
|
2500
|
-
|
2501
|
-
case 'l':
|
2021
|
+
case "l":
|
2502
2022
|
return reader2.getInt64Array(arrayLength);
|
2503
2023
|
}
|
2504
|
-
|
2505
2024
|
default:
|
2506
|
-
throw new Error(
|
2025
|
+
throw new Error("THREE.FBXLoader: Unknown property type " + type);
|
2507
2026
|
}
|
2508
2027
|
}
|
2509
|
-
|
2510
2028
|
}
|
2511
|
-
|
2512
2029
|
class BinaryReader {
|
2513
2030
|
constructor(buffer, littleEndian) {
|
2514
2031
|
this.dv = new DataView(buffer);
|
2515
2032
|
this.offset = 0;
|
2516
|
-
this.littleEndian = littleEndian !==
|
2033
|
+
this.littleEndian = littleEndian !== void 0 ? littleEndian : true;
|
2517
2034
|
}
|
2518
|
-
|
2519
2035
|
getOffset() {
|
2520
2036
|
return this.offset;
|
2521
2037
|
}
|
2522
|
-
|
2523
2038
|
size() {
|
2524
2039
|
return this.dv.buffer.byteLength;
|
2525
2040
|
}
|
2526
|
-
|
2527
2041
|
skip(length) {
|
2528
2042
|
this.offset += length;
|
2529
|
-
}
|
2530
|
-
// true: 1 or 'Y'(=0x59), false: 0 or 'T'(=0x54)
|
2531
|
-
// then sees LSB.
|
2532
|
-
|
2533
|
-
|
2043
|
+
}
|
2534
2044
|
getBoolean() {
|
2535
2045
|
return (this.getUint8() & 1) === 1;
|
2536
2046
|
}
|
2537
|
-
|
2538
2047
|
getBooleanArray(size) {
|
2539
2048
|
const a = [];
|
2540
|
-
|
2541
2049
|
for (let i = 0; i < size; i++) {
|
2542
2050
|
a.push(this.getBoolean());
|
2543
2051
|
}
|
2544
|
-
|
2545
2052
|
return a;
|
2546
2053
|
}
|
2547
|
-
|
2548
2054
|
getUint8() {
|
2549
2055
|
const value = this.dv.getUint8(this.offset);
|
2550
2056
|
this.offset += 1;
|
2551
2057
|
return value;
|
2552
2058
|
}
|
2553
|
-
|
2554
2059
|
getInt16() {
|
2555
2060
|
const value = this.dv.getInt16(this.offset, this.littleEndian);
|
2556
2061
|
this.offset += 2;
|
2557
2062
|
return value;
|
2558
2063
|
}
|
2559
|
-
|
2560
2064
|
getInt32() {
|
2561
2065
|
const value = this.dv.getInt32(this.offset, this.littleEndian);
|
2562
2066
|
this.offset += 4;
|
2563
2067
|
return value;
|
2564
2068
|
}
|
2565
|
-
|
2566
2069
|
getInt32Array(size) {
|
2567
2070
|
const a = [];
|
2568
|
-
|
2569
2071
|
for (let i = 0; i < size; i++) {
|
2570
2072
|
a.push(this.getInt32());
|
2571
2073
|
}
|
2572
|
-
|
2573
2074
|
return a;
|
2574
2075
|
}
|
2575
|
-
|
2576
2076
|
getUint32() {
|
2577
2077
|
const value = this.dv.getUint32(this.offset, this.littleEndian);
|
2578
2078
|
this.offset += 4;
|
2579
2079
|
return value;
|
2580
|
-
}
|
2581
|
-
// 1 << 32 will return 1 so using multiply operation instead here.
|
2582
|
-
// There's a possibility that this method returns wrong value if the value
|
2583
|
-
// is out of the range between Number.MAX_SAFE_INTEGER and Number.MIN_SAFE_INTEGER.
|
2584
|
-
// TODO: safely handle 64-bit integer
|
2585
|
-
|
2586
|
-
|
2080
|
+
}
|
2587
2081
|
getInt64() {
|
2588
2082
|
let low, high;
|
2589
|
-
|
2590
2083
|
if (this.littleEndian) {
|
2591
2084
|
low = this.getUint32();
|
2592
2085
|
high = this.getUint32();
|
2593
2086
|
} else {
|
2594
2087
|
high = this.getUint32();
|
2595
2088
|
low = this.getUint32();
|
2596
|
-
}
|
2597
|
-
|
2598
|
-
|
2599
|
-
|
2600
|
-
|
2601
|
-
|
2602
|
-
|
2603
|
-
|
2604
|
-
|
2605
|
-
|
2606
|
-
|
2607
|
-
return high * 0x100000000 + low;
|
2608
|
-
}
|
2609
|
-
|
2089
|
+
}
|
2090
|
+
if (high & 2147483648) {
|
2091
|
+
high = ~high & 4294967295;
|
2092
|
+
low = ~low & 4294967295;
|
2093
|
+
if (low === 4294967295)
|
2094
|
+
high = high + 1 & 4294967295;
|
2095
|
+
low = low + 1 & 4294967295;
|
2096
|
+
return -(high * 4294967296 + low);
|
2097
|
+
}
|
2098
|
+
return high * 4294967296 + low;
|
2099
|
+
}
|
2610
2100
|
getInt64Array(size) {
|
2611
2101
|
const a = [];
|
2612
|
-
|
2613
2102
|
for (let i = 0; i < size; i++) {
|
2614
2103
|
a.push(this.getInt64());
|
2615
2104
|
}
|
2616
|
-
|
2617
2105
|
return a;
|
2618
|
-
}
|
2619
|
-
|
2620
|
-
|
2106
|
+
}
|
2621
2107
|
getUint64() {
|
2622
2108
|
let low, high;
|
2623
|
-
|
2624
2109
|
if (this.littleEndian) {
|
2625
2110
|
low = this.getUint32();
|
2626
2111
|
high = this.getUint32();
|
@@ -2628,290 +2113,250 @@ class BinaryReader {
|
|
2628
2113
|
high = this.getUint32();
|
2629
2114
|
low = this.getUint32();
|
2630
2115
|
}
|
2631
|
-
|
2632
|
-
return high * 0x100000000 + low;
|
2116
|
+
return high * 4294967296 + low;
|
2633
2117
|
}
|
2634
|
-
|
2635
2118
|
getFloat32() {
|
2636
2119
|
const value = this.dv.getFloat32(this.offset, this.littleEndian);
|
2637
2120
|
this.offset += 4;
|
2638
2121
|
return value;
|
2639
2122
|
}
|
2640
|
-
|
2641
2123
|
getFloat32Array(size) {
|
2642
2124
|
const a = [];
|
2643
|
-
|
2644
2125
|
for (let i = 0; i < size; i++) {
|
2645
2126
|
a.push(this.getFloat32());
|
2646
2127
|
}
|
2647
|
-
|
2648
2128
|
return a;
|
2649
2129
|
}
|
2650
|
-
|
2651
2130
|
getFloat64() {
|
2652
2131
|
const value = this.dv.getFloat64(this.offset, this.littleEndian);
|
2653
2132
|
this.offset += 8;
|
2654
2133
|
return value;
|
2655
2134
|
}
|
2656
|
-
|
2657
2135
|
getFloat64Array(size) {
|
2658
2136
|
const a = [];
|
2659
|
-
|
2660
2137
|
for (let i = 0; i < size; i++) {
|
2661
2138
|
a.push(this.getFloat64());
|
2662
2139
|
}
|
2663
|
-
|
2664
2140
|
return a;
|
2665
2141
|
}
|
2666
|
-
|
2667
2142
|
getArrayBuffer(size) {
|
2668
2143
|
const value = this.dv.buffer.slice(this.offset, this.offset + size);
|
2669
2144
|
this.offset += size;
|
2670
2145
|
return value;
|
2671
2146
|
}
|
2672
|
-
|
2673
2147
|
getString(size) {
|
2674
|
-
// note: safari 9 doesn't support Uint8Array.indexOf; create intermediate array instead
|
2675
2148
|
let a = [];
|
2676
|
-
|
2677
2149
|
for (let i = 0; i < size; i++) {
|
2678
2150
|
a[i] = this.getUint8();
|
2679
2151
|
}
|
2680
|
-
|
2681
2152
|
const nullByte = a.indexOf(0);
|
2682
|
-
if (nullByte >= 0)
|
2683
|
-
|
2684
|
-
|
2685
|
-
|
2686
|
-
}
|
2687
|
-
// and BinaryParser( FBX Binary format)
|
2688
|
-
|
2689
|
-
|
2153
|
+
if (nullByte >= 0)
|
2154
|
+
a = a.slice(0, nullByte);
|
2155
|
+
return THREE.LoaderUtils.decodeText(new Uint8Array(a));
|
2156
|
+
}
|
2157
|
+
}
|
2690
2158
|
class FBXTree {
|
2691
2159
|
add(key, val) {
|
2692
2160
|
this[key] = val;
|
2693
2161
|
}
|
2694
|
-
|
2695
|
-
} // ************** UTILITY FUNCTIONS **************
|
2696
|
-
|
2697
|
-
|
2162
|
+
}
|
2698
2163
|
function isFbxFormatBinary(buffer) {
|
2699
|
-
const CORRECT =
|
2164
|
+
const CORRECT = "Kaydara FBX Binary \0";
|
2700
2165
|
return buffer.byteLength >= CORRECT.length && CORRECT === convertArrayBufferToString(buffer, 0, CORRECT.length);
|
2701
2166
|
}
|
2702
|
-
|
2703
2167
|
function isFbxFormatASCII(text) {
|
2704
|
-
const CORRECT = [
|
2168
|
+
const CORRECT = [
|
2169
|
+
"K",
|
2170
|
+
"a",
|
2171
|
+
"y",
|
2172
|
+
"d",
|
2173
|
+
"a",
|
2174
|
+
"r",
|
2175
|
+
"a",
|
2176
|
+
"\\",
|
2177
|
+
"F",
|
2178
|
+
"B",
|
2179
|
+
"X",
|
2180
|
+
"\\",
|
2181
|
+
"B",
|
2182
|
+
"i",
|
2183
|
+
"n",
|
2184
|
+
"a",
|
2185
|
+
"r",
|
2186
|
+
"y",
|
2187
|
+
"\\",
|
2188
|
+
"\\"
|
2189
|
+
];
|
2705
2190
|
let cursor = 0;
|
2706
|
-
|
2707
2191
|
function read(offset) {
|
2708
2192
|
const result = text[offset - 1];
|
2709
2193
|
text = text.slice(cursor + offset);
|
2710
2194
|
cursor++;
|
2711
2195
|
return result;
|
2712
2196
|
}
|
2713
|
-
|
2714
2197
|
for (let i = 0; i < CORRECT.length; ++i) {
|
2715
2198
|
const num = read(1);
|
2716
|
-
|
2717
2199
|
if (num === CORRECT[i]) {
|
2718
2200
|
return false;
|
2719
2201
|
}
|
2720
2202
|
}
|
2721
|
-
|
2722
2203
|
return true;
|
2723
2204
|
}
|
2724
|
-
|
2725
2205
|
function getFbxVersion(text) {
|
2726
2206
|
const versionRegExp = /FBXVersion: (\d+)/;
|
2727
2207
|
const match = text.match(versionRegExp);
|
2728
|
-
|
2729
2208
|
if (match) {
|
2730
2209
|
const version = parseInt(match[1]);
|
2731
2210
|
return version;
|
2732
2211
|
}
|
2733
|
-
|
2734
|
-
|
2735
|
-
} // Converts FBX ticks into real time seconds.
|
2736
|
-
|
2737
|
-
|
2212
|
+
throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.");
|
2213
|
+
}
|
2738
2214
|
function convertFBXTimeToSeconds(time) {
|
2739
|
-
return time /
|
2215
|
+
return time / 46186158e3;
|
2740
2216
|
}
|
2741
|
-
|
2742
|
-
const dataArray = []; // extracts the data from the correct position in the FBX array based on indexing type
|
2743
|
-
|
2217
|
+
const dataArray = [];
|
2744
2218
|
function getData(polygonVertexIndex, polygonIndex, vertexIndex, infoObject) {
|
2745
2219
|
let index;
|
2746
|
-
|
2747
2220
|
switch (infoObject.mappingType) {
|
2748
|
-
case
|
2221
|
+
case "ByPolygonVertex":
|
2749
2222
|
index = polygonVertexIndex;
|
2750
2223
|
break;
|
2751
|
-
|
2752
|
-
case 'ByPolygon':
|
2224
|
+
case "ByPolygon":
|
2753
2225
|
index = polygonIndex;
|
2754
2226
|
break;
|
2755
|
-
|
2756
|
-
case 'ByVertice':
|
2227
|
+
case "ByVertice":
|
2757
2228
|
index = vertexIndex;
|
2758
2229
|
break;
|
2759
|
-
|
2760
|
-
case 'AllSame':
|
2230
|
+
case "AllSame":
|
2761
2231
|
index = infoObject.indices[0];
|
2762
2232
|
break;
|
2763
|
-
|
2764
2233
|
default:
|
2765
|
-
console.warn(
|
2234
|
+
console.warn("THREE.FBXLoader: unknown attribute mapping type " + infoObject.mappingType);
|
2766
2235
|
}
|
2767
|
-
|
2768
|
-
|
2236
|
+
if (infoObject.referenceType === "IndexToDirect")
|
2237
|
+
index = infoObject.indices[index];
|
2769
2238
|
const from = index * infoObject.dataSize;
|
2770
2239
|
const to = from + infoObject.dataSize;
|
2771
2240
|
return slice(dataArray, infoObject.buffer, from, to);
|
2772
2241
|
}
|
2773
|
-
|
2774
|
-
const
|
2775
|
-
const tempVec = new Vector3(); // generate transformation from FBX transform data
|
2776
|
-
// ref: https://help.autodesk.com/view/FBX/2017/ENU/?guid=__files_GUID_10CDD63C_79C1_4F2D_BB28_AD2BE65A02ED_htm
|
2777
|
-
// ref: http://docs.autodesk.com/FBX/2014/ENU/FBX-SDK-Documentation/index.html?url=cpp_ref/_transformations_2main_8cxx-example.html,topicNumber=cpp_ref__transformations_2main_8cxx_example_htmlfc10a1e1-b18d-4e72-9dc0-70d0f1959f5e
|
2778
|
-
|
2242
|
+
const tempEuler = new THREE.Euler();
|
2243
|
+
const tempVec = new THREE.Vector3();
|
2779
2244
|
function generateTransform(transformData) {
|
2780
|
-
const lTranslationM = new Matrix4();
|
2781
|
-
const lPreRotationM = new Matrix4();
|
2782
|
-
const lRotationM = new Matrix4();
|
2783
|
-
const lPostRotationM = new Matrix4();
|
2784
|
-
const lScalingM = new Matrix4();
|
2785
|
-
const lScalingPivotM = new Matrix4();
|
2786
|
-
const lScalingOffsetM = new Matrix4();
|
2787
|
-
const lRotationOffsetM = new Matrix4();
|
2788
|
-
const lRotationPivotM = new Matrix4();
|
2789
|
-
const lParentGX = new Matrix4();
|
2790
|
-
const lParentLX = new Matrix4();
|
2791
|
-
const lGlobalT = new Matrix4();
|
2245
|
+
const lTranslationM = new THREE.Matrix4();
|
2246
|
+
const lPreRotationM = new THREE.Matrix4();
|
2247
|
+
const lRotationM = new THREE.Matrix4();
|
2248
|
+
const lPostRotationM = new THREE.Matrix4();
|
2249
|
+
const lScalingM = new THREE.Matrix4();
|
2250
|
+
const lScalingPivotM = new THREE.Matrix4();
|
2251
|
+
const lScalingOffsetM = new THREE.Matrix4();
|
2252
|
+
const lRotationOffsetM = new THREE.Matrix4();
|
2253
|
+
const lRotationPivotM = new THREE.Matrix4();
|
2254
|
+
const lParentGX = new THREE.Matrix4();
|
2255
|
+
const lParentLX = new THREE.Matrix4();
|
2256
|
+
const lGlobalT = new THREE.Matrix4();
|
2792
2257
|
const inheritType = transformData.inheritType ? transformData.inheritType : 0;
|
2793
|
-
if (transformData.translation)
|
2794
|
-
|
2258
|
+
if (transformData.translation)
|
2259
|
+
lTranslationM.setPosition(tempVec.fromArray(transformData.translation));
|
2795
2260
|
if (transformData.preRotation) {
|
2796
|
-
const array = transformData.preRotation.map(MathUtils.degToRad);
|
2261
|
+
const array = transformData.preRotation.map(THREE.MathUtils.degToRad);
|
2797
2262
|
array.push(transformData.eulerOrder);
|
2798
2263
|
lPreRotationM.makeRotationFromEuler(tempEuler.fromArray(array));
|
2799
2264
|
}
|
2800
|
-
|
2801
2265
|
if (transformData.rotation) {
|
2802
|
-
const array = transformData.rotation.map(MathUtils.degToRad);
|
2266
|
+
const array = transformData.rotation.map(THREE.MathUtils.degToRad);
|
2803
2267
|
array.push(transformData.eulerOrder);
|
2804
2268
|
lRotationM.makeRotationFromEuler(tempEuler.fromArray(array));
|
2805
2269
|
}
|
2806
|
-
|
2807
2270
|
if (transformData.postRotation) {
|
2808
|
-
const array = transformData.postRotation.map(MathUtils.degToRad);
|
2271
|
+
const array = transformData.postRotation.map(THREE.MathUtils.degToRad);
|
2809
2272
|
array.push(transformData.eulerOrder);
|
2810
2273
|
lPostRotationM.makeRotationFromEuler(tempEuler.fromArray(array));
|
2811
2274
|
lPostRotationM.invert();
|
2812
2275
|
}
|
2813
|
-
|
2814
|
-
|
2815
|
-
|
2816
|
-
|
2817
|
-
if (transformData.scalingPivot)
|
2818
|
-
|
2819
|
-
if (transformData.
|
2820
|
-
|
2276
|
+
if (transformData.scale)
|
2277
|
+
lScalingM.scale(tempVec.fromArray(transformData.scale));
|
2278
|
+
if (transformData.scalingOffset)
|
2279
|
+
lScalingOffsetM.setPosition(tempVec.fromArray(transformData.scalingOffset));
|
2280
|
+
if (transformData.scalingPivot)
|
2281
|
+
lScalingPivotM.setPosition(tempVec.fromArray(transformData.scalingPivot));
|
2282
|
+
if (transformData.rotationOffset)
|
2283
|
+
lRotationOffsetM.setPosition(tempVec.fromArray(transformData.rotationOffset));
|
2284
|
+
if (transformData.rotationPivot)
|
2285
|
+
lRotationPivotM.setPosition(tempVec.fromArray(transformData.rotationPivot));
|
2821
2286
|
if (transformData.parentMatrixWorld) {
|
2822
2287
|
lParentLX.copy(transformData.parentMatrix);
|
2823
2288
|
lParentGX.copy(transformData.parentMatrixWorld);
|
2824
2289
|
}
|
2825
|
-
|
2826
|
-
const
|
2827
|
-
|
2828
|
-
const
|
2829
|
-
lParentGRM.extractRotation(lParentGX); // Global Shear*Scaling
|
2830
|
-
|
2831
|
-
const lParentTM = new Matrix4();
|
2290
|
+
const lLRM = lPreRotationM.clone().multiply(lRotationM).multiply(lPostRotationM);
|
2291
|
+
const lParentGRM = new THREE.Matrix4();
|
2292
|
+
lParentGRM.extractRotation(lParentGX);
|
2293
|
+
const lParentTM = new THREE.Matrix4();
|
2832
2294
|
lParentTM.copyPosition(lParentGX);
|
2833
2295
|
const lParentGRSM = lParentTM.clone().invert().multiply(lParentGX);
|
2834
2296
|
const lParentGSM = lParentGRM.clone().invert().multiply(lParentGRSM);
|
2835
2297
|
const lLSM = lScalingM;
|
2836
|
-
const lGlobalRS = new Matrix4();
|
2837
|
-
|
2298
|
+
const lGlobalRS = new THREE.Matrix4();
|
2838
2299
|
if (inheritType === 0) {
|
2839
2300
|
lGlobalRS.copy(lParentGRM).multiply(lLRM).multiply(lParentGSM).multiply(lLSM);
|
2840
2301
|
} else if (inheritType === 1) {
|
2841
2302
|
lGlobalRS.copy(lParentGRM).multiply(lParentGSM).multiply(lLRM).multiply(lLSM);
|
2842
2303
|
} else {
|
2843
|
-
const lParentLSM = new Matrix4().scale(new Vector3().setFromMatrixScale(lParentLX));
|
2304
|
+
const lParentLSM = new THREE.Matrix4().scale(new THREE.Vector3().setFromMatrixScale(lParentLX));
|
2844
2305
|
const lParentLSM_inv = lParentLSM.clone().invert();
|
2845
2306
|
const lParentGSM_noLocal = lParentGSM.clone().multiply(lParentLSM_inv);
|
2846
2307
|
lGlobalRS.copy(lParentGRM).multiply(lLRM).multiply(lParentGSM_noLocal).multiply(lLSM);
|
2847
2308
|
}
|
2848
|
-
|
2849
2309
|
const lRotationPivotM_inv = lRotationPivotM.clone().invert();
|
2850
|
-
const lScalingPivotM_inv = lScalingPivotM.clone().invert();
|
2851
|
-
|
2310
|
+
const lScalingPivotM_inv = lScalingPivotM.clone().invert();
|
2852
2311
|
let lTransform = lTranslationM.clone().multiply(lRotationOffsetM).multiply(lRotationPivotM).multiply(lPreRotationM).multiply(lRotationM).multiply(lPostRotationM).multiply(lRotationPivotM_inv).multiply(lScalingOffsetM).multiply(lScalingPivotM).multiply(lScalingM).multiply(lScalingPivotM_inv);
|
2853
|
-
const lLocalTWithAllPivotAndOffsetInfo = new Matrix4().copyPosition(lTransform);
|
2312
|
+
const lLocalTWithAllPivotAndOffsetInfo = new THREE.Matrix4().copyPosition(lTransform);
|
2854
2313
|
const lGlobalTranslation = lParentGX.clone().multiply(lLocalTWithAllPivotAndOffsetInfo);
|
2855
2314
|
lGlobalT.copyPosition(lGlobalTranslation);
|
2856
|
-
lTransform = lGlobalT.clone().multiply(lGlobalRS);
|
2857
|
-
|
2315
|
+
lTransform = lGlobalT.clone().multiply(lGlobalRS);
|
2858
2316
|
lTransform.premultiply(lParentGX.invert());
|
2859
2317
|
return lTransform;
|
2860
|
-
}
|
2861
|
-
// ref: http://help.autodesk.com/view/FBX/2017/ENU/?guid=__cpp_ref_class_fbx_euler_html
|
2862
|
-
|
2863
|
-
|
2318
|
+
}
|
2864
2319
|
function getEulerOrder(order) {
|
2865
2320
|
order = order || 0;
|
2866
|
-
const enums = [
|
2867
|
-
|
2868
|
-
|
2869
|
-
|
2870
|
-
|
2871
|
-
|
2872
|
-
|
2321
|
+
const enums = [
|
2322
|
+
"ZYX",
|
2323
|
+
"YZX",
|
2324
|
+
"XZY",
|
2325
|
+
"ZXY",
|
2326
|
+
"YXZ",
|
2327
|
+
"XYZ"
|
2873
2328
|
];
|
2874
|
-
|
2875
2329
|
if (order === 6) {
|
2876
|
-
console.warn(
|
2330
|
+
console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect.");
|
2877
2331
|
return enums[0];
|
2878
2332
|
}
|
2879
|
-
|
2880
2333
|
return enums[order];
|
2881
|
-
}
|
2882
|
-
// Used internally by the TextParser
|
2883
|
-
|
2884
|
-
|
2334
|
+
}
|
2885
2335
|
function parseNumberArray(value) {
|
2886
|
-
const array = value.split(
|
2336
|
+
const array = value.split(",").map(function(val) {
|
2887
2337
|
return parseFloat(val);
|
2888
2338
|
});
|
2889
2339
|
return array;
|
2890
2340
|
}
|
2891
|
-
|
2892
2341
|
function convertArrayBufferToString(buffer, from, to) {
|
2893
|
-
if (from ===
|
2894
|
-
|
2895
|
-
|
2342
|
+
if (from === void 0)
|
2343
|
+
from = 0;
|
2344
|
+
if (to === void 0)
|
2345
|
+
to = buffer.byteLength;
|
2346
|
+
return THREE.LoaderUtils.decodeText(new Uint8Array(buffer, from, to));
|
2896
2347
|
}
|
2897
|
-
|
2898
2348
|
function append(a, b) {
|
2899
2349
|
for (let i = 0, j = a.length, l = b.length; i < l; i++, j++) {
|
2900
2350
|
a[j] = b[i];
|
2901
2351
|
}
|
2902
2352
|
}
|
2903
|
-
|
2904
2353
|
function slice(a, b, from, to) {
|
2905
2354
|
for (let i = from, j = 0; i < to; i++, j++) {
|
2906
2355
|
a[j] = b[i];
|
2907
2356
|
}
|
2908
|
-
|
2909
2357
|
return a;
|
2910
|
-
}
|
2911
|
-
|
2912
|
-
|
2358
|
+
}
|
2913
2359
|
function inject(a1, index, a2) {
|
2914
2360
|
return a1.slice(0, index).concat(a2).concat(a1.slice(index));
|
2915
2361
|
}
|
2916
|
-
|
2917
|
-
export { FBXLoader };
|
2362
|
+
exports.FBXLoader = FBXLoader;
|