Skip to content

Documentation / @sw-file-lib/three

@sw-file-lib/three ​

TypeScript libraries for reading, writing Stormworks files.

This package includes three.js helpers including coordinate conversion, mesh creation, and materials. For other packages, see GitHub Repository.

Get Started

Documentation ​

Three.js integration utilities, including mesh conversion and imitation of Stormworks materials and lights.

Useful for tools that show 3D previews of components/vehicles.

Classes ​

ClassDescription
UniformControllerManages shader uniforms for a material.
VehicleBodyAssemblerAssembles a single Stormworks vehicle body into Three.js objects.

Interfaces ​

InterfaceDescription
AdditiveUniformsUniforms used by the additive material.
CreateSwLightsOptionsOptions used when creating the default Stormworks-style lights.
CreateSwMaterialsOptionsOptions used when creating the default Stormworks material set.
CreateSwMeshOptionsOptions used when creating a render mesh object from parsed mesh data.
CreateSwPhysMeshOptionsOptions used when creating a physics mesh group from parsed phys data.
GlassUniformsUniforms used by the glass material.
OpaqueUniformsUniforms used by the opaque material.
SwMaterialSetMaterials and their uniform stores used by Stormworks object creation helpers.
SwUniformControllersMutable Three.js uniform stores owned by a Stormworks material set.
VehicleAssetResolverAsset resolver used by VehicleBodyAssembler.
VehicleBodyBuildOptionsOptions for VehicleBodyAssembler.build.

Type Aliases ​

Type AliasDescription
AdditiveUniformControllerManages shader uniforms for the additive material.
ComponentDefinitionResolverResolves a component definition from its component ID.
GlassUniformControllerManages shader uniforms for the glass material.
MeshAttributeNameThe type for the mesh reference attributes in the component definition XML.
MeshResolverResolves a Three.js geometry from a Stormworks mesh path.
OpaqueUniformControllerManages shader uniforms for the opaque material.
SwMaterialKindMaterial families for Stormworks mesh.

Variables ​

VariableDescription
MESH_ATTRIBUTE_NAMESThe names of the mesh reference attributes in the component definition XML.

Functions ​

FunctionDescription
applyBuilderOnBufferGeometryTransfers the contents of a GeometryBuilder into a THREE.BufferGeometry.
bufferGeometryFromBuilderCreates a new THREE.BufferGeometry from a GeometryBuilder.
createAdditiveMaterialCreate an additive material used for materialIndex 2 groups.
createAdditiveUniformsCreate the default uniforms used for additive materials.
createGlassMaterialCreate the default glass material used for materialIndex 1 groups.
createGlassUniformsCreate the default uniforms used for glass materials.
createOpaqueMaterialCreate the default opaque material used for materialIndex 0 groups.
createOpaqueUniformsCreate the default uniforms used for opaque materials.
createSwLightGroupCreate a group containing the default Stormworks-style lights.
createSwLightsCreate the default Stormworks-style light objects.
createSwMaterialsCreate the default materials used by Stormworks object helpers.
createSwMeshCreate a renderable Three.js mesh from parsed Stormworks mesh data.
createSwMeshGeometryCreate buffer geometry for parsed Stormworks render mesh data.
createSwPhysGroupGeometryCreate buffer geometry for parsed Stormworks phys group.
createSwPhysMeshGroupCreate a Three.js group from parsed Stormworks phys data.
createVehicleAssetResolverCreates a VehicleAssetResolver from raw asset providers.
withCacheWraps an asynchronous resolver with memoization.