@anov/3d 0.0.4-alpha.1 → 0.0.4-alpha13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -144
- package/dist/applicationApi.d.ts +34 -0
- package/dist/{core/cssRenderer.js → applicationApi.js} +53 -21
- package/dist/environment/index.d.ts +27 -0
- package/dist/environment/index.js +84 -0
- package/dist/environment/time/index.d.ts +12 -0
- package/dist/environment/time/index.js +27 -0
- package/dist/environment/weather/type.d.ts +15 -0
- package/dist/environment/weather/type.js +27 -0
- package/dist/hooksManager.d.ts +2 -0
- package/dist/hooksManager.js +15 -0
- package/dist/index.d.ts +15 -3
- package/dist/index.js +38 -5
- package/dist/messageStatus.d.ts +49 -0
- package/dist/messageStatus.js +50 -0
- package/dist/utils/index.d.ts +11 -50
- package/dist/utils/index.js +29 -92
- package/dist/utils/messageFn.d.ts +12 -0
- package/dist/utils/messageFn.js +33 -0
- package/package.json +8 -24
- package/dist/commonEnu.d.ts +0 -5
- package/dist/commonEnu.js +0 -6
- package/dist/core/camera.d.ts +0 -32
- package/dist/core/camera.js +0 -74
- package/dist/core/control/transformControls.d.ts +0 -12
- package/dist/core/control/transformControls.js +0 -72
- package/dist/core/cssRenderer.d.ts +0 -17
- package/dist/core/events.d.ts +0 -16
- package/dist/core/events.js +0 -38
- package/dist/core/global/global.d.ts +0 -27
- package/dist/core/global/global.js +0 -72
- package/dist/core/global/globalControl.d.ts +0 -17
- package/dist/core/global/globalControl.js +0 -62
- package/dist/core/group.d.ts +0 -57
- package/dist/core/group.js +0 -157
- package/dist/core/line.d.ts +0 -13
- package/dist/core/line.js +0 -83
- package/dist/core/mesh.d.ts +0 -59
- package/dist/core/mesh.js +0 -180
- package/dist/core/model.d.ts +0 -30
- package/dist/core/model.js +0 -109
- package/dist/core/scene.d.ts +0 -175
- package/dist/core/scene.js +0 -381
- package/dist/core/use/useScene.d.ts +0 -10
- package/dist/core/use/useScene.js +0 -14
- package/dist/core/use/useframe.d.ts +0 -6
- package/dist/core/use/useframe.js +0 -11
- package/dist/export.d.ts +0 -40
- package/dist/export.js +0 -36
- package/dist/threeCell.d.ts +0 -8
- package/dist/threeCell.js +0 -16
- package/dist/type.d.ts +0 -3
- package/dist/type.js +0 -1
- package/dist/utils/createElement.d.ts +0 -103
- package/dist/utils/createElement.js +0 -145
- package/dist/utils/createLabel.d.ts +0 -2
- package/dist/utils/createLabel.js +0 -4
- package/dist/utils/line.d.ts +0 -0
- package/dist/utils/line.js +0 -0
- package/dist/utils/move.d.ts +0 -48
- package/dist/utils/move.js +0 -149
- package/examples/fonts/LICENSE +0 -13
- package/examples/fonts/README.md +0 -11
- package/examples/fonts/droid/NOTICE +0 -190
- package/examples/fonts/droid/README.txt +0 -18
- package/examples/fonts/droid/droid_sans_bold.typeface.json +0 -1
- package/examples/fonts/droid/droid_sans_mono_regular.typeface.json +0 -1
- package/examples/fonts/droid/droid_sans_regular.typeface.json +0 -1
- package/examples/fonts/droid/droid_serif_bold.typeface.json +0 -1
- package/examples/fonts/droid/droid_serif_regular.typeface.json +0 -1
- package/examples/fonts/gentilis_bold.typeface.json +0 -1
- package/examples/fonts/gentilis_regular.typeface.json +0 -1
- package/examples/fonts/helvetiker_bold.typeface.json +0 -1
- package/examples/fonts/helvetiker_regular.typeface.json +0 -1
- package/examples/fonts/optimer_bold.typeface.json +0 -1
- package/examples/fonts/optimer_regular.typeface.json +0 -1
- package/examples/fonts/ttf/README.md +0 -9
- package/examples/fonts/ttf/kenpixel.ttf +0 -0
- package/examples/jsm/animation/AnimationClipCreator.js +0 -116
- package/examples/jsm/animation/CCDIKSolver.js +0 -482
- package/examples/jsm/animation/MMDAnimationHelper.js +0 -1207
- package/examples/jsm/animation/MMDPhysics.js +0 -1406
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/examples/jsm/capabilities/WebGL.js +0 -91
- package/examples/jsm/capabilities/WebGPU.js +0 -53
- package/examples/jsm/controls/ArcballControls.js +0 -3224
- package/examples/jsm/controls/DragControls.js +0 -220
- package/examples/jsm/controls/FirstPersonControls.js +0 -325
- package/examples/jsm/controls/FlyControls.js +0 -300
- package/examples/jsm/controls/MapControls.js +0 -28
- package/examples/jsm/controls/OrbitControls.js +0 -1388
- package/examples/jsm/controls/PointerLockControls.js +0 -162
- package/examples/jsm/controls/TrackballControls.js +0 -828
- package/examples/jsm/controls/TransformControls.js +0 -1557
- package/examples/jsm/csm/CSM.js +0 -384
- package/examples/jsm/csm/CSMFrustum.js +0 -152
- package/examples/jsm/csm/CSMHelper.js +0 -193
- package/examples/jsm/csm/CSMShader.js +0 -252
- package/examples/jsm/curves/CurveExtras.js +0 -422
- package/examples/jsm/curves/NURBSCurve.js +0 -80
- package/examples/jsm/curves/NURBSSurface.js +0 -52
- package/examples/jsm/curves/NURBSUtils.js +0 -487
- package/examples/jsm/effects/AnaglyphEffect.js +0 -154
- package/examples/jsm/effects/AsciiEffect.js +0 -263
- package/examples/jsm/effects/OutlineEffect.js +0 -539
- package/examples/jsm/effects/ParallaxBarrierEffect.js +0 -119
- package/examples/jsm/effects/PeppersGhostEffect.js +0 -153
- package/examples/jsm/effects/StereoEffect.js +0 -55
- package/examples/jsm/environments/DebugEnvironment.js +0 -52
- package/examples/jsm/environments/RoomEnvironment.js +0 -148
- package/examples/jsm/exporters/DRACOExporter.js +0 -267
- package/examples/jsm/exporters/EXRExporter.js +0 -501
- package/examples/jsm/exporters/GLTFExporter.js +0 -3161
- package/examples/jsm/exporters/KTX2Exporter.js +0 -292
- package/examples/jsm/exporters/MMDExporter.js +0 -217
- package/examples/jsm/exporters/OBJExporter.js +0 -284
- package/examples/jsm/exporters/PLYExporter.js +0 -528
- package/examples/jsm/exporters/STLExporter.js +0 -199
- package/examples/jsm/exporters/USDZExporter.js +0 -711
- package/examples/jsm/geometries/BoxLineGeometry.js +0 -69
- package/examples/jsm/geometries/ConvexGeometry.js +0 -53
- package/examples/jsm/geometries/DecalGeometry.js +0 -356
- package/examples/jsm/geometries/ParametricGeometries.js +0 -254
- package/examples/jsm/geometries/ParametricGeometry.js +0 -139
- package/examples/jsm/geometries/RoundedBoxGeometry.js +0 -155
- package/examples/jsm/geometries/TeapotGeometry.js +0 -704
- package/examples/jsm/geometries/TextGeometry.js +0 -57
- package/examples/jsm/helpers/LightProbeHelper.js +0 -130
- package/examples/jsm/helpers/OctreeHelper.js +0 -73
- package/examples/jsm/helpers/PositionalAudioHelper.js +0 -109
- package/examples/jsm/helpers/RectAreaLightHelper.js +0 -85
- package/examples/jsm/helpers/VertexNormalsHelper.js +0 -96
- package/examples/jsm/helpers/VertexTangentsHelper.js +0 -88
- package/examples/jsm/helpers/ViewHelper.js +0 -333
- package/examples/jsm/interactive/HTMLMesh.js +0 -565
- package/examples/jsm/interactive/InteractiveGroup.js +0 -116
- package/examples/jsm/interactive/SelectionBox.js +0 -227
- package/examples/jsm/interactive/SelectionHelper.js +0 -104
- package/examples/jsm/libs/ammo.wasm.js +0 -822
- package/examples/jsm/libs/ammo.wasm.wasm +0 -0
- package/examples/jsm/libs/basis/README.md +0 -46
- package/examples/jsm/libs/basis/basis_transcoder.js +0 -21
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/chevrotain.module.min.js +0 -141
- package/examples/jsm/libs/draco/README.md +0 -32
- package/examples/jsm/libs/draco/draco_decoder.js +0 -34
- package/examples/jsm/libs/draco/draco_decoder.wasm +0 -0
- package/examples/jsm/libs/draco/draco_encoder.js +0 -33
- package/examples/jsm/libs/draco/draco_wasm_wrapper.js +0 -117
- package/examples/jsm/libs/draco/gltf/draco_decoder.js +0 -33
- package/examples/jsm/libs/draco/gltf/draco_decoder.wasm +0 -0
- package/examples/jsm/libs/draco/gltf/draco_encoder.js +0 -33
- package/examples/jsm/libs/draco/gltf/draco_wasm_wrapper.js +0 -116
- package/examples/jsm/libs/ecsy.module.js +0 -1792
- package/examples/jsm/libs/fflate.module.js +0 -2474
- package/examples/jsm/libs/ktx-parse.module.js +0 -1
- package/examples/jsm/libs/lil-gui.module.min.js +0 -8
- package/examples/jsm/libs/lottie_canvas.module.js +0 -14844
- package/examples/jsm/libs/meshopt_decoder.module.js +0 -178
- package/examples/jsm/libs/mikktspace.module.js +0 -128
- package/examples/jsm/libs/mmdparser.module.js +0 -11530
- package/examples/jsm/libs/motion-controllers.module.js +0 -397
- package/examples/jsm/libs/opentype.module.js +0 -14568
- package/examples/jsm/libs/potpack.module.js +0 -125
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +0 -21
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +0 -16
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/libs/stats.module.js +0 -167
- package/examples/jsm/libs/tween.module.js +0 -803
- package/examples/jsm/libs/utif.module.js +0 -1579
- package/examples/jsm/libs/zstddec.module.js +0 -1
- package/examples/jsm/lights/IESSpotLight.js +0 -25
- package/examples/jsm/lights/LightProbeGenerator.js +0 -252
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +0 -79
- package/examples/jsm/lines/Line2.js +0 -19
- package/examples/jsm/lines/LineGeometry.js +0 -79
- package/examples/jsm/lines/LineMaterial.js +0 -702
- package/examples/jsm/lines/LineSegments2.js +0 -361
- package/examples/jsm/lines/LineSegmentsGeometry.js +0 -241
- package/examples/jsm/lines/Wireframe.js +0 -56
- package/examples/jsm/lines/WireframeGeometry2.js +0 -24
- package/examples/jsm/loaders/3DMLoader.js +0 -1497
- package/examples/jsm/loaders/3MFLoader.js +0 -1478
- package/examples/jsm/loaders/AMFLoader.js +0 -521
- package/examples/jsm/loaders/BVHLoader.js +0 -437
- package/examples/jsm/loaders/ColladaLoader.js +0 -4122
- package/examples/jsm/loaders/DDSLoader.js +0 -274
- package/examples/jsm/loaders/DRACOLoader.js +0 -612
- package/examples/jsm/loaders/EXRLoader.js +0 -2309
- package/examples/jsm/loaders/FBXLoader.js +0 -4142
- package/examples/jsm/loaders/FontLoader.js +0 -183
- package/examples/jsm/loaders/GCodeLoader.js +0 -261
- package/examples/jsm/loaders/GLTFLoader.js +0 -4576
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +0 -115
- package/examples/jsm/loaders/IESLoader.js +0 -337
- package/examples/jsm/loaders/KMZLoader.js +0 -130
- package/examples/jsm/loaders/KTX2Loader.js +0 -868
- package/examples/jsm/loaders/KTXLoader.js +0 -176
- package/examples/jsm/loaders/LDrawLoader.js +0 -2464
- package/examples/jsm/loaders/LUT3dlLoader.js +0 -151
- package/examples/jsm/loaders/LUTCubeLoader.js +0 -153
- package/examples/jsm/loaders/LWOLoader.js +0 -1052
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/examples/jsm/loaders/LottieLoader.js +0 -77
- package/examples/jsm/loaders/MD2Loader.js +0 -399
- package/examples/jsm/loaders/MDDLoader.js +0 -102
- package/examples/jsm/loaders/MMDLoader.js +0 -2273
- package/examples/jsm/loaders/MTLLoader.js +0 -567
- package/examples/jsm/loaders/MaterialXLoader.js +0 -734
- package/examples/jsm/loaders/NRRDLoader.js +0 -699
- package/examples/jsm/loaders/OBJLoader.js +0 -905
- package/examples/jsm/loaders/PCDLoader.js +0 -467
- package/examples/jsm/loaders/PDBLoader.js +0 -232
- package/examples/jsm/loaders/PLYLoader.js +0 -771
- package/examples/jsm/loaders/PVRLoader.js +0 -251
- package/examples/jsm/loaders/RGBELoader.js +0 -468
- package/examples/jsm/loaders/RGBMLoader.js +0 -1065
- package/examples/jsm/loaders/STLLoader.js +0 -403
- package/examples/jsm/loaders/SVGLoader.js +0 -3172
- package/examples/jsm/loaders/TDSLoader.js +0 -1124
- package/examples/jsm/loaders/TGALoader.js +0 -517
- package/examples/jsm/loaders/TIFFLoader.js +0 -36
- package/examples/jsm/loaders/TTFLoader.js +0 -214
- package/examples/jsm/loaders/TiltLoader.js +0 -520
- package/examples/jsm/loaders/USDZLoader.js +0 -633
- package/examples/jsm/loaders/VOXLoader.js +0 -311
- package/examples/jsm/loaders/VRMLLoader.js +0 -3533
- package/examples/jsm/loaders/VTKLoader.js +0 -1163
- package/examples/jsm/loaders/XYZLoader.js +0 -106
- package/examples/jsm/loaders/lwo/IFFParser.js +0 -1218
- package/examples/jsm/loaders/lwo/LWO2Parser.js +0 -414
- package/examples/jsm/loaders/lwo/LWO3Parser.js +0 -373
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -420
- package/examples/jsm/math/Capsule.js +0 -137
- package/examples/jsm/math/ColorConverter.js +0 -36
- package/examples/jsm/math/ConvexHull.js +0 -1271
- package/examples/jsm/math/ImprovedNoise.js +0 -71
- package/examples/jsm/math/Lut.js +0 -204
- package/examples/jsm/math/MeshSurfaceSampler.js +0 -250
- package/examples/jsm/math/OBB.js +0 -423
- package/examples/jsm/math/Octree.js +0 -462
- package/examples/jsm/math/SimplexNoise.js +0 -444
- package/examples/jsm/misc/ConvexObjectBreaker.js +0 -519
- package/examples/jsm/misc/GPUComputationRenderer.js +0 -446
- package/examples/jsm/misc/Gyroscope.js +0 -66
- package/examples/jsm/misc/MD2Character.js +0 -276
- package/examples/jsm/misc/MD2CharacterComplex.js +0 -576
- package/examples/jsm/misc/MorphAnimMesh.js +0 -75
- package/examples/jsm/misc/MorphBlendMesh.js +0 -322
- package/examples/jsm/misc/ProgressiveLightMap.js +0 -323
- package/examples/jsm/misc/RollerCoaster.js +0 -566
- package/examples/jsm/misc/TubePainter.js +0 -205
- package/examples/jsm/misc/Volume.js +0 -473
- package/examples/jsm/misc/VolumeSlice.js +0 -229
- package/examples/jsm/modifiers/CurveModifier.js +0 -326
- package/examples/jsm/modifiers/EdgeSplitModifier.js +0 -279
- package/examples/jsm/modifiers/SimplifyModifier.js +0 -525
- package/examples/jsm/modifiers/TessellateModifier.js +0 -307
- package/examples/jsm/nodes/Nodes.js +0 -171
- package/examples/jsm/nodes/accessors/BitangentNode.js +0 -89
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +0 -99
- package/examples/jsm/nodes/accessors/BufferNode.js +0 -30
- package/examples/jsm/nodes/accessors/CameraNode.js +0 -98
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +0 -103
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +0 -77
- package/examples/jsm/nodes/accessors/InstanceNode.js +0 -71
- package/examples/jsm/nodes/accessors/MaterialNode.js +0 -267
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +0 -39
- package/examples/jsm/nodes/accessors/ModelNode.js +0 -34
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +0 -29
- package/examples/jsm/nodes/accessors/MorphNode.js +0 -70
- package/examples/jsm/nodes/accessors/NormalNode.js +0 -96
- package/examples/jsm/nodes/accessors/Object3DNode.js +0 -150
- package/examples/jsm/nodes/accessors/PointUVNode.js +0 -26
- package/examples/jsm/nodes/accessors/PositionNode.js +0 -104
- package/examples/jsm/nodes/accessors/ReferenceNode.js +0 -72
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +0 -35
- package/examples/jsm/nodes/accessors/SceneNode.js +0 -52
- package/examples/jsm/nodes/accessors/SkinningNode.js +0 -93
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +0 -27
- package/examples/jsm/nodes/accessors/TangentNode.js +0 -103
- package/examples/jsm/nodes/accessors/TextureBicubicNode.js +0 -94
- package/examples/jsm/nodes/accessors/TextureNode.js +0 -271
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +0 -35
- package/examples/jsm/nodes/accessors/UVNode.js +0 -47
- package/examples/jsm/nodes/accessors/UserDataNode.js +0 -29
- package/examples/jsm/nodes/code/CodeNode.js +0 -78
- package/examples/jsm/nodes/code/ExpressionNode.js +0 -37
- package/examples/jsm/nodes/code/FunctionCallNode.js +0 -96
- package/examples/jsm/nodes/code/FunctionNode.js +0 -127
- package/examples/jsm/nodes/code/ScriptableNode.js +0 -488
- package/examples/jsm/nodes/code/ScriptableValueNode.js +0 -167
- package/examples/jsm/nodes/core/ArrayUniformNode.js +0 -26
- package/examples/jsm/nodes/core/AttributeNode.js +0 -102
- package/examples/jsm/nodes/core/BypassNode.js +0 -45
- package/examples/jsm/nodes/core/CacheNode.js +0 -46
- package/examples/jsm/nodes/core/ConstNode.js +0 -32
- package/examples/jsm/nodes/core/ContextNode.js +0 -61
- package/examples/jsm/nodes/core/IndexNode.js +0 -66
- package/examples/jsm/nodes/core/InputNode.js +0 -83
- package/examples/jsm/nodes/core/LightingModel.js +0 -15
- package/examples/jsm/nodes/core/Node.js +0 -454
- package/examples/jsm/nodes/core/NodeAttribute.js +0 -15
- package/examples/jsm/nodes/core/NodeBuilder.js +0 -1016
- package/examples/jsm/nodes/core/NodeCache.js +0 -26
- package/examples/jsm/nodes/core/NodeCode.js +0 -15
- package/examples/jsm/nodes/core/NodeFrame.js +0 -110
- package/examples/jsm/nodes/core/NodeFunction.js +0 -22
- package/examples/jsm/nodes/core/NodeFunctionInput.js +0 -17
- package/examples/jsm/nodes/core/NodeKeywords.js +0 -80
- package/examples/jsm/nodes/core/NodeParser.js +0 -11
- package/examples/jsm/nodes/core/NodeUniform.js +0 -28
- package/examples/jsm/nodes/core/NodeUtils.js +0 -212
- package/examples/jsm/nodes/core/NodeVar.js +0 -14
- package/examples/jsm/nodes/core/NodeVarying.js +0 -17
- package/examples/jsm/nodes/core/PropertyNode.js +0 -61
- package/examples/jsm/nodes/core/StackNode.js +0 -99
- package/examples/jsm/nodes/core/TempNode.js +0 -58
- package/examples/jsm/nodes/core/UniformNode.js +0 -61
- package/examples/jsm/nodes/core/VarNode.js +0 -87
- package/examples/jsm/nodes/core/VaryingNode.js +0 -69
- package/examples/jsm/nodes/core/constants.js +0 -27
- package/examples/jsm/nodes/display/BlendModeNode.js +0 -99
- package/examples/jsm/nodes/display/BumpMapNode.js +0 -77
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +0 -100
- package/examples/jsm/nodes/display/ColorSpaceNode.js +0 -108
- package/examples/jsm/nodes/display/FrontFacingNode.js +0 -27
- package/examples/jsm/nodes/display/NormalMapNode.js +0 -106
- package/examples/jsm/nodes/display/PosterizeNode.js +0 -32
- package/examples/jsm/nodes/display/ToneMappingNode.js +0 -141
- package/examples/jsm/nodes/display/ViewportDepthNode.js +0 -69
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +0 -34
- package/examples/jsm/nodes/display/ViewportNode.js +0 -115
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +0 -31
- package/examples/jsm/nodes/display/ViewportTextureNode.js +0 -75
- package/examples/jsm/nodes/fog/FogExp2Node.js +0 -35
- package/examples/jsm/nodes/fog/FogNode.js +0 -37
- package/examples/jsm/nodes/fog/FogRangeNode.js +0 -34
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +0 -40
- package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +0 -9
- package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +0 -43
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +0 -29
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +0 -18
- package/examples/jsm/nodes/functions/BSDF/EnvironmentBRDF.js +0 -13
- package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +0 -16
- package/examples/jsm/nodes/functions/BSDF/Schlick_to_F0.js +0 -13
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +0 -20
- package/examples/jsm/nodes/functions/PhongLightingModel.js +0 -67
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +0 -343
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +0 -13
- package/examples/jsm/nodes/functions/material/getRoughness.js +0 -18
- package/examples/jsm/nodes/geometry/RangeNode.js +0 -104
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +0 -85
- package/examples/jsm/nodes/lighting/AONode.js +0 -27
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +0 -27
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +0 -184
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +0 -40
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +0 -191
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +0 -55
- package/examples/jsm/nodes/lighting/IESSpotLightNode.js +0 -39
- package/examples/jsm/nodes/lighting/LightNode.js +0 -57
- package/examples/jsm/nodes/lighting/LightUtils.js +0 -17
- package/examples/jsm/nodes/lighting/LightingContextNode.js +0 -102
- package/examples/jsm/nodes/lighting/LightingNode.js +0 -21
- package/examples/jsm/nodes/lighting/LightsNode.js +0 -128
- package/examples/jsm/nodes/lighting/PointLightNode.js +0 -68
- package/examples/jsm/nodes/lighting/SpotLightNode.js +0 -89
- package/examples/jsm/nodes/loaders/NodeLoader.js +0 -108
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +0 -59
- package/examples/jsm/nodes/loaders/NodeObjectLoader.js +0 -70
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +0 -28
- package/examples/jsm/nodes/materials/Materials.js +0 -12
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -27
- package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +0 -34
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -40
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +0 -65
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +0 -128
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +0 -80
- package/examples/jsm/nodes/materials/NodeMaterial.js +0 -536
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +0 -49
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -103
- package/examples/jsm/nodes/materialx/DISCLAIMER.md +0 -199
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +0 -68
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +0 -56
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +0 -618
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +0 -19
- package/examples/jsm/nodes/math/CondNode.js +0 -86
- package/examples/jsm/nodes/math/MathNode.js +0 -359
- package/examples/jsm/nodes/math/OperatorNode.js +0 -269
- package/examples/jsm/nodes/parsers/GLSLNodeFunction.js +0 -152
- package/examples/jsm/nodes/parsers/GLSLNodeParser.js +0 -14
- package/examples/jsm/nodes/procedural/CheckerNode.js +0 -42
- package/examples/jsm/nodes/shadernode/ShaderNode.js +0 -420
- package/examples/jsm/nodes/utils/ArrayElementNode.js +0 -33
- package/examples/jsm/nodes/utils/ConvertNode.js +0 -65
- package/examples/jsm/nodes/utils/DiscardNode.js +0 -26
- package/examples/jsm/nodes/utils/EquirectUVNode.js +0 -33
- package/examples/jsm/nodes/utils/JoinNode.js +0 -51
- package/examples/jsm/nodes/utils/LoopNode.js +0 -186
- package/examples/jsm/nodes/utils/MatcapUVNode.js +0 -30
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +0 -46
- package/examples/jsm/nodes/utils/OscNode.js +0 -81
- package/examples/jsm/nodes/utils/PackingNode.js +0 -55
- package/examples/jsm/nodes/utils/RemapNode.js +0 -42
- package/examples/jsm/nodes/utils/RotateUVNode.js +0 -43
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
- package/examples/jsm/nodes/utils/SplitNode.js +0 -104
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +0 -41
- package/examples/jsm/nodes/utils/TimerNode.js +0 -94
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +0 -62
- package/examples/jsm/objects/GroundProjectedSkybox.js +0 -172
- package/examples/jsm/objects/Lensflare.js +0 -377
- package/examples/jsm/objects/MarchingCubes.js +0 -1176
- package/examples/jsm/objects/Reflector.js +0 -264
- package/examples/jsm/objects/ReflectorForSSRPass.js +0 -349
- package/examples/jsm/objects/Refractor.js +0 -324
- package/examples/jsm/objects/ShadowMesh.js +0 -80
- package/examples/jsm/objects/Sky.js +0 -219
- package/examples/jsm/objects/Water.js +0 -330
- package/examples/jsm/objects/Water2.js +0 -358
- package/examples/jsm/offscreen/jank.js +0 -45
- package/examples/jsm/offscreen/offscreen.js +0 -8
- package/examples/jsm/offscreen/scene.js +0 -86
- package/examples/jsm/physics/AmmoPhysics.js +0 -285
- package/examples/jsm/physics/RapierPhysics.js +0 -199
- package/examples/jsm/postprocessing/AfterimagePass.js +0 -104
- package/examples/jsm/postprocessing/BloomPass.js +0 -172
- package/examples/jsm/postprocessing/BokehPass.js +0 -140
- package/examples/jsm/postprocessing/ClearPass.js +0 -46
- package/examples/jsm/postprocessing/CubeTexturePass.js +0 -85
- package/examples/jsm/postprocessing/DotScreenPass.js +0 -65
- package/examples/jsm/postprocessing/EffectComposer.js +0 -231
- package/examples/jsm/postprocessing/FilmPass.js +0 -66
- package/examples/jsm/postprocessing/GlitchPass.js +0 -128
- package/examples/jsm/postprocessing/HalftonePass.js +0 -79
- package/examples/jsm/postprocessing/LUTPass.js +0 -173
- package/examples/jsm/postprocessing/MaskPass.js +0 -104
- package/examples/jsm/postprocessing/OutlinePass.js +0 -654
- package/examples/jsm/postprocessing/OutputPass.js +0 -91
- package/examples/jsm/postprocessing/Pass.js +0 -84
- package/examples/jsm/postprocessing/RenderPass.js +0 -81
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +0 -235
- package/examples/jsm/postprocessing/SAOPass.js +0 -411
- package/examples/jsm/postprocessing/SMAAPass.js +0 -201
- package/examples/jsm/postprocessing/SSAARenderPass.js +0 -228
- package/examples/jsm/postprocessing/SSAOPass.js +0 -440
- package/examples/jsm/postprocessing/SSRPass.js +0 -641
- package/examples/jsm/postprocessing/SavePass.js +0 -79
- package/examples/jsm/postprocessing/ShaderPass.js +0 -77
- package/examples/jsm/postprocessing/TAARenderPass.js +0 -189
- package/examples/jsm/postprocessing/TexturePass.js +0 -67
- package/examples/jsm/postprocessing/UnrealBloomPass.js +0 -415
- package/examples/jsm/renderers/CSS2DRenderer.js +0 -215
- package/examples/jsm/renderers/CSS3DRenderer.js +0 -335
- package/examples/jsm/renderers/Projector.js +0 -918
- package/examples/jsm/renderers/SVGRenderer.js +0 -553
- package/examples/jsm/renderers/common/Animation.js +0 -58
- package/examples/jsm/renderers/common/Attributes.js +0 -75
- package/examples/jsm/renderers/common/Backend.js +0 -162
- package/examples/jsm/renderers/common/Background.js +0 -136
- package/examples/jsm/renderers/common/Binding.js +0 -19
- package/examples/jsm/renderers/common/Bindings.js +0 -165
- package/examples/jsm/renderers/common/Buffer.js +0 -38
- package/examples/jsm/renderers/common/BufferUtils.js +0 -33
- package/examples/jsm/renderers/common/ChainMap.js +0 -89
- package/examples/jsm/renderers/common/ComputePipeline.js +0 -17
- package/examples/jsm/renderers/common/Constants.js +0 -14
- package/examples/jsm/renderers/common/CubeRenderTarget.js +0 -65
- package/examples/jsm/renderers/common/DataMap.js +0 -54
- package/examples/jsm/renderers/common/Geometries.js +0 -215
- package/examples/jsm/renderers/common/Info.js +0 -73
- package/examples/jsm/renderers/common/Pipeline.js +0 -13
- package/examples/jsm/renderers/common/Pipelines.js +0 -370
- package/examples/jsm/renderers/common/ProgrammableStage.js +0 -18
- package/examples/jsm/renderers/common/RenderContext.js +0 -38
- package/examples/jsm/renderers/common/RenderContexts.js +0 -49
- package/examples/jsm/renderers/common/RenderList.js +0 -178
- package/examples/jsm/renderers/common/RenderLists.js +0 -38
- package/examples/jsm/renderers/common/RenderObject.js +0 -129
- package/examples/jsm/renderers/common/RenderObjects.js +0 -95
- package/examples/jsm/renderers/common/RenderPipeline.js +0 -16
- package/examples/jsm/renderers/common/Renderer.js +0 -895
- package/examples/jsm/renderers/common/SampledTexture.js +0 -80
- package/examples/jsm/renderers/common/Sampler.js +0 -18
- package/examples/jsm/renderers/common/StorageBuffer.js +0 -17
- package/examples/jsm/renderers/common/Textures.js +0 -218
- package/examples/jsm/renderers/common/Uniform.js +0 -140
- package/examples/jsm/renderers/common/UniformBuffer.js +0 -15
- package/examples/jsm/renderers/common/UniformsGroup.js +0 -299
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +0 -39
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +0 -21
- package/examples/jsm/renderers/common/nodes/NodeUniform.js +0 -135
- package/examples/jsm/renderers/common/nodes/Nodes.js +0 -330
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +0 -340
- package/examples/jsm/renderers/webgl/nodes/SlotNode.js +0 -26
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +0 -764
- package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +0 -49
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +0 -844
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +0 -32
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +0 -902
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +0 -104
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeParser.js +0 -14
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +0 -274
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +0 -223
- package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +0 -324
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +0 -533
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureMipmapUtils.js +0 -163
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +0 -964
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +0 -92
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +0 -87
- package/examples/jsm/shaders/AfterimageShader.js +0 -56
- package/examples/jsm/shaders/BasicShader.js +0 -27
- package/examples/jsm/shaders/BleachBypassShader.js +0 -62
- package/examples/jsm/shaders/BlendShader.js +0 -47
- package/examples/jsm/shaders/BokehShader.js +0 -143
- package/examples/jsm/shaders/BokehShader2.js +0 -393
- package/examples/jsm/shaders/BrightnessContrastShader.js +0 -54
- package/examples/jsm/shaders/ColorCorrectionShader.js +0 -50
- package/examples/jsm/shaders/ColorifyShader.js +0 -51
- package/examples/jsm/shaders/ConvolutionShader.js +0 -103
- package/examples/jsm/shaders/CopyShader.js +0 -45
- package/examples/jsm/shaders/DOFMipMapShader.js +0 -54
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +0 -166
- package/examples/jsm/shaders/DigitalGlitch.js +0 -101
- package/examples/jsm/shaders/DotScreenShader.js +0 -70
- package/examples/jsm/shaders/ExposureShader.js +0 -44
- package/examples/jsm/shaders/FXAAShader.js +0 -286
- package/examples/jsm/shaders/FilmShader.js +0 -102
- package/examples/jsm/shaders/FocusShader.js +0 -87
- package/examples/jsm/shaders/FreiChenShader.js +0 -94
- package/examples/jsm/shaders/GammaCorrectionShader.js +0 -43
- package/examples/jsm/shaders/GodRaysShader.js +0 -313
- package/examples/jsm/shaders/HalftoneShader.js +0 -310
- package/examples/jsm/shaders/HorizontalBlurShader.js +0 -59
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +0 -61
- package/examples/jsm/shaders/HueSaturationShader.js +0 -65
- package/examples/jsm/shaders/KaleidoShader.js +0 -56
- package/examples/jsm/shaders/LuminosityHighPassShader.js +0 -64
- package/examples/jsm/shaders/LuminosityShader.js +0 -46
- package/examples/jsm/shaders/MMDToonShader.js +0 -132
- package/examples/jsm/shaders/MirrorShader.js +0 -54
- package/examples/jsm/shaders/NormalMapShader.js +0 -53
- package/examples/jsm/shaders/OutputShader.js +0 -78
- package/examples/jsm/shaders/RGBShiftShader.js +0 -54
- package/examples/jsm/shaders/SAOShader.js +0 -188
- package/examples/jsm/shaders/SMAAShader.js +0 -460
- package/examples/jsm/shaders/SSAOShader.js +0 -288
- package/examples/jsm/shaders/SSRShader.js +0 -364
- package/examples/jsm/shaders/SepiaShader.js +0 -52
- package/examples/jsm/shaders/SobelOperatorShader.js +0 -90
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +0 -88
- package/examples/jsm/shaders/TechnicolorShader.js +0 -43
- package/examples/jsm/shaders/ToonShader.js +0 -326
- package/examples/jsm/shaders/TriangleBlurShader.js +0 -72
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +0 -45
- package/examples/jsm/shaders/VelocityShader.js +0 -128
- package/examples/jsm/shaders/VerticalBlurShader.js +0 -59
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +0 -61
- package/examples/jsm/shaders/VignetteShader.js +0 -51
- package/examples/jsm/shaders/VolumeShader.js +0 -289
- package/examples/jsm/shaders/WaterRefractionShader.js +0 -93
- package/examples/jsm/textures/FlakesTexture.js +0 -40
- package/examples/jsm/utils/BufferGeometryUtils.js +0 -1373
- package/examples/jsm/utils/CameraUtils.js +0 -73
- package/examples/jsm/utils/GPUStatsPanel.js +0 -128
- package/examples/jsm/utils/GeometryCompressionUtils.js +0 -639
- package/examples/jsm/utils/GeometryUtils.js +0 -221
- package/examples/jsm/utils/LDrawUtils.js +0 -202
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/examples/jsm/utils/SceneUtils.js +0 -254
- package/examples/jsm/utils/ShadowMapViewer.js +0 -210
- package/examples/jsm/utils/SkeletonUtils.js +0 -413
- package/examples/jsm/utils/TextureUtils.js +0 -86
- package/examples/jsm/utils/UVsDebug.js +0 -165
- package/examples/jsm/utils/WorkerPool.js +0 -102
- package/examples/jsm/webxr/ARButton.js +0 -208
- package/examples/jsm/webxr/OculusHandModel.js +0 -109
- package/examples/jsm/webxr/OculusHandPointerModel.js +0 -413
- package/examples/jsm/webxr/Text2D.js +0 -38
- package/examples/jsm/webxr/VRButton.js +0 -200
- package/examples/jsm/webxr/XRButton.js +0 -198
- package/examples/jsm/webxr/XRControllerModelFactory.js +0 -299
- package/examples/jsm/webxr/XREstimatedLight.js +0 -223
- package/examples/jsm/webxr/XRHandMeshModel.js +0 -112
- package/examples/jsm/webxr/XRHandModelFactory.js +0 -105
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +0 -103
- package/examples/jsm/webxr/XRPlanes.js +0 -100
- package/lib/3d.min.js +0 -1
|
@@ -1,868 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Loader for KTX 2.0 GPU Texture containers.
|
|
3
|
-
*
|
|
4
|
-
* KTX 2.0 is a container format for various GPU texture formats. The loader
|
|
5
|
-
* supports Basis Universal GPU textures, which can be quickly transcoded to
|
|
6
|
-
* a wide variety of GPU texture compression formats, as well as some
|
|
7
|
-
* uncompressed DataTexture and Data3DTexture formats.
|
|
8
|
-
*
|
|
9
|
-
* References:
|
|
10
|
-
* - KTX: http://github.khronos.org/KTX-Specification/
|
|
11
|
-
* - DFD: https://www.khronos.org/registry/DataFormat/specs/1.3/dataformat.1.3.html#basicdescriptor
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
CompressedTexture,
|
|
16
|
-
CompressedArrayTexture,
|
|
17
|
-
CompressedCubeTexture,
|
|
18
|
-
Data3DTexture,
|
|
19
|
-
DataTexture,
|
|
20
|
-
FileLoader,
|
|
21
|
-
FloatType,
|
|
22
|
-
HalfFloatType,
|
|
23
|
-
NoColorSpace,
|
|
24
|
-
LinearFilter,
|
|
25
|
-
LinearMipmapLinearFilter,
|
|
26
|
-
Loader,
|
|
27
|
-
RedFormat,
|
|
28
|
-
RGB_ETC1_Format,
|
|
29
|
-
RGB_ETC2_Format,
|
|
30
|
-
RGB_PVRTC_4BPPV1_Format,
|
|
31
|
-
RGB_S3TC_DXT1_Format,
|
|
32
|
-
RGBA_ASTC_4x4_Format,
|
|
33
|
-
RGBA_BPTC_Format,
|
|
34
|
-
RGBA_ETC2_EAC_Format,
|
|
35
|
-
RGBA_PVRTC_4BPPV1_Format,
|
|
36
|
-
RGBA_S3TC_DXT5_Format,
|
|
37
|
-
RGBAFormat,
|
|
38
|
-
RGFormat,
|
|
39
|
-
SRGBColorSpace,
|
|
40
|
-
UnsignedByteType,
|
|
41
|
-
} from 'three';
|
|
42
|
-
import { WorkerPool } from '../utils/WorkerPool.js';
|
|
43
|
-
import {
|
|
44
|
-
read,
|
|
45
|
-
KHR_DF_FLAG_ALPHA_PREMULTIPLIED,
|
|
46
|
-
KHR_DF_TRANSFER_SRGB,
|
|
47
|
-
KHR_SUPERCOMPRESSION_NONE,
|
|
48
|
-
KHR_SUPERCOMPRESSION_ZSTD,
|
|
49
|
-
VK_FORMAT_UNDEFINED,
|
|
50
|
-
VK_FORMAT_R16_SFLOAT,
|
|
51
|
-
VK_FORMAT_R16G16_SFLOAT,
|
|
52
|
-
VK_FORMAT_R16G16B16A16_SFLOAT,
|
|
53
|
-
VK_FORMAT_R32_SFLOAT,
|
|
54
|
-
VK_FORMAT_R32G32_SFLOAT,
|
|
55
|
-
VK_FORMAT_R32G32B32A32_SFLOAT,
|
|
56
|
-
VK_FORMAT_R8_SRGB,
|
|
57
|
-
VK_FORMAT_R8_UNORM,
|
|
58
|
-
VK_FORMAT_R8G8_SRGB,
|
|
59
|
-
VK_FORMAT_R8G8_UNORM,
|
|
60
|
-
VK_FORMAT_R8G8B8A8_SRGB,
|
|
61
|
-
VK_FORMAT_R8G8B8A8_UNORM,
|
|
62
|
-
} from '../libs/ktx-parse.module.js';
|
|
63
|
-
import { ZSTDDecoder } from '../libs/zstddec.module.js';
|
|
64
|
-
|
|
65
|
-
const _taskCache = new WeakMap();
|
|
66
|
-
|
|
67
|
-
let _activeLoaders = 0;
|
|
68
|
-
|
|
69
|
-
let _zstd;
|
|
70
|
-
|
|
71
|
-
class KTX2Loader extends Loader {
|
|
72
|
-
|
|
73
|
-
constructor( manager ) {
|
|
74
|
-
|
|
75
|
-
super( manager );
|
|
76
|
-
|
|
77
|
-
this.transcoderPath = '';
|
|
78
|
-
this.transcoderBinary = null;
|
|
79
|
-
this.transcoderPending = null;
|
|
80
|
-
|
|
81
|
-
this.workerPool = new WorkerPool();
|
|
82
|
-
this.workerSourceURL = '';
|
|
83
|
-
this.workerConfig = null;
|
|
84
|
-
|
|
85
|
-
if ( typeof MSC_TRANSCODER !== 'undefined' ) {
|
|
86
|
-
|
|
87
|
-
console.warn(
|
|
88
|
-
|
|
89
|
-
'THREE.KTX2Loader: Please update to latest "basis_transcoder".'
|
|
90
|
-
+ ' "msc_basis_transcoder" is no longer supported in three.js r125+.'
|
|
91
|
-
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
setTranscoderPath( path ) {
|
|
99
|
-
|
|
100
|
-
this.transcoderPath = path;
|
|
101
|
-
|
|
102
|
-
return this;
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
setWorkerLimit( num ) {
|
|
107
|
-
|
|
108
|
-
this.workerPool.setWorkerLimit( num );
|
|
109
|
-
|
|
110
|
-
return this;
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
detectSupport( renderer ) {
|
|
115
|
-
|
|
116
|
-
if ( renderer.isWebGPURenderer === true ) {
|
|
117
|
-
|
|
118
|
-
this.workerConfig = {
|
|
119
|
-
astcSupported: renderer.hasFeature( 'texture-compression-astc' ),
|
|
120
|
-
etc1Supported: false,
|
|
121
|
-
etc2Supported: renderer.hasFeature( 'texture-compression-etc2' ),
|
|
122
|
-
dxtSupported: renderer.hasFeature( 'texture-compression-bc' ),
|
|
123
|
-
bptcSupported: false,
|
|
124
|
-
pvrtcSupported: false
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
} else {
|
|
128
|
-
|
|
129
|
-
this.workerConfig = {
|
|
130
|
-
astcSupported: renderer.extensions.has( 'WEBGL_compressed_texture_astc' ),
|
|
131
|
-
etc1Supported: renderer.extensions.has( 'WEBGL_compressed_texture_etc1' ),
|
|
132
|
-
etc2Supported: renderer.extensions.has( 'WEBGL_compressed_texture_etc' ),
|
|
133
|
-
dxtSupported: renderer.extensions.has( 'WEBGL_compressed_texture_s3tc' ),
|
|
134
|
-
bptcSupported: renderer.extensions.has( 'EXT_texture_compression_bptc' ),
|
|
135
|
-
pvrtcSupported: renderer.extensions.has( 'WEBGL_compressed_texture_pvrtc' )
|
|
136
|
-
|| renderer.extensions.has( 'WEBKIT_WEBGL_compressed_texture_pvrtc' )
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
if ( renderer.capabilities.isWebGL2 ) {
|
|
140
|
-
|
|
141
|
-
// https://github.com/mrdoob/three.js/pull/22928
|
|
142
|
-
this.workerConfig.etc1Supported = false;
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return this;
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
init() {
|
|
153
|
-
|
|
154
|
-
if ( ! this.transcoderPending ) {
|
|
155
|
-
|
|
156
|
-
// Load transcoder wrapper.
|
|
157
|
-
const jsLoader = new FileLoader( this.manager );
|
|
158
|
-
jsLoader.setPath( this.transcoderPath );
|
|
159
|
-
jsLoader.setWithCredentials( this.withCredentials );
|
|
160
|
-
const jsContent = jsLoader.loadAsync( 'basis_transcoder.js' );
|
|
161
|
-
|
|
162
|
-
// Load transcoder WASM binary.
|
|
163
|
-
const binaryLoader = new FileLoader( this.manager );
|
|
164
|
-
binaryLoader.setPath( this.transcoderPath );
|
|
165
|
-
binaryLoader.setResponseType( 'arraybuffer' );
|
|
166
|
-
binaryLoader.setWithCredentials( this.withCredentials );
|
|
167
|
-
const binaryContent = binaryLoader.loadAsync( 'basis_transcoder.wasm' );
|
|
168
|
-
|
|
169
|
-
this.transcoderPending = Promise.all( [ jsContent, binaryContent ] )
|
|
170
|
-
.then( ( [ jsContent, binaryContent ] ) => {
|
|
171
|
-
|
|
172
|
-
const fn = KTX2Loader.BasisWorker.toString();
|
|
173
|
-
|
|
174
|
-
const body = [
|
|
175
|
-
'/* constants */',
|
|
176
|
-
'let _EngineFormat = ' + JSON.stringify( KTX2Loader.EngineFormat ),
|
|
177
|
-
'let _TranscoderFormat = ' + JSON.stringify( KTX2Loader.TranscoderFormat ),
|
|
178
|
-
'let _BasisFormat = ' + JSON.stringify( KTX2Loader.BasisFormat ),
|
|
179
|
-
'/* basis_transcoder.js */',
|
|
180
|
-
jsContent,
|
|
181
|
-
'/* worker */',
|
|
182
|
-
fn.substring( fn.indexOf( '{' ) + 1, fn.lastIndexOf( '}' ) )
|
|
183
|
-
].join( '\n' );
|
|
184
|
-
|
|
185
|
-
this.workerSourceURL = URL.createObjectURL( new Blob( [ body ] ) );
|
|
186
|
-
this.transcoderBinary = binaryContent;
|
|
187
|
-
|
|
188
|
-
this.workerPool.setWorkerCreator( () => {
|
|
189
|
-
|
|
190
|
-
const worker = new Worker( this.workerSourceURL );
|
|
191
|
-
const transcoderBinary = this.transcoderBinary.slice( 0 );
|
|
192
|
-
|
|
193
|
-
worker.postMessage( { type: 'init', config: this.workerConfig, transcoderBinary }, [ transcoderBinary ] );
|
|
194
|
-
|
|
195
|
-
return worker;
|
|
196
|
-
|
|
197
|
-
} );
|
|
198
|
-
|
|
199
|
-
} );
|
|
200
|
-
|
|
201
|
-
if ( _activeLoaders > 0 ) {
|
|
202
|
-
|
|
203
|
-
// Each instance loads a transcoder and allocates workers, increasing network and memory cost.
|
|
204
|
-
|
|
205
|
-
console.warn(
|
|
206
|
-
|
|
207
|
-
'THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues.'
|
|
208
|
-
+ ' Use a single KTX2Loader instance, or call .dispose() on old instances.'
|
|
209
|
-
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
_activeLoaders ++;
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
return this.transcoderPending;
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
load( url, onLoad, onProgress, onError ) {
|
|
223
|
-
|
|
224
|
-
if ( this.workerConfig === null ) {
|
|
225
|
-
|
|
226
|
-
throw new Error( 'THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.' );
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
const loader = new FileLoader( this.manager );
|
|
231
|
-
|
|
232
|
-
loader.setResponseType( 'arraybuffer' );
|
|
233
|
-
loader.setWithCredentials( this.withCredentials );
|
|
234
|
-
|
|
235
|
-
loader.load( url, ( buffer ) => {
|
|
236
|
-
|
|
237
|
-
// Check for an existing task using this buffer. A transferred buffer cannot be transferred
|
|
238
|
-
// again from this thread.
|
|
239
|
-
if ( _taskCache.has( buffer ) ) {
|
|
240
|
-
|
|
241
|
-
const cachedTask = _taskCache.get( buffer );
|
|
242
|
-
|
|
243
|
-
return cachedTask.promise.then( onLoad ).catch( onError );
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
this._createTexture( buffer )
|
|
248
|
-
.then( ( texture ) => onLoad ? onLoad( texture ) : null )
|
|
249
|
-
.catch( onError );
|
|
250
|
-
|
|
251
|
-
}, onProgress, onError );
|
|
252
|
-
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
_createTextureFrom( transcodeResult, container ) {
|
|
256
|
-
|
|
257
|
-
const { faces, width, height, format, type, error, dfdTransferFn, dfdFlags } = transcodeResult;
|
|
258
|
-
|
|
259
|
-
if ( type === 'error' ) return Promise.reject( error );
|
|
260
|
-
|
|
261
|
-
let texture;
|
|
262
|
-
|
|
263
|
-
if ( container.faceCount === 6 ) {
|
|
264
|
-
|
|
265
|
-
texture = new CompressedCubeTexture( faces, format, UnsignedByteType );
|
|
266
|
-
|
|
267
|
-
} else {
|
|
268
|
-
|
|
269
|
-
const mipmaps = faces[ 0 ].mipmaps;
|
|
270
|
-
|
|
271
|
-
texture = container.layerCount > 1
|
|
272
|
-
? new CompressedArrayTexture( mipmaps, width, height, container.layerCount, format, UnsignedByteType )
|
|
273
|
-
: new CompressedTexture( mipmaps, width, height, format, UnsignedByteType );
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
texture.minFilter = faces[ 0 ].mipmaps.length === 1 ? LinearFilter : LinearMipmapLinearFilter;
|
|
278
|
-
texture.magFilter = LinearFilter;
|
|
279
|
-
texture.generateMipmaps = false;
|
|
280
|
-
|
|
281
|
-
texture.needsUpdate = true;
|
|
282
|
-
// TODO: Detect NoColorSpace vs. LinearSRGBColorSpace based on primaries.
|
|
283
|
-
texture.colorSpace = dfdTransferFn === KHR_DF_TRANSFER_SRGB ? SRGBColorSpace : NoColorSpace;
|
|
284
|
-
texture.premultiplyAlpha = !! ( dfdFlags & KHR_DF_FLAG_ALPHA_PREMULTIPLIED );
|
|
285
|
-
|
|
286
|
-
return texture;
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* @param {ArrayBuffer} buffer
|
|
292
|
-
* @param {object?} config
|
|
293
|
-
* @return {Promise<CompressedTexture|CompressedArrayTexture|DataTexture|Data3DTexture>}
|
|
294
|
-
*/
|
|
295
|
-
async _createTexture( buffer, config = {} ) {
|
|
296
|
-
|
|
297
|
-
const container = read( new Uint8Array( buffer ) );
|
|
298
|
-
|
|
299
|
-
if ( container.vkFormat !== VK_FORMAT_UNDEFINED ) {
|
|
300
|
-
|
|
301
|
-
const mipmaps = [];
|
|
302
|
-
const pendings = [];
|
|
303
|
-
|
|
304
|
-
for ( let levelIndex = 0; levelIndex < container.levels.length; levelIndex ++ ) {
|
|
305
|
-
|
|
306
|
-
pendings.push( createDataTexture( container, levelIndex ).then( function ( dataTexture ) {
|
|
307
|
-
|
|
308
|
-
mipmaps[ levelIndex ] = dataTexture;
|
|
309
|
-
|
|
310
|
-
} ) );
|
|
311
|
-
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
await Promise.all( pendings );
|
|
315
|
-
|
|
316
|
-
const texture = mipmaps[ 0 ];
|
|
317
|
-
texture.mipmaps = mipmaps.map( dt => {
|
|
318
|
-
|
|
319
|
-
return {
|
|
320
|
-
data: dt.source.data,
|
|
321
|
-
width: dt.source.data.width,
|
|
322
|
-
height: dt.source.data.height,
|
|
323
|
-
depth: dt.source.data.depth
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
} );
|
|
327
|
-
return texture;
|
|
328
|
-
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
//
|
|
332
|
-
const taskConfig = config;
|
|
333
|
-
const texturePending = this.init().then( () => {
|
|
334
|
-
|
|
335
|
-
return this.workerPool.postMessage( { type: 'transcode', buffer, taskConfig: taskConfig }, [ buffer ] );
|
|
336
|
-
|
|
337
|
-
} ).then( ( e ) => this._createTextureFrom( e.data, container ) );
|
|
338
|
-
|
|
339
|
-
// Cache the task result.
|
|
340
|
-
_taskCache.set( buffer, { promise: texturePending } );
|
|
341
|
-
|
|
342
|
-
return texturePending;
|
|
343
|
-
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
dispose() {
|
|
347
|
-
|
|
348
|
-
this.workerPool.dispose();
|
|
349
|
-
if ( this.workerSourceURL ) URL.revokeObjectURL( this.workerSourceURL );
|
|
350
|
-
|
|
351
|
-
_activeLoaders --;
|
|
352
|
-
|
|
353
|
-
return this;
|
|
354
|
-
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
/* CONSTANTS */
|
|
361
|
-
|
|
362
|
-
KTX2Loader.BasisFormat = {
|
|
363
|
-
ETC1S: 0,
|
|
364
|
-
UASTC_4x4: 1,
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
KTX2Loader.TranscoderFormat = {
|
|
368
|
-
ETC1: 0,
|
|
369
|
-
ETC2: 1,
|
|
370
|
-
BC1: 2,
|
|
371
|
-
BC3: 3,
|
|
372
|
-
BC4: 4,
|
|
373
|
-
BC5: 5,
|
|
374
|
-
BC7_M6_OPAQUE_ONLY: 6,
|
|
375
|
-
BC7_M5: 7,
|
|
376
|
-
PVRTC1_4_RGB: 8,
|
|
377
|
-
PVRTC1_4_RGBA: 9,
|
|
378
|
-
ASTC_4x4: 10,
|
|
379
|
-
ATC_RGB: 11,
|
|
380
|
-
ATC_RGBA_INTERPOLATED_ALPHA: 12,
|
|
381
|
-
RGBA32: 13,
|
|
382
|
-
RGB565: 14,
|
|
383
|
-
BGR565: 15,
|
|
384
|
-
RGBA4444: 16,
|
|
385
|
-
};
|
|
386
|
-
|
|
387
|
-
KTX2Loader.EngineFormat = {
|
|
388
|
-
RGBAFormat: RGBAFormat,
|
|
389
|
-
RGBA_ASTC_4x4_Format: RGBA_ASTC_4x4_Format,
|
|
390
|
-
RGBA_BPTC_Format: RGBA_BPTC_Format,
|
|
391
|
-
RGBA_ETC2_EAC_Format: RGBA_ETC2_EAC_Format,
|
|
392
|
-
RGBA_PVRTC_4BPPV1_Format: RGBA_PVRTC_4BPPV1_Format,
|
|
393
|
-
RGBA_S3TC_DXT5_Format: RGBA_S3TC_DXT5_Format,
|
|
394
|
-
RGB_ETC1_Format: RGB_ETC1_Format,
|
|
395
|
-
RGB_ETC2_Format: RGB_ETC2_Format,
|
|
396
|
-
RGB_PVRTC_4BPPV1_Format: RGB_PVRTC_4BPPV1_Format,
|
|
397
|
-
RGB_S3TC_DXT1_Format: RGB_S3TC_DXT1_Format,
|
|
398
|
-
};
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
/* WEB WORKER */
|
|
402
|
-
|
|
403
|
-
KTX2Loader.BasisWorker = function () {
|
|
404
|
-
|
|
405
|
-
let config;
|
|
406
|
-
let transcoderPending;
|
|
407
|
-
let BasisModule;
|
|
408
|
-
|
|
409
|
-
const EngineFormat = _EngineFormat; // eslint-disable-line no-undef
|
|
410
|
-
const TranscoderFormat = _TranscoderFormat; // eslint-disable-line no-undef
|
|
411
|
-
const BasisFormat = _BasisFormat; // eslint-disable-line no-undef
|
|
412
|
-
|
|
413
|
-
self.addEventListener( 'message', function ( e ) {
|
|
414
|
-
|
|
415
|
-
const message = e.data;
|
|
416
|
-
|
|
417
|
-
switch ( message.type ) {
|
|
418
|
-
|
|
419
|
-
case 'init':
|
|
420
|
-
config = message.config;
|
|
421
|
-
init( message.transcoderBinary );
|
|
422
|
-
break;
|
|
423
|
-
|
|
424
|
-
case 'transcode':
|
|
425
|
-
transcoderPending.then( () => {
|
|
426
|
-
|
|
427
|
-
try {
|
|
428
|
-
|
|
429
|
-
const { faces, buffers, width, height, hasAlpha, format, dfdTransferFn, dfdFlags } = transcode( message.buffer );
|
|
430
|
-
|
|
431
|
-
self.postMessage( { type: 'transcode', id: message.id, faces, width, height, hasAlpha, format, dfdTransferFn, dfdFlags }, buffers );
|
|
432
|
-
|
|
433
|
-
} catch ( error ) {
|
|
434
|
-
|
|
435
|
-
console.error( error );
|
|
436
|
-
|
|
437
|
-
self.postMessage( { type: 'error', id: message.id, error: error.message } );
|
|
438
|
-
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
} );
|
|
442
|
-
break;
|
|
443
|
-
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
} );
|
|
447
|
-
|
|
448
|
-
function init( wasmBinary ) {
|
|
449
|
-
|
|
450
|
-
transcoderPending = new Promise( ( resolve ) => {
|
|
451
|
-
|
|
452
|
-
BasisModule = { wasmBinary, onRuntimeInitialized: resolve };
|
|
453
|
-
BASIS( BasisModule ); // eslint-disable-line no-undef
|
|
454
|
-
|
|
455
|
-
} ).then( () => {
|
|
456
|
-
|
|
457
|
-
BasisModule.initializeBasis();
|
|
458
|
-
|
|
459
|
-
if ( BasisModule.KTX2File === undefined ) {
|
|
460
|
-
|
|
461
|
-
console.warn( 'THREE.KTX2Loader: Please update Basis Universal transcoder.' );
|
|
462
|
-
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
} );
|
|
466
|
-
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
function transcode( buffer ) {
|
|
470
|
-
|
|
471
|
-
const ktx2File = new BasisModule.KTX2File( new Uint8Array( buffer ) );
|
|
472
|
-
|
|
473
|
-
function cleanup() {
|
|
474
|
-
|
|
475
|
-
ktx2File.close();
|
|
476
|
-
ktx2File.delete();
|
|
477
|
-
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
if ( ! ktx2File.isValid() ) {
|
|
481
|
-
|
|
482
|
-
cleanup();
|
|
483
|
-
throw new Error( 'THREE.KTX2Loader: Invalid or unsupported .ktx2 file' );
|
|
484
|
-
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
const basisFormat = ktx2File.isUASTC() ? BasisFormat.UASTC_4x4 : BasisFormat.ETC1S;
|
|
488
|
-
const width = ktx2File.getWidth();
|
|
489
|
-
const height = ktx2File.getHeight();
|
|
490
|
-
const layerCount = ktx2File.getLayers() || 1;
|
|
491
|
-
const levelCount = ktx2File.getLevels();
|
|
492
|
-
const faceCount = ktx2File.getFaces();
|
|
493
|
-
const hasAlpha = ktx2File.getHasAlpha();
|
|
494
|
-
const dfdTransferFn = ktx2File.getDFDTransferFunc();
|
|
495
|
-
const dfdFlags = ktx2File.getDFDFlags();
|
|
496
|
-
|
|
497
|
-
const { transcoderFormat, engineFormat } = getTranscoderFormat( basisFormat, width, height, hasAlpha );
|
|
498
|
-
|
|
499
|
-
if ( ! width || ! height || ! levelCount ) {
|
|
500
|
-
|
|
501
|
-
cleanup();
|
|
502
|
-
throw new Error( 'THREE.KTX2Loader: Invalid texture' );
|
|
503
|
-
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
if ( ! ktx2File.startTranscoding() ) {
|
|
507
|
-
|
|
508
|
-
cleanup();
|
|
509
|
-
throw new Error( 'THREE.KTX2Loader: .startTranscoding failed' );
|
|
510
|
-
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
const faces = [];
|
|
514
|
-
const buffers = [];
|
|
515
|
-
|
|
516
|
-
for ( let face = 0; face < faceCount; face ++ ) {
|
|
517
|
-
|
|
518
|
-
const mipmaps = [];
|
|
519
|
-
|
|
520
|
-
for ( let mip = 0; mip < levelCount; mip ++ ) {
|
|
521
|
-
|
|
522
|
-
const layerMips = [];
|
|
523
|
-
|
|
524
|
-
let mipWidth, mipHeight;
|
|
525
|
-
|
|
526
|
-
for ( let layer = 0; layer < layerCount; layer ++ ) {
|
|
527
|
-
|
|
528
|
-
const levelInfo = ktx2File.getImageLevelInfo( mip, layer, face );
|
|
529
|
-
|
|
530
|
-
if ( face === 0 && mip === 0 && layer === 0 && ( levelInfo.origWidth % 4 !== 0 || levelInfo.origHeight % 4 !== 0 ) ) {
|
|
531
|
-
|
|
532
|
-
console.warn( 'THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions.' );
|
|
533
|
-
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
if ( levelCount > 1 ) {
|
|
537
|
-
|
|
538
|
-
mipWidth = levelInfo.origWidth;
|
|
539
|
-
mipHeight = levelInfo.origHeight;
|
|
540
|
-
|
|
541
|
-
} else {
|
|
542
|
-
|
|
543
|
-
// Handles non-multiple-of-four dimensions in textures without mipmaps. Textures with
|
|
544
|
-
// mipmaps must use multiple-of-four dimensions, for some texture formats and APIs.
|
|
545
|
-
// See mrdoob/three.js#25908.
|
|
546
|
-
mipWidth = levelInfo.width;
|
|
547
|
-
mipHeight = levelInfo.height;
|
|
548
|
-
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
const dst = new Uint8Array( ktx2File.getImageTranscodedSizeInBytes( mip, layer, 0, transcoderFormat ) );
|
|
552
|
-
const status = ktx2File.transcodeImage( dst, mip, layer, face, transcoderFormat, 0, - 1, - 1 );
|
|
553
|
-
|
|
554
|
-
if ( ! status ) {
|
|
555
|
-
|
|
556
|
-
cleanup();
|
|
557
|
-
throw new Error( 'THREE.KTX2Loader: .transcodeImage failed.' );
|
|
558
|
-
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
layerMips.push( dst );
|
|
562
|
-
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
const mipData = concat( layerMips );
|
|
566
|
-
|
|
567
|
-
mipmaps.push( { data: mipData, width: mipWidth, height: mipHeight } );
|
|
568
|
-
buffers.push( mipData.buffer );
|
|
569
|
-
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
faces.push( { mipmaps, width, height, format: engineFormat } );
|
|
573
|
-
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
cleanup();
|
|
577
|
-
|
|
578
|
-
return { faces, buffers, width, height, hasAlpha, format: engineFormat, dfdTransferFn, dfdFlags };
|
|
579
|
-
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
//
|
|
583
|
-
|
|
584
|
-
// Optimal choice of a transcoder target format depends on the Basis format (ETC1S or UASTC),
|
|
585
|
-
// device capabilities, and texture dimensions. The list below ranks the formats separately
|
|
586
|
-
// for ETC1S and UASTC.
|
|
587
|
-
//
|
|
588
|
-
// In some cases, transcoding UASTC to RGBA32 might be preferred for higher quality (at
|
|
589
|
-
// significant memory cost) compared to ETC1/2, BC1/3, and PVRTC. The transcoder currently
|
|
590
|
-
// chooses RGBA32 only as a last resort and does not expose that option to the caller.
|
|
591
|
-
const FORMAT_OPTIONS = [
|
|
592
|
-
{
|
|
593
|
-
if: 'astcSupported',
|
|
594
|
-
basisFormat: [ BasisFormat.UASTC_4x4 ],
|
|
595
|
-
transcoderFormat: [ TranscoderFormat.ASTC_4x4, TranscoderFormat.ASTC_4x4 ],
|
|
596
|
-
engineFormat: [ EngineFormat.RGBA_ASTC_4x4_Format, EngineFormat.RGBA_ASTC_4x4_Format ],
|
|
597
|
-
priorityETC1S: Infinity,
|
|
598
|
-
priorityUASTC: 1,
|
|
599
|
-
needsPowerOfTwo: false,
|
|
600
|
-
},
|
|
601
|
-
{
|
|
602
|
-
if: 'bptcSupported',
|
|
603
|
-
basisFormat: [ BasisFormat.ETC1S, BasisFormat.UASTC_4x4 ],
|
|
604
|
-
transcoderFormat: [ TranscoderFormat.BC7_M5, TranscoderFormat.BC7_M5 ],
|
|
605
|
-
engineFormat: [ EngineFormat.RGBA_BPTC_Format, EngineFormat.RGBA_BPTC_Format ],
|
|
606
|
-
priorityETC1S: 3,
|
|
607
|
-
priorityUASTC: 2,
|
|
608
|
-
needsPowerOfTwo: false,
|
|
609
|
-
},
|
|
610
|
-
{
|
|
611
|
-
if: 'dxtSupported',
|
|
612
|
-
basisFormat: [ BasisFormat.ETC1S, BasisFormat.UASTC_4x4 ],
|
|
613
|
-
transcoderFormat: [ TranscoderFormat.BC1, TranscoderFormat.BC3 ],
|
|
614
|
-
engineFormat: [ EngineFormat.RGB_S3TC_DXT1_Format, EngineFormat.RGBA_S3TC_DXT5_Format ],
|
|
615
|
-
priorityETC1S: 4,
|
|
616
|
-
priorityUASTC: 5,
|
|
617
|
-
needsPowerOfTwo: false,
|
|
618
|
-
},
|
|
619
|
-
{
|
|
620
|
-
if: 'etc2Supported',
|
|
621
|
-
basisFormat: [ BasisFormat.ETC1S, BasisFormat.UASTC_4x4 ],
|
|
622
|
-
transcoderFormat: [ TranscoderFormat.ETC1, TranscoderFormat.ETC2 ],
|
|
623
|
-
engineFormat: [ EngineFormat.RGB_ETC2_Format, EngineFormat.RGBA_ETC2_EAC_Format ],
|
|
624
|
-
priorityETC1S: 1,
|
|
625
|
-
priorityUASTC: 3,
|
|
626
|
-
needsPowerOfTwo: false,
|
|
627
|
-
},
|
|
628
|
-
{
|
|
629
|
-
if: 'etc1Supported',
|
|
630
|
-
basisFormat: [ BasisFormat.ETC1S, BasisFormat.UASTC_4x4 ],
|
|
631
|
-
transcoderFormat: [ TranscoderFormat.ETC1 ],
|
|
632
|
-
engineFormat: [ EngineFormat.RGB_ETC1_Format ],
|
|
633
|
-
priorityETC1S: 2,
|
|
634
|
-
priorityUASTC: 4,
|
|
635
|
-
needsPowerOfTwo: false,
|
|
636
|
-
},
|
|
637
|
-
{
|
|
638
|
-
if: 'pvrtcSupported',
|
|
639
|
-
basisFormat: [ BasisFormat.ETC1S, BasisFormat.UASTC_4x4 ],
|
|
640
|
-
transcoderFormat: [ TranscoderFormat.PVRTC1_4_RGB, TranscoderFormat.PVRTC1_4_RGBA ],
|
|
641
|
-
engineFormat: [ EngineFormat.RGB_PVRTC_4BPPV1_Format, EngineFormat.RGBA_PVRTC_4BPPV1_Format ],
|
|
642
|
-
priorityETC1S: 5,
|
|
643
|
-
priorityUASTC: 6,
|
|
644
|
-
needsPowerOfTwo: true,
|
|
645
|
-
},
|
|
646
|
-
];
|
|
647
|
-
|
|
648
|
-
const ETC1S_OPTIONS = FORMAT_OPTIONS.sort( function ( a, b ) {
|
|
649
|
-
|
|
650
|
-
return a.priorityETC1S - b.priorityETC1S;
|
|
651
|
-
|
|
652
|
-
} );
|
|
653
|
-
const UASTC_OPTIONS = FORMAT_OPTIONS.sort( function ( a, b ) {
|
|
654
|
-
|
|
655
|
-
return a.priorityUASTC - b.priorityUASTC;
|
|
656
|
-
|
|
657
|
-
} );
|
|
658
|
-
|
|
659
|
-
function getTranscoderFormat( basisFormat, width, height, hasAlpha ) {
|
|
660
|
-
|
|
661
|
-
let transcoderFormat;
|
|
662
|
-
let engineFormat;
|
|
663
|
-
|
|
664
|
-
const options = basisFormat === BasisFormat.ETC1S ? ETC1S_OPTIONS : UASTC_OPTIONS;
|
|
665
|
-
|
|
666
|
-
for ( let i = 0; i < options.length; i ++ ) {
|
|
667
|
-
|
|
668
|
-
const opt = options[ i ];
|
|
669
|
-
|
|
670
|
-
if ( ! config[ opt.if ] ) continue;
|
|
671
|
-
if ( ! opt.basisFormat.includes( basisFormat ) ) continue;
|
|
672
|
-
if ( hasAlpha && opt.transcoderFormat.length < 2 ) continue;
|
|
673
|
-
if ( opt.needsPowerOfTwo && ! ( isPowerOfTwo( width ) && isPowerOfTwo( height ) ) ) continue;
|
|
674
|
-
|
|
675
|
-
transcoderFormat = opt.transcoderFormat[ hasAlpha ? 1 : 0 ];
|
|
676
|
-
engineFormat = opt.engineFormat[ hasAlpha ? 1 : 0 ];
|
|
677
|
-
|
|
678
|
-
return { transcoderFormat, engineFormat };
|
|
679
|
-
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
console.warn( 'THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32.' );
|
|
683
|
-
|
|
684
|
-
transcoderFormat = TranscoderFormat.RGBA32;
|
|
685
|
-
engineFormat = EngineFormat.RGBAFormat;
|
|
686
|
-
|
|
687
|
-
return { transcoderFormat, engineFormat };
|
|
688
|
-
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
function isPowerOfTwo( value ) {
|
|
692
|
-
|
|
693
|
-
if ( value <= 2 ) return true;
|
|
694
|
-
|
|
695
|
-
return ( value & ( value - 1 ) ) === 0 && value !== 0;
|
|
696
|
-
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
/** Concatenates N byte arrays. */
|
|
700
|
-
function concat( arrays ) {
|
|
701
|
-
|
|
702
|
-
if ( arrays.length === 1 ) return arrays[ 0 ];
|
|
703
|
-
|
|
704
|
-
let totalByteLength = 0;
|
|
705
|
-
|
|
706
|
-
for ( let i = 0; i < arrays.length; i ++ ) {
|
|
707
|
-
|
|
708
|
-
const array = arrays[ i ];
|
|
709
|
-
totalByteLength += array.byteLength;
|
|
710
|
-
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
const result = new Uint8Array( totalByteLength );
|
|
714
|
-
|
|
715
|
-
let byteOffset = 0;
|
|
716
|
-
|
|
717
|
-
for ( let i = 0; i < arrays.length; i ++ ) {
|
|
718
|
-
|
|
719
|
-
const array = arrays[ i ];
|
|
720
|
-
result.set( array, byteOffset );
|
|
721
|
-
|
|
722
|
-
byteOffset += array.byteLength;
|
|
723
|
-
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
return result;
|
|
727
|
-
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
};
|
|
731
|
-
|
|
732
|
-
//
|
|
733
|
-
// DataTexture and Data3DTexture parsing.
|
|
734
|
-
|
|
735
|
-
const FORMAT_MAP = {
|
|
736
|
-
|
|
737
|
-
[ VK_FORMAT_R32G32B32A32_SFLOAT ]: RGBAFormat,
|
|
738
|
-
[ VK_FORMAT_R16G16B16A16_SFLOAT ]: RGBAFormat,
|
|
739
|
-
[ VK_FORMAT_R8G8B8A8_UNORM ]: RGBAFormat,
|
|
740
|
-
[ VK_FORMAT_R8G8B8A8_SRGB ]: RGBAFormat,
|
|
741
|
-
|
|
742
|
-
[ VK_FORMAT_R32G32_SFLOAT ]: RGFormat,
|
|
743
|
-
[ VK_FORMAT_R16G16_SFLOAT ]: RGFormat,
|
|
744
|
-
[ VK_FORMAT_R8G8_UNORM ]: RGFormat,
|
|
745
|
-
[ VK_FORMAT_R8G8_SRGB ]: RGFormat,
|
|
746
|
-
|
|
747
|
-
[ VK_FORMAT_R32_SFLOAT ]: RedFormat,
|
|
748
|
-
[ VK_FORMAT_R16_SFLOAT ]: RedFormat,
|
|
749
|
-
[ VK_FORMAT_R8_SRGB ]: RedFormat,
|
|
750
|
-
[ VK_FORMAT_R8_UNORM ]: RedFormat,
|
|
751
|
-
|
|
752
|
-
};
|
|
753
|
-
|
|
754
|
-
const TYPE_MAP = {
|
|
755
|
-
|
|
756
|
-
[ VK_FORMAT_R32G32B32A32_SFLOAT ]: FloatType,
|
|
757
|
-
[ VK_FORMAT_R16G16B16A16_SFLOAT ]: HalfFloatType,
|
|
758
|
-
[ VK_FORMAT_R8G8B8A8_UNORM ]: UnsignedByteType,
|
|
759
|
-
[ VK_FORMAT_R8G8B8A8_SRGB ]: UnsignedByteType,
|
|
760
|
-
|
|
761
|
-
[ VK_FORMAT_R32G32_SFLOAT ]: FloatType,
|
|
762
|
-
[ VK_FORMAT_R16G16_SFLOAT ]: HalfFloatType,
|
|
763
|
-
[ VK_FORMAT_R8G8_UNORM ]: UnsignedByteType,
|
|
764
|
-
[ VK_FORMAT_R8G8_SRGB ]: UnsignedByteType,
|
|
765
|
-
|
|
766
|
-
[ VK_FORMAT_R32_SFLOAT ]: FloatType,
|
|
767
|
-
[ VK_FORMAT_R16_SFLOAT ]: HalfFloatType,
|
|
768
|
-
[ VK_FORMAT_R8_SRGB ]: UnsignedByteType,
|
|
769
|
-
[ VK_FORMAT_R8_UNORM ]: UnsignedByteType,
|
|
770
|
-
|
|
771
|
-
};
|
|
772
|
-
|
|
773
|
-
const COLOR_SPACE_MAP = {
|
|
774
|
-
|
|
775
|
-
[ VK_FORMAT_R8G8B8A8_SRGB ]: SRGBColorSpace,
|
|
776
|
-
[ VK_FORMAT_R8G8_SRGB ]: SRGBColorSpace,
|
|
777
|
-
[ VK_FORMAT_R8_SRGB ]: SRGBColorSpace,
|
|
778
|
-
|
|
779
|
-
};
|
|
780
|
-
|
|
781
|
-
async function createDataTexture( container, levelIndex = 0 ) {
|
|
782
|
-
|
|
783
|
-
const { vkFormat } = container;
|
|
784
|
-
const pixelWidth = Math.max( 1, container.pixelWidth >> levelIndex );
|
|
785
|
-
const pixelHeight = Math.max( 1, container.pixelHeight >> levelIndex );
|
|
786
|
-
const pixelDepth = Math.max( 1, container.pixelDepth >> levelIndex );
|
|
787
|
-
|
|
788
|
-
if ( FORMAT_MAP[ vkFormat ] === undefined ) {
|
|
789
|
-
|
|
790
|
-
throw new Error( 'THREE.KTX2Loader: Unsupported vkFormat.' );
|
|
791
|
-
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
const level = container.levels[ levelIndex ];
|
|
795
|
-
|
|
796
|
-
let levelData;
|
|
797
|
-
let view;
|
|
798
|
-
|
|
799
|
-
if ( container.supercompressionScheme === KHR_SUPERCOMPRESSION_NONE ) {
|
|
800
|
-
|
|
801
|
-
levelData = level.levelData;
|
|
802
|
-
|
|
803
|
-
} else if ( container.supercompressionScheme === KHR_SUPERCOMPRESSION_ZSTD ) {
|
|
804
|
-
|
|
805
|
-
if ( ! _zstd ) {
|
|
806
|
-
|
|
807
|
-
_zstd = new Promise( async ( resolve ) => {
|
|
808
|
-
|
|
809
|
-
const zstd = new ZSTDDecoder();
|
|
810
|
-
await zstd.init();
|
|
811
|
-
resolve( zstd );
|
|
812
|
-
|
|
813
|
-
} );
|
|
814
|
-
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
levelData = ( await _zstd ).decode( level.levelData, level.uncompressedByteLength );
|
|
818
|
-
|
|
819
|
-
} else {
|
|
820
|
-
|
|
821
|
-
throw new Error( 'THREE.KTX2Loader: Unsupported supercompressionScheme.' );
|
|
822
|
-
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
if ( TYPE_MAP[ vkFormat ] === FloatType ) {
|
|
826
|
-
|
|
827
|
-
view = new Float32Array(
|
|
828
|
-
|
|
829
|
-
levelData.buffer,
|
|
830
|
-
levelData.byteOffset,
|
|
831
|
-
levelData.byteLength / Float32Array.BYTES_PER_ELEMENT
|
|
832
|
-
|
|
833
|
-
);
|
|
834
|
-
|
|
835
|
-
} else if ( TYPE_MAP[ vkFormat ] === HalfFloatType ) {
|
|
836
|
-
|
|
837
|
-
view = new Uint16Array(
|
|
838
|
-
|
|
839
|
-
levelData.buffer,
|
|
840
|
-
levelData.byteOffset,
|
|
841
|
-
levelData.byteLength / Uint16Array.BYTES_PER_ELEMENT
|
|
842
|
-
|
|
843
|
-
);
|
|
844
|
-
|
|
845
|
-
} else {
|
|
846
|
-
|
|
847
|
-
view = levelData;
|
|
848
|
-
|
|
849
|
-
}
|
|
850
|
-
//
|
|
851
|
-
|
|
852
|
-
const texture = pixelDepth === 0
|
|
853
|
-
? new DataTexture( view, pixelWidth, pixelHeight )
|
|
854
|
-
: new Data3DTexture( view, pixelWidth, pixelHeight, pixelDepth );
|
|
855
|
-
|
|
856
|
-
texture.type = TYPE_MAP[ vkFormat ];
|
|
857
|
-
texture.format = FORMAT_MAP[ vkFormat ];
|
|
858
|
-
texture.colorSpace = COLOR_SPACE_MAP[ vkFormat ] || NoColorSpace;
|
|
859
|
-
|
|
860
|
-
texture.needsUpdate = true;
|
|
861
|
-
|
|
862
|
-
//
|
|
863
|
-
|
|
864
|
-
return Promise.resolve( texture );
|
|
865
|
-
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
export { KTX2Loader };
|