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