├── .gitattributes ├── .github └── workflows │ ├── build-and-test.yaml │ ├── merge-and-run.yaml │ ├── publish-bfast-nuget.yml │ ├── publish-format-nuget.yml │ ├── publish-g3d-nuget.yml │ ├── publish-linqarray-nuget.yml │ ├── publish-math3d-nuget.yml │ ├── publish-nuget.yaml │ ├── publish-ts-dev.yaml │ └── publish-ts.yaml ├── .gitignore ├── README.md ├── data ├── .gitkeep ├── Dwelling.r2019.om_v5.5.0.vim ├── RoomTest.vim ├── Wolford_Residence.r2023.om_v4.4.0.vim ├── Wolford_Residence.r2023.om_v5.0.0.vim └── gltf-samples │ ├── BoomBoxWithAxes.glb │ ├── Fox.glb │ ├── SciFiHelmet.glb │ └── ToyCar.glb ├── devops ├── build-cpp-tests.sh ├── check-nuget-version.sh ├── cs-tag-commit.sh ├── csproj-version.sh ├── run-cpp-tests.sh └── ts-tag-commit.sh ├── docs ├── bfast.md ├── g3d.md ├── linqarray.md ├── math3d.md ├── object-model-schema.json ├── object-model.md ├── schema-diff.json └── vim.md ├── license.txt └── src ├── cpp ├── bfast.h ├── g3d.h ├── math3d │ ├── CMakeLists.txt │ ├── constants.h │ ├── experimental.h │ ├── hash.h │ ├── math_ops.h │ ├── random.h │ ├── structs.h │ ├── value_domain.h │ ├── vim_math3d.cpp │ └── vim_math3d.h └── vim │ ├── .gitignore │ ├── Vim.Cpp.vcxproj │ ├── Vim.Cpp.vcxproj.filters │ ├── object-model.h │ ├── test-object-model.cpp │ ├── test.cpp │ ├── tests.h │ └── vim.h ├── cs ├── .editorconfig ├── .gitignore ├── .gitkeep ├── bfast │ ├── Vim.BFast.Tests │ │ ├── BFastTestProgram.cs │ │ └── Vim.BFast.Tests.csproj │ └── Vim.BFast │ │ ├── BFast.cs │ │ ├── BFastBufferReader.cs │ │ ├── BFastBuilder.cs │ │ ├── BFastStructs.cs │ │ ├── BufferExtensions.cs │ │ ├── Buffers.cs │ │ ├── SeekContext.cs │ │ ├── UnsafeHelpers.cs │ │ ├── Vim.BFast.csproj │ │ ├── readme.md │ │ └── spec.txt ├── g3d │ ├── G3d.Build.props │ ├── Vim.G3d.AssimpWrapper │ │ ├── AssimpExtensions.cs │ │ ├── AssimpLoader.cs │ │ └── Vim.G3d.AssimpWrapper.csproj │ ├── Vim.G3d.Tests │ │ ├── G3dTestUtils.cs │ │ ├── G3dTests.cs │ │ ├── Properties │ │ │ ├── Resources.Designer.cs │ │ │ └── Resources.resx │ │ ├── Resources │ │ │ └── .gitignore │ │ ├── Util.cs │ │ └── Vim.G3d.Tests.csproj │ └── Vim.G3d │ │ ├── AttributeDescriptor.cs │ │ ├── AttributeExtensions.cs │ │ ├── CommonAttributes.cs │ │ ├── CommonAttributes.tt │ │ ├── Enums.cs │ │ ├── G3D.cs │ │ ├── G3DBuilder.cs │ │ ├── G3dMaterial.cs │ │ ├── G3dMesh.cs │ │ ├── G3dSerialization.cs │ │ ├── G3dShape.cs │ │ ├── G3dWriter.cs │ │ ├── GeometryAttribute.cs │ │ ├── GeometryAttributes.cs │ │ ├── GeometryAttributesExtensions.cs │ │ ├── Header.cs │ │ ├── IGeometryAttributes.cs │ │ ├── ObjExporter.cs │ │ ├── PlyExporter.cs │ │ ├── README.md │ │ ├── Validation.cs │ │ └── Vim.G3d.csproj ├── linqarray │ ├── Vim.LinqArray.Tests │ │ ├── LinqArrayTests.cs │ │ └── Vim.LinqArray.Tests.csproj │ └── Vim.LinqArray │ │ ├── ILookup.cs │ │ ├── LinqArray.cs │ │ ├── README.md │ │ └── Vim.LinqArray.csproj ├── math3d │ ├── .editorconfig │ ├── Vim.Math3D.Tests │ │ ├── AABox2DTests.cs │ │ ├── DVector3Tests.cs │ │ ├── Line2DTests.cs │ │ ├── MathHelper.cs │ │ ├── Matrix4x4Tests.cs │ │ ├── PlaneTests.cs │ │ ├── QuaternionTests.cs │ │ ├── RayTests.cs │ │ ├── Util.cs │ │ ├── Vector2Tests.cs │ │ ├── Vector3Tests.cs │ │ ├── Vector4Tests.cs │ │ └── Vim.Math3D.Tests.csproj │ ├── Vim.Math3D │ │ ├── AABox.cs │ │ ├── AABox2D.cs │ │ ├── Constants.cs │ │ ├── ContainmentType.cs │ │ ├── DMatrix4x4.cs │ │ ├── Experimental.cs │ │ ├── Hash.cs │ │ ├── IMappable.cs │ │ ├── IPoints.cs │ │ ├── ITransformable.cs │ │ ├── LinqUtil.cs │ │ ├── MathOps.cs │ │ ├── MathOps.tt │ │ ├── MathOpsPartial.cs │ │ ├── Matrix4x4.cs │ │ ├── Plane.cs │ │ ├── PlaneIntersectionType.cs │ │ ├── Quad.cs │ │ ├── Quaternion.cs │ │ ├── Random.cs │ │ ├── Ray.cs │ │ ├── Sphere.cs │ │ ├── Stats.cs │ │ ├── Structs.cs │ │ ├── Structs.tt │ │ ├── StructsPartial.cs │ │ ├── TemplateHelpers.tt │ │ ├── Triangle.cs │ │ ├── Triangle2D.cs │ │ ├── ValueDomain.cs │ │ └── Vim.Math3D.csproj │ ├── docfx_project │ │ ├── .gitignore │ │ ├── api │ │ │ ├── .gitignore │ │ │ └── index.md │ │ ├── articles │ │ │ ├── csharp-math-libraries.md │ │ │ ├── intro.md │ │ │ └── toc.yml │ │ ├── docfx.json │ │ ├── filterConfig.yml │ │ ├── images │ │ │ ├── favicon.ico │ │ │ └── vim_color_logo_landscape_whitetext_small.png │ │ ├── index.md │ │ ├── templates │ │ │ ├── material │ │ │ │ ├── partials │ │ │ │ │ └── head.tmpl.partial │ │ │ │ └── styles │ │ │ │ │ └── main.css │ │ │ ├── old-vim │ │ │ │ ├── layout │ │ │ │ │ └── _master.tmpl │ │ │ │ ├── partials │ │ │ │ │ ├── _affix.liquid │ │ │ │ │ ├── _breadcrumb.liquid │ │ │ │ │ ├── _footer.liquid │ │ │ │ │ ├── _head.liquid │ │ │ │ │ ├── _logo.liquid │ │ │ │ │ ├── _navbar.liquid │ │ │ │ │ ├── _scripts.liquid │ │ │ │ │ ├── _toc.liquid │ │ │ │ │ ├── affix.tmpl.partial │ │ │ │ │ ├── breadcrumb.tmpl.partial │ │ │ │ │ ├── class.header.tmpl.partial │ │ │ │ │ ├── class.tmpl.partial │ │ │ │ │ ├── customMREFContent.tmpl.partial │ │ │ │ │ ├── dd-li.tmpl.partial │ │ │ │ │ ├── enum.tmpl.partial │ │ │ │ │ ├── footer.tmpl.partial │ │ │ │ │ ├── head.tmpl.partial │ │ │ │ │ ├── li.tmpl.partial │ │ │ │ │ ├── logo.tmpl.partial │ │ │ │ │ ├── namespace.tmpl.partial │ │ │ │ │ ├── navbar.tmpl.partial │ │ │ │ │ ├── rest.child.tmpl.partial │ │ │ │ │ ├── rest.tmpl.partial │ │ │ │ │ ├── scripts.tmpl.partial │ │ │ │ │ ├── searchResults.tmpl.partial │ │ │ │ │ ├── title.tmpl.partial │ │ │ │ │ ├── toc.tmpl.partial │ │ │ │ │ └── uref │ │ │ │ │ │ ├── class.header.tmpl.partial │ │ │ │ │ │ ├── class.tmpl.partial │ │ │ │ │ │ ├── enum.tmpl.partial │ │ │ │ │ │ ├── inheritance.tmpl.partial │ │ │ │ │ │ ├── namespace.tmpl.partial │ │ │ │ │ │ └── parameters.tmpl.partial │ │ │ │ └── styles │ │ │ │ │ ├── docfx.css │ │ │ │ │ └── main.css │ │ │ └── vim │ │ │ │ ├── VIM logo FULL COLOR landscape.png │ │ │ │ ├── VIM logo FULL COLOR landscape@2x.png │ │ │ │ ├── VIM logo WHITE landscape.png │ │ │ │ ├── VIM logo WHITE landscape@2x.png │ │ │ │ ├── VIM logo WHITE@2x.png │ │ │ │ ├── partials │ │ │ │ ├── class.header.tmpl.partial │ │ │ │ ├── class.tmpl.partial │ │ │ │ ├── head.tmpl.partial │ │ │ │ └── logo.tmpl.partial │ │ │ │ └── styles │ │ │ │ └── main.css │ │ └── toc.yml │ └── docs │ │ ├── api │ │ ├── Vim.Math3d.AABox.html │ │ ├── Vim.Math3d.AABox2D.html │ │ ├── Vim.Math3d.AABox4D.html │ │ ├── Vim.Math3d.AngularMotion.html │ │ ├── Vim.Math3d.AxisAngle.html │ │ ├── Vim.Math3d.Byte2.html │ │ ├── Vim.Math3d.Byte3.html │ │ ├── Vim.Math3d.Byte4.html │ │ ├── Vim.Math3d.ColorHDR.html │ │ ├── Vim.Math3d.ColorRGB.html │ │ ├── Vim.Math3d.ColorRGBA.html │ │ ├── Vim.Math3d.Complex.html │ │ ├── Vim.Math3d.Constants.html │ │ ├── Vim.Math3d.ContainmentType.html │ │ ├── Vim.Math3d.CylindricalCoordinate.html │ │ ├── Vim.Math3d.DAABox.html │ │ ├── Vim.Math3d.DAABox2D.html │ │ ├── Vim.Math3d.DAABox4D.html │ │ ├── Vim.Math3d.DInterval.html │ │ ├── Vim.Math3d.DPlane.html │ │ ├── Vim.Math3d.DQuaternion.html │ │ ├── Vim.Math3d.DRay.html │ │ ├── Vim.Math3d.DSphere.html │ │ ├── Vim.Math3d.DVector2.html │ │ ├── Vim.Math3d.DVector3.html │ │ ├── Vim.Math3d.DVector4.html │ │ ├── Vim.Math3d.Euler.html │ │ ├── Vim.Math3d.GeoCoordinate.html │ │ ├── Vim.Math3d.Hash.html │ │ ├── Vim.Math3d.HorizontalCoordinate.html │ │ ├── Vim.Math3d.IMappable-2.html │ │ ├── Vim.Math3d.IPoints.html │ │ ├── Vim.Math3d.IPoints2D.html │ │ ├── Vim.Math3d.ITransformable3D-1.html │ │ ├── Vim.Math3d.Int2.html │ │ ├── Vim.Math3d.Int3.html │ │ ├── Vim.Math3d.Int4.html │ │ ├── Vim.Math3d.Interval.html │ │ ├── Vim.Math3d.Line.html │ │ ├── Vim.Math3d.Line2D.html │ │ ├── Vim.Math3d.LinearMotion.html │ │ ├── Vim.Math3d.LinqUtil.html │ │ ├── Vim.Math3d.LogPolarCoordinate.html │ │ ├── Vim.Math3d.MathOps.html │ │ ├── Vim.Math3d.Matrix4x4.html │ │ ├── Vim.Math3d.Motion.html │ │ ├── Vim.Math3d.MovementExtensions.html │ │ ├── Vim.Math3d.Plane.html │ │ ├── Vim.Math3d.PlaneIntersectionType.html │ │ ├── Vim.Math3d.PolarCoordinate.html │ │ ├── Vim.Math3d.Quad.html │ │ ├── Vim.Math3d.Quad2D.html │ │ ├── Vim.Math3d.Quaternion.html │ │ ├── Vim.Math3d.Ray.html │ │ ├── Vim.Math3d.Sphere.html │ │ ├── Vim.Math3d.SphericalCoordinate.html │ │ ├── Vim.Math3d.StatelessRandom.html │ │ ├── Vim.Math3d.Stats-1.html │ │ ├── Vim.Math3d.Transform.html │ │ ├── Vim.Math3d.Transformable3D.html │ │ ├── Vim.Math3d.Triangle.html │ │ ├── Vim.Math3d.Triangle2D.html │ │ ├── Vim.Math3d.Vector2.html │ │ ├── Vim.Math3d.Vector3.html │ │ ├── Vim.Math3d.Vector4.html │ │ ├── Vim.Math3d.html │ │ └── index.html │ │ ├── articles │ │ ├── csharp-math-libraries.html │ │ └── intro.html │ │ ├── favicon.ico │ │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ │ ├── images │ │ ├── favicon.ico │ │ └── vim_color_logo_landscape_whitetext_small.png │ │ ├── index.html │ │ ├── logo.svg │ │ ├── manifest.json │ │ ├── search-stopwords.json │ │ ├── styles │ │ ├── docfx.css │ │ ├── docfx.js │ │ ├── docfx.vendor.css │ │ ├── docfx.vendor.js │ │ ├── lunr.js │ │ ├── lunr.min.js │ │ ├── main.css │ │ ├── main.js │ │ └── search-worker.js │ │ └── xrefmap.yml ├── samples │ ├── README.md │ ├── Vim.Gltf.Converter.Tests │ │ ├── TestVimGltfConverter.cs │ │ └── Vim.Gltf.Converter.Tests.csproj │ ├── Vim.Gltf.Converter │ │ ├── GltfToVimStore.cs │ │ ├── Vim.Gltf.Converter.csproj │ │ └── VimToGltfStore.cs │ ├── Vim.JsonDigest.AzureFunction │ │ ├── .gitignore │ │ ├── GetVimJsonDigest.cs │ │ ├── Program.cs │ │ ├── Properties │ │ │ ├── serviceDependencies.json │ │ │ └── serviceDependencies.local.json │ │ ├── Vim.JsonDigest.AzureFunction.csproj │ │ ├── host.json │ │ └── local.settings.json │ ├── Vim.JsonDigest.Tests │ │ ├── TestVimJsonDigest.cs │ │ └── Vim.JsonDigest.Tests.csproj │ └── Vim.JsonDigest │ │ ├── AreaDigest.cs │ │ ├── BimDocumentDigest.cs │ │ ├── ElementDigest.cs │ │ ├── LevelDigest.cs │ │ ├── MaterialDigest.cs │ │ ├── RoomDigest.cs │ │ ├── Vim.JsonDigest.csproj │ │ └── VimJsonDigest.cs ├── util │ ├── Vim.Util.Logging.Serilog │ │ ├── Log.cs │ │ ├── SerilogLoggerAdapter.cs │ │ └── Vim.Util.Logging.Serilog.csproj │ ├── Vim.Util.Tests │ │ ├── CommandLineExtensions.cs │ │ ├── CronTests.cs │ │ ├── FeetAndInchParsingTests.cs │ │ ├── MD5Tests.cs │ │ ├── PipeSeparatedStringsTests.cs │ │ ├── Properties │ │ │ ├── Resources.Designer.cs │ │ │ └── Resources.resx │ │ ├── Resources │ │ │ └── .gitignore │ │ ├── SerializableVersionTests.cs │ │ ├── ShellProcess.cs │ │ ├── TestContext.cs │ │ ├── Vim.Util.Tests.csproj │ │ └── VimFormatRepoPaths.cs │ └── Vim.Util │ │ ├── ArrayEqualityComparer.cs │ │ ├── CodeBuilder.cs │ │ ├── Cron.cs │ │ ├── DictionaryOfLists.cs │ │ ├── Disposer.cs │ │ ├── Either.cs │ │ ├── EnumWithDescription.cs │ │ ├── HResult.cs │ │ ├── Http.cs │ │ ├── IO.cs │ │ ├── IndexedSet.cs │ │ ├── LinqExtensions.cs │ │ ├── Logging │ │ ├── DurationLogger.cs │ │ ├── ILogger.cs │ │ ├── IndentLogger.cs │ │ ├── LogLevel.cs │ │ ├── NullLogger.cs │ │ ├── RecordLogger.cs │ │ └── StdLogger.cs │ │ ├── MD5Extensions.cs │ │ ├── PipeSeparatedStrings.cs │ │ ├── ProcessResult.cs │ │ ├── Reflection.cs │ │ ├── Result.cs │ │ ├── ResultExtensions.cs │ │ ├── SerializableVersion.cs │ │ ├── SpecialFolders.cs │ │ ├── Statistics.cs │ │ ├── StringFormatting.cs │ │ ├── SynchronousProgress.cs │ │ ├── Tree.cs │ │ ├── Util.cs │ │ ├── Vim.Util.csproj │ │ └── WithRetry.cs ├── vim-format.sln └── vim │ ├── Vim.Format.CodeGen │ ├── HandWrittenCpp.cpp │ ├── ObjectModelCppGenerator.cs │ ├── ObjectModelGenerator.cs │ ├── ObjectModelTypeScriptGenerator.cs │ ├── Program.cs │ └── Vim.Format.CodeGen.csproj │ ├── Vim.Format.Core │ ├── AssetInfo.cs │ ├── BigG3dWriter.cs │ ├── CascadeElementRemapAttribute.cs │ ├── ColumnExtensions.Buffer.cs │ ├── ColumnExtensions.Reflection.cs │ ├── ColumnExtensions.cs │ ├── ColumnInfo.cs │ ├── Document.cs │ ├── DocumentBuilder.cs │ ├── DocumentBuilderExtensions.cs │ ├── DocumentBuilderTypes.cs │ ├── DocumentExtensions.cs │ ├── EntityColumnLoaderAttribute.cs │ ├── EntityColumnLoadingInfo.cs │ ├── EntityTable.cs │ ├── EntityTableBuilder.cs │ ├── EntityTable_v2.cs │ ├── ErrorCode.cs │ ├── Geometry │ │ ├── ArrayOps.cs │ │ ├── ArrayOps.tt │ │ ├── Bounded.cs │ │ ├── CatmullClark.cs │ │ ├── GeometryCuttingUtils.cs │ │ ├── GeometryUtil.cs │ │ ├── IMesh.cs │ │ ├── IScene.cs │ │ ├── KdTree.cs │ │ ├── MeshDebugView.cs │ │ ├── MeshExtensions.cs │ │ ├── MeshOptimization.cs │ │ ├── PerimeterProjection.cs │ │ ├── Primitives.cs │ │ ├── QuadMesh.cs │ │ ├── SceneExtensions.cs │ │ ├── Serialization.cs │ │ ├── Topology.cs │ │ ├── TriMesh.cs │ │ ├── Validation.cs │ │ └── VimMaterial.cs │ ├── SerializableDocument.cs │ ├── SerializableHeader.cs │ ├── Serializer.cs │ ├── TableNameAttribute.cs │ ├── Validation.cs │ ├── ValueSerializationStrategy.cs │ ├── Vim.Format.Core.csproj │ ├── VimConstants.cs │ ├── VimFormatVersion.cs │ └── VimSchema.cs │ ├── Vim.Format.ILMerge.Tests │ ├── Vim.Format.ILMerge.Tests.csproj │ └── VimFormatILMergeTests.cs │ ├── Vim.Format.ILMerge │ ├── ILRepack.Config.props │ ├── ILRepack.targets │ └── Vim.Format.ILMerge.csproj │ ├── Vim.Format.Tests │ ├── EntityTable_v2_Tests.cs │ ├── FormatTests.cs │ ├── GenerateRevitBuiltInCategories.cs │ ├── Geometry │ │ ├── GeometryTests.cs │ │ ├── PerimeterTest.cs │ │ └── RayTests.cs │ ├── MergeServiceTests.cs │ ├── PublishedVersionTests.cs │ ├── ReferenceAppTests.cs │ ├── RoomServiceTests.cs │ ├── TrainingSetTests.cs │ ├── TransformServiceTests.cs │ ├── Vim.Format.Tests.csproj │ ├── VimCppTests.cs │ └── VimTypeScriptTest.cs │ └── Vim.Format │ ├── Merge │ ├── MergeConfigFiles.cs │ ├── MergeConfigOptions.cs │ ├── MergeConfigVimScenes.cs │ ├── MergeService.cs │ ├── MergedTableBuilder.cs │ └── RemappedEntityTableBuilder.cs │ ├── ObjectModel │ ├── ElementIndexMaps.cs │ ├── ElementInfo.cs │ ├── EntityTableSet.cs │ ├── ObjectModel.cs │ ├── ObjectModelBuilder.cs │ ├── ObjectModelExtensions.cs │ ├── ObjectModelGenerated.cs │ ├── ObjectModelStore.cs │ ├── RevitBuiltInCategory.cs │ ├── Urn.cs │ └── Validation.cs │ ├── RoomService.cs │ ├── SceneBuilder │ ├── Validation.cs │ ├── VimScene.cs │ ├── VimSceneHelpers.cs │ ├── VimSceneNode.cs │ └── VimShape.cs │ ├── TransformService.cs │ └── Vim.Format.csproj ├── dart ├── bfast.dart ├── g3d.dart ├── object_model.dart └── vim.dart ├── rust ├── bfast │ ├── Cargo.lock │ ├── Cargo.toml │ └── src │ │ └── lib.rs ├── g3d │ ├── Cargo.lock │ ├── Cargo.toml │ └── src │ │ ├── descriptors.rs │ │ └── lib.rs ├── math3d │ ├── Cargo.lock │ ├── Cargo.toml │ ├── math3d_macro_derive │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ └── src │ │ │ └── lib.rs │ └── src │ │ ├── constants.rs │ │ ├── hash.rs │ │ ├── lib.rs │ │ ├── math3d_ops.rs │ │ ├── stateless_random.rs │ │ ├── structs.rs │ │ └── transformable.rs ├── object_model │ ├── Cargo.lock │ ├── Cargo.toml │ ├── object_model_macro_derive │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ └── src │ │ │ └── lib.rs │ └── src │ │ └── lib.rs ├── vim │ ├── Cargo.lock │ ├── Cargo.toml │ └── src │ │ └── lib.rs └── vim_format │ ├── Cargo.lock │ ├── Cargo.toml │ └── src │ └── main.rs └── ts ├── .gitignore ├── README.md ├── dist ├── abstractG3d.d.ts ├── abstractG3d.js ├── bfast.d.ts ├── bfast.js ├── converters.d.ts ├── converters.js ├── entityTable.d.ts ├── entityTable.js ├── g3d.d.ts ├── g3d.js ├── g3d │ ├── g3d.js │ ├── g3dChunk.js │ ├── g3dMaterials.js │ ├── g3dMesh.js │ └── g3dScene.js ├── g3dAttributes.d.ts ├── g3dAttributes.js ├── g3dChunk.js ├── g3dMaterials.d.ts ├── g3dMaterials.js ├── g3dMesh.d.ts ├── g3dMesh.js ├── g3dMeshIndex.d.ts ├── g3dMeshIndex.js ├── g3dMeshOffsets.d.ts ├── g3dMeshOffsets.js ├── g3dScene.d.ts ├── g3dScene.js ├── g3dSubset.d.ts ├── g3dSubset.js ├── http │ ├── logging.js │ ├── remoteBuffer.js │ ├── remoteValue.js │ ├── requestTracker.js │ ├── requester.js │ └── retriableRequest.js ├── index.d.ts ├── index.js ├── logging.d.ts ├── logging.js ├── objectModel.d.ts ├── objectModel.js ├── remoteBuffer.d.ts ├── remoteBuffer.js ├── remoteG3d.d.ts ├── remoteG3d.js ├── remoteGeometry.d.ts ├── remoteGeometry.js ├── remoteValue.d.ts ├── remoteValue.js ├── remoteVimx.d.ts ├── remoteVimx.js ├── requestTracker.d.ts ├── requestTracker.js ├── requester.d.ts ├── requester.js ├── retriableRequest.js ├── structures.d.ts ├── structures.js ├── types │ ├── abstractG3d.d.ts │ ├── bfast.d.ts │ ├── converters.d.ts │ ├── entityTable.d.ts │ ├── g3d.d.ts │ ├── g3dAttributes.d.ts │ ├── g3dMaterials.d.ts │ ├── g3dMesh.d.ts │ ├── g3dMeshIndex.d.ts │ ├── g3dMeshOffsets.d.ts │ ├── g3dScene.d.ts │ ├── g3dSubset.d.ts │ ├── index.d.ts │ ├── logging.d.ts │ ├── objectModel.d.ts │ ├── remoteBuffer.d.ts │ ├── remoteG3d.d.ts │ ├── remoteGeometry.d.ts │ ├── remoteValue.d.ts │ ├── remoteVimx.d.ts │ ├── requestTracker.d.ts │ ├── requester.d.ts │ ├── structures.d.ts │ ├── vimHeader.d.ts │ ├── vimHelpers.d.ts │ └── vimLoader.d.ts ├── utils.js ├── vimHeader.d.ts ├── vimHeader.js ├── vimHelpers.d.ts ├── vimHelpers.js ├── vimLoader.d.ts └── vimLoader.js ├── jest.config.js ├── package-lock.json ├── package.json ├── src ├── bfast.ts ├── converters.ts ├── entityTable.ts ├── g3d │ ├── g3d.ts │ ├── g3dChunk.ts │ ├── g3dMaterials.ts │ ├── g3dMesh.ts │ └── g3dScene.ts ├── http │ ├── logging.ts │ ├── remoteBuffer.ts │ ├── remoteValue.ts │ ├── requestTracker.ts │ ├── requester.ts │ └── retriableRequest.ts ├── index.ts ├── logging.ts ├── objectModel.ts ├── remoteVimx.ts ├── structures.ts ├── vimHeader.ts ├── vimHelpers.ts └── vimLoader.ts ├── tests ├── filter_0.txt ├── filter_1.txt ├── filter_4000.txt ├── filter_8059.txt ├── helpers.ts ├── objectModel.test.ts ├── parameters_119.txt └── vimHelpers.test.ts └── tsconfig.json /.gitattributes: -------------------------------------------------------------------------------- 1 | *.vim filter=lfs diff=lfs merge=lfs -text 2 | *.bin filter=lfs diff=lfs merge=lfs -text 3 | *.glb filter=lfs diff=lfs merge=lfs -text 4 | -------------------------------------------------------------------------------- /.github/workflows/merge-and-run.yaml: -------------------------------------------------------------------------------- 1 | name: Build merged 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | lfs: 7 | type: boolean 8 | default: false 9 | run-codegen: 10 | type: boolean 11 | default: false 12 | run: 13 | type: string 14 | working-directory: 15 | type: string 16 | default: "." 17 | 18 | jobs: 19 | merge_and_run: 20 | runs-on: ubuntu-latest 21 | 22 | steps: 23 | - name: Checkout 24 | uses: actions/checkout@v2 25 | with: 26 | lfs: ${{ inputs.lfs }} 27 | fetch-depth: 0 # fetches the whole history in order to be able to merge with the base branch 28 | 29 | - name: Setup DotNet Environment 30 | uses: actions/setup-dotnet@v1 31 | with: 32 | dotnet-version: | 33 | 6.0.x 34 | 8.0.x 35 | 36 | - name: Setup Git VIM Robot User Info 37 | run: | 38 | git config --global user.email "vim-robot@email.com" 39 | git config --global user.name "Vim Robot" 40 | 41 | - name: Merge with base 42 | run: git merge origin/${GITHUB_BASE_REF} # GITHUB_BASE_REF is only defined for pull requests 43 | shell: bash 44 | 45 | - name: Optionally run CodeGen first 46 | if: ${{ inputs.run-codegen }} 47 | run: dotnet build ./src/cs/vim/Vim.Format.CodeGen/Vim.Format.CodeGen.csproj 48 | shell: bash 49 | 50 | - name: Run 51 | shell: bash 52 | run: ${{ inputs.run }} 53 | working-directory: ${{ inputs.working-directory }} 54 | -------------------------------------------------------------------------------- /.github/workflows/publish-bfast-nuget.yml: -------------------------------------------------------------------------------- 1 | name: Publish BFast NuGet 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | publish: 8 | uses: ./.github/workflows/publish-nuget.yaml 9 | with: 10 | project_path: src/cs/bfast/Vim.BFast/Vim.BFast.csproj 11 | test_project_path: src/cs/bfast/Vim.BFast.Tests/Vim.BFast.Tests.csproj 12 | package_name: Vim.BFast 13 | secrets: 14 | VIM_NUGET_PUSH: ${{ secrets.VIM_NUGET_PUSH }} 15 | -------------------------------------------------------------------------------- /.github/workflows/publish-format-nuget.yml: -------------------------------------------------------------------------------- 1 | name: Publish Format NuGet 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | publish: 8 | uses: ./.github/workflows/publish-nuget.yaml 9 | with: 10 | project_path: src/cs/vim/Vim.Format/Vim.Format.csproj 11 | test_project_path: src/cs/vim/Vim.Format.Tests/Vim.Format.Tests.csproj 12 | package_name: Vim.Format 13 | secrets: 14 | VIM_NUGET_PUSH: ${{ secrets.VIM_NUGET_PUSH }} -------------------------------------------------------------------------------- /.github/workflows/publish-g3d-nuget.yml: -------------------------------------------------------------------------------- 1 | name: Publish G3D NuGet 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | publish: 8 | uses: ./.github/workflows/publish-nuget.yaml 9 | with: 10 | project_path: src/cs/g3d/Vim.G3d/Vim.G3d.csproj 11 | test_project_path: src/cs/g3d/Vim.G3d.Tests/Vim.G3d.Tests.csproj 12 | package_name: Vim.G3d 13 | secrets: 14 | VIM_NUGET_PUSH: ${{ secrets.VIM_NUGET_PUSH }} 15 | -------------------------------------------------------------------------------- /.github/workflows/publish-linqarray-nuget.yml: -------------------------------------------------------------------------------- 1 | name: Publish LinqArray NuGet 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | publish: 8 | uses: ./.github/workflows/publish-nuget.yaml 9 | with: 10 | project_path: src/cs/linqarray/Vim.LinqArray/Vim.LinqArray.csproj 11 | test_project_path: src/cs/linqarray/Vim.LinqArray.Tests/Vim.LinqArray.Tests.csproj 12 | package_name: Vim.LinqArray 13 | secrets: 14 | VIM_NUGET_PUSH: ${{ secrets.VIM_NUGET_PUSH }} 15 | -------------------------------------------------------------------------------- /.github/workflows/publish-math3d-nuget.yml: -------------------------------------------------------------------------------- 1 | name: Publish Math3D NuGet 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | publish: 8 | uses: ./.github/workflows/publish-nuget.yaml 9 | with: 10 | project_path: src/cs/math3d/Vim.Math3D/Vim.Math3D.csproj 11 | test_project_path: src/cs/math3d/Vim.Math3D.Tests/Vim.Math3D.Tests.csproj 12 | package_name: Vim.Math3D 13 | secrets: 14 | VIM_NUGET_PUSH: ${{ secrets.VIM_NUGET_PUSH }} 15 | -------------------------------------------------------------------------------- /.github/workflows/publish-ts.yaml: -------------------------------------------------------------------------------- 1 | name: Publish TS to NPM 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | build: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Checkout 11 | uses: actions/checkout@v2 12 | 13 | - name: Setup Node 14 | uses: actions/setup-node@v2 15 | with: 16 | node-version: '14.x' 17 | registry-url: 'https://registry.npmjs.org' 18 | 19 | - name: Install dependencies and build 🔧 20 | run: npm ci && npm run build 21 | working-directory: ./src/ts 22 | 23 | - name: Run tests 24 | run: npm test 25 | working-directory: ./src/ts 26 | 27 | - name: Publish package on NPM 📦 28 | run: npm publish 29 | working-directory: ./src/ts 30 | env: 31 | NODE_AUTH_TOKEN: ${{ secrets.VIM_NPM_PUSH }} 32 | 33 | - name: Tag commit 34 | run: ./devops/ts-tag-commit.sh ./src/ts/package.json 35 | shell: bash -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | out/ 2 | src/rust/vim_format/target/ 3 | src/rust/math3d/target/ 4 | src/rust/bfast/target/ 5 | src/rust/g3d/target/ 6 | src/rust/object_model/target/ 7 | src/rust/vim/target/ 8 | src/rust/math3d/math3d_macro_derive/target/ 9 | src/rust/object_model/object_model_macro_derive/target/ 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VIM Format 2 | Contains serialization code for the VIM file format 3 | 4 | This repository contains source code of the VIM libraries in three languages: 5 | - [C#](src/cs/) 6 | - [C++](src/cpp/) 7 | - [TypeScript](src/ts/) 8 | 9 | ## VIM 10 | The documentation for the VIM format can be found [here](docs/vim.md). 11 | 12 | ## VIM Object Model 13 | The documentation for the VIM Object Model can be found [here](docs/object-model.md). 14 | 15 | ## Math3D 16 | The documentation for the Math3D library can be found [here](docs/math3d.md). 17 | 18 | ## BFast 19 | The documentation for the BFast format can be found [here](docs/bfast.md). 20 | 21 | ## LinqArray 22 | The documentation for the LinqArray library can be found [here](docs/linqarray.md). 23 | -------------------------------------------------------------------------------- /data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimaec/vim-format/fc4a98e02e51ad595ef3e9b51d6223afbf9e53bc/data/.gitkeep -------------------------------------------------------------------------------- /data/Dwelling.r2019.om_v5.5.0.vim: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:bbefdb5bd6fa39560a9bd90f7aaa3e8f41571f53b2fe403224720da091ce4c44 3 | size 173716608 4 | -------------------------------------------------------------------------------- /data/RoomTest.vim: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:656c52aaf71858265ae3b02df07a0cb12d67d8a2de09ecafff2cd9c4f77df3ab 3 | size 14863680 4 | -------------------------------------------------------------------------------- /data/Wolford_Residence.r2023.om_v4.4.0.vim: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e885adbb6e4337a98f510666377226baa0d817072e85df271124f04a2e208b8c 3 | size 36990912 4 | -------------------------------------------------------------------------------- /data/Wolford_Residence.r2023.om_v5.0.0.vim: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:22fca9c9f5a9e6422084e624379f64154ad544e2b23d90d51800b2cad568e5b6 3 | size 37008000 4 | -------------------------------------------------------------------------------- /data/gltf-samples/BoomBoxWithAxes.glb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:4404cf4bc2270bec32fe63d8eb766eb13762808a76eeb311dab3ed905307b30c 3 | size 9661432 4 | -------------------------------------------------------------------------------- /data/gltf-samples/Fox.glb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d97044e701822bac5a62696459b27d7b375aada5de8574ed4362edbba94771f7 3 | size 162852 4 | -------------------------------------------------------------------------------- /data/gltf-samples/SciFiHelmet.glb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:3952299759caf916113d76547c7fa32f62a352ee0f5b7c26316876bed1cda7e0 3 | size 30284708 4 | -------------------------------------------------------------------------------- /data/gltf-samples/ToyCar.glb: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b4527ffb4f16fe4ae322227b2485842173ae3f804609dade4430449507d2eb9c 3 | size 5805720 4 | -------------------------------------------------------------------------------- /devops/build-cpp-tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SRC=`pwd`/../src/cpp/vim 4 | 5 | echo Building C++ tests... 6 | 7 | g++ $SRC/test.cpp -o $SRC/test_app -std=c++17 | 8 | while IFS= read -r line 9 | do 10 | echo "$line" 11 | done 12 | 13 | chmod +x $SRC/test_app -------------------------------------------------------------------------------- /devops/check-nuget-version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z ${2+x} ]; then 4 | echo "The script expects 2 arguments: (1) project file path and (2) package name." 5 | exit 2 6 | fi 7 | 8 | __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 9 | ver=`bash ${__dir}/csproj-version.sh $1` 10 | 11 | if ! [ $? == 0 ]; then 12 | echo "Version couldn't be parsed." 13 | echo $ver 14 | exit 3 15 | fi 16 | 17 | if [ "$ver" == "" ]; then 18 | echo "Version not found." 19 | exit 4 20 | fi 21 | 22 | echo "Project version is ${ver}. Checking NuGet versions..." 23 | 24 | versions=`nuget list -AllVersions -IncludeDelisted -NonInteractive PackageId:$2 | awk '{print $2}'` 25 | 26 | # `nuget list` returns "No packages found." message 27 | if [ "$versions" = "packages" ]; then 28 | echo "No versions found." 29 | exit 0 30 | fi 31 | 32 | for nuget in $versions 33 | do 34 | echo "Version found $nuget" 35 | 36 | if [ $nuget == ${ver} ] || [ $nuget == "v${ver}" ] || ([ ${ver:0:1} == 'v' ] && [ $nuget == ${ver:1} ]) ; then 37 | echo "The NuGet version $nuget already exists. The package cannot be pushed." 38 | exit 1 39 | fi 40 | done -------------------------------------------------------------------------------- /devops/cs-tag-commit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z ${2+x} ]; then 4 | echo "The script expects 2 arguments: (1) project file path and (2) package name." 5 | exit 2 6 | fi 7 | 8 | __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 9 | ver=`bash ${__dir}/csproj-version.sh $1` 10 | 11 | if ! [ $? == 0 ]; then 12 | echo "Version couldn't be parsed." 13 | echo $ver 14 | exit 3 15 | fi 16 | 17 | package=`(echo "$2" | tr '[:upper:]' '[:lower:]')` # to lower 18 | package=${package#*.} # remove everything before . 19 | 20 | echo "Project version is ${ver}. Tagging cs_${package}_${ver}..." 21 | 22 | git tag cs_${package}_${ver} 23 | 24 | echo "Pushing tag..." 25 | 26 | git push origin cs_${package}_${ver} -------------------------------------------------------------------------------- /devops/csproj-version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z ${1+x} ]; then 4 | echo "The script expects 1 argument: the project file path." 5 | exit 2 6 | fi 7 | 8 | if ! [ -f $1 ]; then 9 | echo "Project file $1 doesn't exist." 10 | exit 1 11 | fi 12 | 13 | cat $1 |\ 14 | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+.*<\/Version>' |\ 15 | perl -pe 's///g and s/<\/Version>//g' -------------------------------------------------------------------------------- /devops/run-cpp-tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SRC=`pwd`/../src/cpp/vim 4 | 5 | bash build-cpp-tests.sh 6 | 7 | echo Running C++ tests... 8 | $SRC/test_app 9 | CODE=$? 10 | 11 | echo Cleaning up... 12 | rm $SRC/test_app 13 | 14 | exit $CODE -------------------------------------------------------------------------------- /devops/ts-tag-commit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z ${1+x} ]; then 4 | echo "The script expects 1 argument: package.json path." 5 | exit 2 6 | fi 7 | 8 | ver=`awk -F'"' '/"version": ".+"/{ print $4; exit; }' $1` 9 | 10 | echo "package.json version is ${ver}. Tagging ts_${ver}..." 11 | 12 | git tag ts_${ver} 13 | 14 | echo "Pushing tag..." 15 | 16 | git push origin ts_${ver} -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 VIMBuild, LLC. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/cpp/math3d/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # CMakeList.txt : CMake project for vim_math3d, include source and define 2 | # project specific logic here. 3 | # 4 | cmake_minimum_required (VERSION 3.10) 5 | 6 | set (PROJECT "vim_math_3d") 7 | project (${PROJECT}) 8 | 9 | # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR- /wd4091 /wd4065 /MP /bigobj") 10 | # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR /wd4091 /wd4065 /MP /bigobj") 11 | # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 /GL /arch:AVX2 /fp:fast") 12 | 13 | # Add source to this project's executable. 14 | set(SRCS 15 | "vim_math3d.cpp" 16 | "vim_math3d.h" 17 | ) 18 | 19 | add_executable (${PROJECT} ${SRCS}) 20 | 21 | set_property(TARGET ${PROJECT} PROPERTY CXX_STANDARD 17) 22 | 23 | # TODO: Add tests and install targets if needed. 24 | -------------------------------------------------------------------------------- /src/cpp/math3d/constants.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace vim::math3d::constants { 4 | const float tolerance = 0.0000001f; 5 | 6 | const double pi = 3.14159265358979323846; 7 | const double halfPi = pi / 2.0; 8 | const double twoPi = pi * 2.0; 9 | const double log10E = 0.434294481903251827651; 10 | const double log2E = 1.44269504088896340736; 11 | const double e = 2.71828182845904523536; 12 | 13 | const double radiansToDegrees = 57.295779513082320876798154814105; 14 | const double degreesToRadians = 0.017453292519943295769236907684886; 15 | const double oneTenthOfADegree = degreesToRadians / 10.0; 16 | 17 | // TODO: BUG: these two values are inverted dumb-dumb 18 | const double mmToFeet = 0.00328084; 19 | const double feetToMm = 1.0 / mmToFeet; 20 | }; 21 | -------------------------------------------------------------------------------- /src/cpp/math3d/experimental.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /src/cpp/math3d/random.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "hash.h" 4 | #include "structs.h" 5 | 6 | namespace vim::math3d::statelessRandom { 7 | template 8 | inline typename std::enable_if::value, T>::type 9 | random(int index, int seed = 0) { return (T)hash::combine(seed, index); } 10 | 11 | template 12 | inline T randomNumb(T min, T max, int index, int seed) { 13 | return (T)random(index, seed) / std::numeric_limits::max() * (max - min) + min; 14 | } 15 | 16 | template 17 | inline T randomNumb(int index, int seed = 0) { return randomNumb(0, 1, index, seed); } 18 | 19 | template 20 | inline Vector2 randomVector2(int index, int seed = 0) { 21 | return Vector2(randomNumb(index * 2, seed), randomNumb(index * 2 + 1, seed)); 22 | } 23 | 24 | template 25 | inline Vector3 randomVector3(int index, int seed = 0) { 26 | return Vector3(randomNumb(index * 3, seed), randomNumb(index * 3 + 1, seed), randomNumb(index * 3 + 2, seed)); 27 | } 28 | 29 | template 30 | inline Vector4 randomVector4(int index, int seed = 0) { 31 | return Vector4(randomNumb(index * 4, seed), randomNumb(index * 4 + 1, seed), randomNumb(index * 4 + 2, seed), randomNumb(index * 4 + 3, seed)); 32 | } 33 | } -------------------------------------------------------------------------------- /src/cpp/math3d/value_domain.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | //#include 5 | 6 | namespace vim::math3d 7 | { 8 | template 9 | class ValueDomain { 10 | public: 11 | static_assert(std::is_arithmetic::value, "T must be a numerical type"); 12 | 13 | const T Lower; 14 | const T Upper; 15 | 16 | ValueDomain(T lower, T upper): Lower(lower), Upper(upper) {} 17 | 18 | inline T normalize(T value) const { return std::clamp(value, Lower, Upper) / Upper; } 19 | }; 20 | } 21 | -------------------------------------------------------------------------------- /src/cpp/math3d/vim_math3d.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "constants.h" 4 | #include "math_ops.h" 5 | #include "value_domain.h" 6 | #include "hash.h" 7 | #include "random.h" 8 | #include "structs.h" 9 | #include "experimental.h" 10 | 11 | namespace vim::math3d { } -------------------------------------------------------------------------------- /src/cpp/vim/Vim.Cpp.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 6 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 7 | 8 | 9 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 10 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 11 | 12 | 13 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 14 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/cpp/vim/test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "test-object-model.cpp" 3 | 4 | int main(int num, char** args) 5 | { 6 | auto this_exe_path = normalize_path(std::string(args[0])); 7 | const auto repo_path = this_exe_path.erase(this_exe_path.rfind("src")); 8 | 9 | const auto object_model_result = test_object_model(repo_path); 10 | 11 | if (object_model_result != 0) 12 | return object_model_result; 13 | 14 | //TODO: test G3D here 15 | 16 | return 0; 17 | } -------------------------------------------------------------------------------- /src/cs/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimaec/vim-format/fc4a98e02e51ad595ef3e9b51d6223afbf9e53bc/src/cs/.gitkeep -------------------------------------------------------------------------------- /src/cs/bfast/Vim.BFast.Tests/Vim.BFast.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/cs/bfast/Vim.BFast/SeekContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace Vim.BFast 5 | { 6 | /// 7 | /// Manages a Stream's seek pointer within a given `using` scope. 8 | /// When the stream context is disposed, the seek position is reset 9 | /// to the original position when the object was created. 10 | /// 11 | public sealed class SeekContext : IDisposable 12 | { 13 | /// 14 | /// The seekable stream. 15 | /// 16 | public readonly Stream Stream; 17 | 18 | /// 19 | /// The original stream seek position when the object was created. 20 | /// 21 | public readonly long OriginalSeekPosition; 22 | 23 | /// 24 | /// Constructor. 25 | /// 26 | public SeekContext(Stream stream) 27 | { 28 | if (!stream.CanSeek) 29 | throw new ArgumentException("Stream must be seekable."); 30 | 31 | Stream = stream; 32 | OriginalSeekPosition = stream.Position; 33 | } 34 | 35 | /// 36 | /// Disposer. 37 | /// 38 | public void Dispose() 39 | => Stream.Seek(OriginalSeekPosition, SeekOrigin.Begin); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/cs/bfast/Vim.BFast/Vim.BFast.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | Vim.BFast 6 | https://github.com/vimaec/bfast 7 | https://github.com/vimaec/bfast 8 | GitHub 9 | true 10 | license.txt 11 | BFAST is a library for converting collections of named binary buffers to a single byte array for efficient cross-platform serialization and deserialization. 12 | 1.5.0.0 13 | 1.5.0.0 14 | 1.5.0 15 | true 16 | true 17 | true 18 | true 19 | snupkg 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | true 28 | 29 | 30 | 31 | 32 | True 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/cs/g3d/G3d.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1.6.1 4 | 1.5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/cs/g3d/Vim.G3d.AssimpWrapper/AssimpLoader.cs: -------------------------------------------------------------------------------- 1 | using Assimp; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using Vim.LinqArray; 6 | 7 | namespace Vim.G3d.AssimpWrapper 8 | { 9 | public static class AssimpLoader 10 | { 11 | public static AssimpContext Context = new AssimpContext(); 12 | 13 | public class AssimpNode 14 | { 15 | public int MeshIndex { get; } 16 | public Matrix4x4 Transform { get; } 17 | public AssimpNode(int index, Matrix4x4 transform) 18 | => (MeshIndex, Transform) = (index, transform); 19 | } 20 | 21 | public static IEnumerable GetNodes(this Scene scene) 22 | => scene == null || scene.RootNode == null 23 | ? Enumerable.Empty() 24 | : GetNodes(scene, scene.RootNode, scene.RootNode.Transform); 25 | 26 | public static IEnumerable GetNodes(this Scene scene, Node node, Matrix4x4 transform) 27 | => node.MeshIndices.Select(idx => new AssimpNode(idx, node.Transform)) 28 | .Concat(node.Children.SelectMany(c => GetNodes(scene, c, transform * c.Transform))); 29 | 30 | public static Scene Load(string filePath, bool triangulate = true) 31 | => Context.ImportFile(filePath, triangulate ? PostProcessSteps.Triangulate : PostProcessSteps.None); 32 | 33 | public static bool CanLoad(string filePath) 34 | => Context.IsImportFormatSupported(Path.GetExtension(filePath)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/cs/g3d/Vim.G3d.AssimpWrapper/Vim.G3d.AssimpWrapper.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | Vim.G3d.AssimpWrapper 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/cs/g3d/Vim.G3d.Tests/Resources/.gitignore: -------------------------------------------------------------------------------- 1 | ProjDir.txt -------------------------------------------------------------------------------- /src/cs/g3d/Vim.G3d.Tests/Vim.G3d.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | True 22 | True 23 | Resources.resx 24 | 25 | 26 | 27 | 28 | 29 | ResXFileCodeGenerator 30 | Resources.Designer.cs 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/cs/g3d/Vim.G3d/G3DBuilder.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Vim.LinqArray; 3 | using Vim.Math3d; 4 | 5 | namespace Vim.G3d 6 | { 7 | /// 8 | /// This is a helper class for constructing a G3D from individual attributes 9 | /// 10 | public class G3DBuilder 11 | { 12 | public readonly List Attributes = new List(); 13 | 14 | public G3D ToG3D(G3dHeader? header = null) 15 | => new G3D(Attributes, header ?? G3dHeader.Default); 16 | 17 | public G3DBuilder Add(GeometryAttribute attr) 18 | { 19 | Attributes.Add(attr); 20 | return this; 21 | } 22 | 23 | public G3DBuilder AddIndices(int[] indices) 24 | => Add(indices.ToIndexAttribute()); 25 | 26 | public G3DBuilder AddIndices(IArray indices) 27 | => Add(indices.ToIndexAttribute()); 28 | 29 | public G3DBuilder SetObjectFaceSize(int objectFaceSize) 30 | => Add(new[] { objectFaceSize }.ToIArray().ToObjectFaceSizeAttribute()); 31 | 32 | public G3DBuilder AddVertices(IArray vertices) 33 | => Add(vertices.ToPositionAttribute()); 34 | 35 | public IGeometryAttributes ToIGeometryAttributes() 36 | => new GeometryAttributes(Attributes); 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /src/cs/g3d/Vim.G3d/G3dMaterial.cs: -------------------------------------------------------------------------------- 1 | using Vim.Math3d; 2 | 3 | namespace Vim.G3d 4 | { 5 | public class G3dMaterial 6 | { 7 | public readonly G3D G3d; 8 | public readonly int Index; 9 | 10 | public G3dMaterial(G3D g3D, int index) 11 | { 12 | G3d = g3D; 13 | Index = index; 14 | } 15 | 16 | public Vector4 Color => G3d.MaterialColors[Index]; 17 | public float Glossiness => G3d?.MaterialGlossiness[Index] ?? 0f; 18 | public float Smoothness => G3d?.MaterialSmoothness[Index] ?? 0f; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/cs/g3d/Vim.G3d/G3dShape.cs: -------------------------------------------------------------------------------- 1 | using Vim.LinqArray; 2 | using Vim.Math3d; 3 | 4 | namespace Vim.G3d 5 | { 6 | public class G3dShape 7 | { 8 | public readonly G3D G3D; 9 | public readonly int Index; 10 | public readonly IArray Vertices; 11 | 12 | public int ShapeVertexOffset => G3D.ShapeVertexOffsets[Index]; 13 | public int NumVertices => G3D.ShapeVertexCounts[Index]; 14 | public Vector4 Color => G3D.ShapeColors[Index]; 15 | public float Width => G3D.ShapeWidths[Index]; 16 | 17 | public G3dShape(G3D parent, int index) 18 | { 19 | (G3D, Index) = (parent, index); 20 | Vertices = G3D.ShapeVertices?.SubArray(ShapeVertexOffset, NumVertices); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/cs/g3d/Vim.G3d/IGeometryAttributes.cs: -------------------------------------------------------------------------------- 1 | using Vim.LinqArray; 2 | 3 | namespace Vim.G3d 4 | { 5 | /// 6 | /// This is a read-only collection of G3D attributes. 7 | /// 8 | public interface IGeometryAttributes 9 | { 10 | int NumCornersPerFace { get; } 11 | int NumVertices { get; } 12 | int NumCorners { get; } 13 | int NumFaces { get; } 14 | int NumInstances { get; } 15 | int NumMeshes { get; } 16 | int NumShapeVertices { get; } 17 | int NumShapes { get; } 18 | 19 | IArray Attributes { get; } 20 | GeometryAttribute GetAttribute(string name); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/cs/linqarray/Vim.LinqArray.Tests/Vim.LinqArray.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/cs/linqarray/Vim.LinqArray/Vim.LinqArray.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | true 6 | Vim.LinqArray 7 | LinqArray is a library of efficient LINQ-style operation on immutable arrays. 8 | 9 | https://github.com/vimaec/linqarray 10 | https://github.com/vimaec/linqarray 11 | GitHub 12 | true 13 | license.txt 14 | 1.1.3 15 | true 16 | true 17 | true 18 | snupkg 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | true 27 | 28 | 29 | 30 | 31 | True 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/cs/math3d/.editorconfig: -------------------------------------------------------------------------------- 1 | [MathOps.cs] 2 | generated_code = true 3 | 4 | [Structs.cs] 5 | generated_code = true -------------------------------------------------------------------------------- /src/cs/math3d/Vim.Math3D.Tests/DVector3Tests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace Vim.Math3d.Tests 4 | { 5 | public class DVector3Tests 6 | { 7 | // A test for Cross (DVector3, DVector3) 8 | [Test] 9 | public void DVector3CrossTest() 10 | { 11 | var a = new DVector3(1.0d, 0.0d, 0.0d); 12 | var b = new DVector3(0.0d, 1.0d, 0.0d); 13 | 14 | var expected = new DVector3(0.0d, 0.0d, 1.0d); 15 | DVector3 actual; 16 | 17 | actual = MathOps.Cross(a, b); 18 | Assert.True(MathHelper.Equal(expected, actual), "Vector3f.Cross did not return the expected value."); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/cs/math3d/Vim.Math3D.Tests/Vim.Math3D.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/cs/math3d/Vim.Math3D/Constants.cs: -------------------------------------------------------------------------------- 1 | // MIT License 2 | // Copyright (C) 2019 VIMaec LLC. 3 | // Copyright (C) 2019 Ara 3D. Inc 4 | // https://ara3d.com 5 | // Copyright (C) The Mono.Xna Team 6 | // This file is subject to the terms and conditions defined in 7 | // file 'LICENSE.txt', which is part of this source code package. 8 | 9 | using System; 10 | 11 | namespace Vim.Math3d 12 | { 13 | public static class Constants 14 | { 15 | public static readonly Plane XYPlane = new Plane(Vector3.UnitZ, 0); 16 | public static readonly Plane XZPlane = new Plane(Vector3.UnitY, 0); 17 | public static readonly Plane YZPlane = new Plane(Vector3.UnitX, 0); 18 | 19 | public const float Pi = (float)Math.PI; 20 | public const float HalfPi = Pi / 2f; 21 | public const float TwoPi = Pi * 2f; 22 | public const float Tolerance = 0.0000001f; 23 | public const float Log10E = 0.4342945f; 24 | public const float Log2E = 1.442695f; 25 | public const float E = (float)Math.E; 26 | 27 | public const double RadiansToDegrees = 57.295779513082320876798154814105; 28 | public const double DegreesToRadians = 0.017453292519943295769236907684886; 29 | 30 | public const double OneTenthOfADegree = DegreesToRadians / 10; 31 | 32 | // TODO: BUG: these two values are inverted dumb-dumb 33 | public const double MmToFeet = 0.00328084; 34 | public const double FeetToMm = 1 / MmToFeet; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/cs/math3d/Vim.Math3D/ContainmentType.cs: -------------------------------------------------------------------------------- 1 | // MIT License 2 | // Copyright (C) 2019 VIMaec LLC. 3 | // Copyright (C) 2019 Ara 3D. Inc 4 | // https://ara3d.com 5 | // Copyright (C) The Mono.Xna Team 6 | // This file is subject to the terms and conditions defined in 7 | // file 'LICENSE.txt', which is part of this source code package. 8 | 9 | namespace Vim.Math3d 10 | { 11 | /// 12 | /// Defines how the bounding volumes intersects or contain one another. 13 | /// 14 | public enum ContainmentType 15 | { 16 | /// 17 | /// Indicates that there is no overlap between two bounding volumes. 18 | /// 19 | Disjoint, 20 | /// 21 | /// Indicates that one bounding volume completely contains another volume. 22 | /// 23 | Contains, 24 | /// 25 | /// Indicates that bounding volumes partially overlap one another. 26 | /// 27 | Intersects 28 | } 29 | } -------------------------------------------------------------------------------- /src/cs/math3d/Vim.Math3D/IMappable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Vim.Math3d 4 | { 5 | public interface IMappable 6 | { 7 | TContainer Map(Func f); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/cs/math3d/Vim.Math3D/IPoints.cs: -------------------------------------------------------------------------------- 1 | namespace Vim.Math3d 2 | { 3 | public interface IPoints 4 | { 5 | int NumPoints { get; } 6 | Vector3 GetPoint(int n); 7 | } 8 | 9 | public interface IPoints2D 10 | { 11 | int NumPoints { get; } 12 | Vector2 GetPoint(int n); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/cs/math3d/Vim.Math3D/LinqUtil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Vim.Math3d 6 | { 7 | public static class LinqUtil 8 | { 9 | public static AABox ToAABox(this IEnumerable self) 10 | => AABox.Create(self); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/cs/math3d/Vim.Math3D/PlaneIntersectionType.cs: -------------------------------------------------------------------------------- 1 | // MIT License 2 | // Copyright (C) 2019 VIMaec LLC. 3 | // Copyright (C) 2019 Ara 3D. Inc 4 | // https://ara3d.com 5 | // Copyright (C) The Mono.Xna Team 6 | // This file is subject to the terms and conditions defined in 7 | // file 'LICENSE.txt', which is part of this source code package. 8 | 9 | namespace Vim.Math3d 10 | { 11 | /// 12 | /// Defines the intersection between a Plane and a bounding volume. 13 | /// 14 | public enum PlaneIntersectionType 15 | { 16 | /// 17 | /// There is no intersection, the bounding volume is in the negative half space of the plane. 18 | /// 19 | Front, 20 | /// 21 | /// There is no intersection, the bounding volume is in the positive half space of the plane. 22 | /// 23 | Back, 24 | /// 25 | /// The plane is intersected. 26 | /// 27 | Intersecting 28 | } 29 | } -------------------------------------------------------------------------------- /src/cs/math3d/Vim.Math3D/Quad.cs: -------------------------------------------------------------------------------- 1 | // MIT License 2 | // Copyright (C) 2019 VIMaec LLC. 3 | // Copyright (C) 2019 Ara 3D. Inc 4 | // https://ara3d.com 5 | 6 | using System; 7 | 8 | namespace Vim.Math3d 9 | { 10 | public partial struct Quad : ITransformable3D, IPoints, IMappable 11 | { 12 | public Quad Transform(Matrix4x4 mat) => Map(x => x.Transform(mat)); 13 | public int NumPoints => 4; 14 | public Vector3 GetPoint(int n) => n == 0 ? A : n == 1 ? B : n == 2 ? C : D; 15 | public Quad Map(Func f) => new Quad(f(A), f(B), f(C), f(D)); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/cs/math3d/Vim.Math3D/Random.cs: -------------------------------------------------------------------------------- 1 | // MIT License 2 | // Copyright (C) 2019 VIMaec LLC. 3 | // Copyright (C) 2019 Ara 3D. Inc 4 | // https://ara3d.com 5 | 6 | namespace Vim.Math3d 7 | { 8 | public static class StatelessRandom 9 | { 10 | public static uint RandomUInt(int index, int seed = 0) 11 | => (uint)Hash.Combine(seed, index); 12 | 13 | public static int RandomInt(int index, int seed = 0) 14 | => Hash.Combine(seed, index); 15 | 16 | public static float RandomFloat(float min, float max, int index, int seed) 17 | => (float)RandomUInt(index, seed) / uint.MaxValue * (max - min) + min; 18 | 19 | public static float RandomFloat(int index, int seed = 0) 20 | => RandomFloat(0, 1, index, seed); 21 | 22 | public static Vector2 RandomVector2(int index, int seed = 0) 23 | => new Vector2( 24 | RandomFloat(index * 2, seed), 25 | RandomFloat(index * 2 + 1, seed)); 26 | 27 | public static Vector3 RandomVector3(int index, int seed = 0) 28 | => new Vector3( 29 | RandomFloat(index * 3, seed), 30 | RandomFloat(index * 3 + 1, seed), 31 | RandomFloat(index * 3 + 2, seed)); 32 | 33 | public static Vector4 RandomVector4(int index, int seed = 0) 34 | => new Vector4( 35 | RandomFloat(index * 4, seed), 36 | RandomFloat(index * 4 + 1, seed), 37 | RandomFloat(index * 4 + 2, seed), 38 | RandomFloat(index * 4 + 3, seed)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/cs/math3d/Vim.Math3D/Triangle2D.cs: -------------------------------------------------------------------------------- 1 | // MIT License 2 | // Copyright (C) 2019 VIMaec LLC. 3 | // Copyright (C) 2019 Ara 3D. Inc 4 | // https://ara3d.com 5 | // This file is subject to the terms and conditions defined in 6 | // file 'LICENSE.txt', which is part of this source code package. 7 | 8 | namespace Vim.Math3d 9 | { 10 | public partial struct Triangle2D 11 | { 12 | public int Count => 3; 13 | 14 | public Vector2 this[int n] => n == 0 ? A : n == 1 ? B : C; 15 | 16 | // Compute the signed area of a triangle. 17 | public float Area => 0.5f * (A.X * (C.Y - B.Y) + B.X * (A.Y - C.Y) + C.X * (B.Y - A.Y)); 18 | 19 | // Test if a given point p2 is on the left side of the line formed by p0-p1. 20 | public static bool OnLeftSideOfLine(Vector2 p0, Vector2 p1, Vector2 p2) 21 | => new Triangle2D(p0, p2, p1).Area > 0; 22 | 23 | // Test if a given point is inside a given triangle in R2. 24 | public bool Contains(Vector2 pp) 25 | { 26 | // Point in triangle test using barycentric coordinates 27 | var v0 = B - A; 28 | var v1 = C - A; 29 | var v2 = pp - A; 30 | 31 | var dot00 = v0.Dot(v0); 32 | var dot01 = v0.Dot(v1); 33 | var dot02 = v0.Dot(v2); 34 | var dot11 = v1.Dot(v1); 35 | var dot12 = v1.Dot(v2); 36 | 37 | var invDenom = 1f / (dot00 * dot11 - dot01 * dot01); 38 | dot11 = (dot11 * dot02 - dot01 * dot12) * invDenom; 39 | dot00 = (dot00 * dot12 - dot01 * dot02) * invDenom; 40 | 41 | return (dot11 > 0) && (dot00 > 0) && (dot11 + dot00 < 1); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/cs/math3d/Vim.Math3D/ValueDomain.cs: -------------------------------------------------------------------------------- 1 | namespace Vim.Math3d 2 | { 3 | public class ValueDomain 4 | { 5 | public readonly double Lower; 6 | public readonly double Upper; 7 | 8 | public ValueDomain(double lower, double upper) 9 | => (Lower, Upper) = (lower, upper); 10 | 11 | public double Normalize(double value) 12 | => value.Clamp(Lower, Upper) / Upper; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/.gitignore: -------------------------------------------------------------------------------- 1 | ############### 2 | # folder # 3 | ############### 4 | /**/DROP/ 5 | /**/TEMP/ 6 | /**/packages/ 7 | /**/bin/ 8 | /**/obj/ 9 | _site 10 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/api/.gitignore: -------------------------------------------------------------------------------- 1 | ############### 2 | # temp file # 3 | ############### 4 | *.yml 5 | .manifest 6 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/api/index.md: -------------------------------------------------------------------------------- 1 | # Vim.Math3D API Documentation 2 | 3 | Vim.Math3D is a portable, safe, and efficient 3D math library from VIM written in C# targeting .NET Standard 2.0 without any dependencies. 4 | 5 | Visit the Vim.Math3D GitHub Repo. 6 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/articles/csharp-math-libraries.md: -------------------------------------------------------------------------------- 1 | ## Related Libraries 2 | 3 | * [System.Numerics](https://referencesource.microsoft.com/#System.Numerics,namespaces) 4 | * [SharpDX Mathematics](https://github.com/sharpdx/SharpDX/tree/master/Source/SharpDX.Mathematics) 5 | * [MonoGame](https://github.com/MonoGame/MonoGame) 6 | * [Math.NET Spatial](https://github.com/mathnet/mathnet-spatial) 7 | * [Math.NET Numerics](https://github.com/mathnet/mathnet-numerics) 8 | * [Unity.Mathematics](https://github.com/Unity-Technologies/Unity.Mathematics) 9 | * [Unity Reference](https://github.com/Unity-Technologies/UnityCsReference/tree/master/Runtime/Export) 10 | * [Abacus](https://github.com/sungiant/abacus) 11 | * [Geometry3Sharp](https://github.com/gradientspace/geometry3Sharp) 12 | * [FNA-XNA](https://github.com/FNA-XNA/FNA/tree/master/src) 13 | * [Stride](https://github.com/stride3d/stride/tree/master/sources/core/Stride.Core.Mathematics) 14 | * [A Vector Type for C# - R Potter via Code Project](https://www.codeproject.com/Articles/17425/A-Vector-Type-for-C) 15 | * [Godot Engine C# Libraries](https://github.com/godotengine/godot/tree/master/modules/mono/glue/GodotSharp/GodotSharp/Core) 16 | * [GeometRi - Simple and lightweight computational geometry library for .Net](https://github.com/RiSearcher/GeometRi.CSharp) 17 | * [Veldrid ](https://github.com/mellinoe/veldrid/tree/master/src/Veldrid.Utilities) -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/articles/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to Vim.Math3D 2 | 3 | Vim.Math3d is a C# library that exposes several types and algorithms to help develop 2D and 3D computer graphics software. 4 | 5 | # Immutability of Structs 6 | 7 | All structs in Math3D are immutable, meaning that fields are readonly and can only be set once upon construction. 8 | 9 | # Vector3 Struct 10 | 11 | The most commonly used type in the Vim.Math3d library is the Vector3 struct which consists of 3 readonly floats: 12 | X, Y, and Z. A Vector3 can be used to express a position in 3-dimensional space, or a vector representing a direction 13 | and magnitude (e.g. velocity). 14 | 15 | The length or magnitude of a Vector is determined by computing the square root of the sum of each component squared. 16 | 17 | In other words: 18 | 19 | ``` 20 | float Length => SumSqrComponents().Sqrt(); 21 | ``` 22 | 23 | # Floating Point Extension Functions 24 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/articles/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Introduction 2 | href: intro.md 3 | - name: C# Math Libraries 4 | href: csharp-math-libraries.md 5 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/filterConfig.yml: -------------------------------------------------------------------------------- 1 | apiRules: 2 | - exclude: 3 | uid: Vim.Experimental 4 | type: Namespace 5 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimaec/vim-format/fc4a98e02e51ad595ef3e9b51d6223afbf9e53bc/src/cs/math3d/docfx_project/images/favicon.ico -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/images/vim_color_logo_landscape_whitetext_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimaec/vim-format/fc4a98e02e51ad595ef3e9b51d6223afbf9e53bc/src/cs/math3d/docfx_project/images/vim_color_logo_landscape_whitetext_small.png -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/material/partials/head.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{!Copyright (c) Oscar Vasquez. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} 2 | 3 | 4 | 5 | 6 | {{#title}}{{title}}{{/title}}{{^title}}{{>partials/title}}{{/title}} {{#_appTitle}}| {{_appTitle}} {{/_appTitle}} 7 | 8 | 9 | 10 | {{#_description}}{{/_description}} 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | {{#_noindex}}{{/_noindex}} 19 | {{#_enableSearch}}{{/_enableSearch}} 20 | {{#_enableNewTab}}{{/_enableNewTab}} 21 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/_affix.liquid: -------------------------------------------------------------------------------- 1 | {% comment -%}Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.{% endcomment -%} 2 | 26 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/_breadcrumb.liquid: -------------------------------------------------------------------------------- 1 | {% comment -%}Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.{% endcomment -%} 2 | 9 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/_footer.liquid: -------------------------------------------------------------------------------- 1 | {% comment -%}Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.{% endcomment -%} 2 |
3 |
4 | 16 |
17 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/_head.liquid: -------------------------------------------------------------------------------- 1 | {% comment -%}Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.{% endcomment -%} 2 | 3 | 4 | 5 | {%- if title and _appTitle -%} 6 | {{title}} | {{appTitle}} 7 | 8 | {%- else -%} 9 | {%- if title or _appTitle -%} 10 | {{title}}{{appTitle}} 11 | 12 | {%- endif -%} 13 | {%- endif -%} 14 | 15 | 16 | {%- if _description -%} 17 | 18 | {%- endif -%} 19 | {%- if _appFaviconPath -%} 20 | 21 | {%- else -%} 22 | 23 | {%- endif -%} 24 | 25 | 26 | 27 | 28 | 29 | {%- if _noindex -%} 30 | 31 | {%- endif -%} 32 | {%- if _enableSearch -%} 33 | 34 | {%- endif -%} 35 | {%- if _enableNewTab -%} 36 | 37 | {%- endif -%} 38 | 39 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/_logo.liquid: -------------------------------------------------------------------------------- 1 | {% comment -%}Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.{% endcomment -%} 2 | 3 | {%- if _appLogoPath -%} 4 | 5 | {%- else -%} 6 | 7 | {%- endif -%} 8 | 9 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/_navbar.liquid: -------------------------------------------------------------------------------- 1 | {% comment -%}Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.{% endcomment -%} 2 | 22 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/_scripts.liquid: -------------------------------------------------------------------------------- 1 | {% comment -%}Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.{% endcomment -%} 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/_toc.liquid: -------------------------------------------------------------------------------- 1 | {% comment -%}Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.{% endcomment -%} 2 | 8 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/affix.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} 2 | 3 | 27 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/breadcrumb.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} 2 | 3 | 10 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/customMREFContent.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} 2 | {{!Add your own custom template for the content for ManagedReference here}} -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/dd-li.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{#items}} 2 |
  • {{name}}
  • 3 | {{/items}} 4 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/enum.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} 2 | 3 | {{>partials/class.header}} 4 | {{#children}} 5 |

    {{>partials/classSubtitle}}

    6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | {{#children}} 15 | 16 | 17 | 18 | 19 | {{/children}} 20 | 21 |
    {{__global.name}}{{__global.description}}
    {{name.0.value}}{{{summary}}}
    22 | {{/children}} 23 | {{#seealso.0}} 24 |
    {{__global.seealso}}
    25 |
    26 | {{/seealso.0}} 27 | {{#seealso}} 28 | {{#isCref}} 29 |
    {{{type.specName.0.value}}}
    30 | {{/isCref}} 31 | {{^isCref}} 32 |
    {{{url}}}
    33 | {{/isCref}} 34 | {{/seealso}} 35 | {{#seealso.0}} 36 |
    37 | {{/seealso.0}} 38 | {{#extensionMethods.0}} 39 |

    {{__global.extensionMethods}}

    40 | {{/extensionMethods.0}} 41 | {{#extensionMethods}} 42 |
    43 | {{#definition}} 44 | 45 | {{/definition}} 46 | {{^definition}} 47 | 48 | {{/definition}} 49 |
    50 | {{/extensionMethods}} 51 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/footer.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} 2 | 3 |
    4 |
    5 | 14 |
    15 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/head.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} 2 | 3 | 4 | 5 | 6 | {{#title}}{{title}}{{/title}}{{^title}}{{>partials/title}}{{/title}} {{#_appTitle}}| {{_appTitle}} {{/_appTitle}} 7 | 8 | 9 | 10 | {{#_description}}{{/_description}} 11 | 12 | 13 | 14 | 15 | 16 | 17 | {{#_noindex}}{{/_noindex}} 18 | {{#_enableSearch}}{{/_enableSearch}} 19 | {{#_enableNewTab}}{{/_enableNewTab}} 20 | 21 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/li.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} 2 | 3 | 31 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/logo.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/namespace.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} 2 | 3 |

    {{>partials/title}}

    4 |
    {{{summary}}}
    5 |
    {{{conceptual}}}
    6 |
    {{{remarks}}}
    7 | {{#children}} 8 |

    {{>partials/namespaceSubtitle}}

    9 | {{#children}} 10 |

    11 |
    {{{summary}}}
    12 | {{/children}} 13 | {{/children}} 14 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/navbar.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} 2 | 3 | 23 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/rest.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} 2 | 3 |

    {{name}}

    4 | {{#summary}} 5 |
    {{{summary}}}
    6 | {{/summary}} 7 | {{#description}} 8 |
    {{{description}}}
    9 | {{/description}} 10 | {{#conceptual}} 11 |
    {{{conceptual}}}
    12 | {{/conceptual}} 13 | {{#tags}} 14 |

    {{name}}

    15 | {{#description}} 16 |
    {{{description}}}
    17 | {{/description}} 18 | {{#conceptual}} 19 |
    {{{conceptual}}}
    20 | {{/conceptual}} 21 | {{#children}} 22 | {{>partials/rest.child}} 23 | {{/children}} 24 | {{/tags}} 25 | {{!if some children are not tagged while other children are tagged, add default title}} 26 | {{#children.0}} 27 | {{#isTagLayout}} 28 |

    Other APIs

    29 | {{/isTagLayout}} 30 | {{/children.0}} 31 | {{#children}} 32 | {{>partials/rest.child}} 33 | {{/children}} 34 | {{#footer}} 35 | 36 | {{/footer}} 37 | 38 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/scripts.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/searchResults.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} 2 | 3 |
    4 |
    {{__global.searchResults}}
    5 |
    6 |

    7 |
    8 |
      9 |
      10 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/title.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} 2 | {{#inPackage}} 3 | Package {{name.0.value}} 4 | {{/inPackage}} 5 | {{#inNamespace}} 6 | Namespace {{name.0.value}} 7 | {{/inNamespace}} 8 | {{#inClass}} 9 | Class {{name.0.value}} 10 | {{/inClass}} 11 | {{#inStruct}} 12 | Struct {{name.0.value}} 13 | {{/inStruct}} 14 | {{#inInterface}} 15 | Interface {{name.0.value}} 16 | {{/inInterface}} 17 | {{#inEnum}} 18 | Enum {{name.0.value}} 19 | {{/inEnum}} 20 | {{#inDelegate}} 21 | Delegate {{name.0.value}} 22 | {{/inDelegate}} 23 | {{#inConstructor}} 24 | Constructor {{name.0.value}} 25 | {{/inConstructor}} 26 | {{#inField}} 27 | Field {{name.0.value}} 28 | {{/inField}} 29 | {{#inProperty}} 30 | Property {{name.0.value}} 31 | {{/inProperty}} 32 | {{#inMethod}} 33 | Method {{name.0.value}} 34 | {{/inMethod}} 35 | {{#inEvent}} 36 | Event {{name.0.value}} 37 | {{/inEvent}} 38 | {{#inOperator}} 39 | Operator {{name.0.value}} 40 | {{/inOperator}} 41 | {{#inEii}} 42 | Explict Interface Implementation {{name.0.value}} 43 | {{/inEii}} 44 | {{#inVariable}} 45 | Variable {{name.0.value}} 46 | {{/inVariable}} 47 | {{#inTypeAlias}} 48 | Type Alias {{name.0.value}} 49 | {{/inTypeAlias}} -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/toc.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} 2 | 3 | 9 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/uref/enum.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} 2 | 3 | {{>partials/uref/class.header}} 4 | {{#children}} 5 |

      {{>partials/classSubtitle}}

      6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | {{#children}} 15 | 16 | 17 | 18 | 19 | {{/children}} 20 | 21 |
      {{__global.name}}{{__global.description}}
      {{name.0.value}}{{{summary}}}
      22 | {{/children}} 23 | {{#extensionMethods.0}} 24 |

      {{__global.extensionMethods}}

      25 | {{/extensionMethods.0}} 26 | {{#extensionMethods}} 27 |
      28 | {{#definition}} 29 | 30 | {{/definition}} 31 | {{^definition}} 32 | 33 | {{/definition}} 34 |
      35 | {{/extensionMethods}} 36 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/uref/inheritance.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{#inheritance}} 2 | {{>partials/uref/inheritance}} 3 | {{/inheritance}} 4 |
      {{{type.specName.0.value}}}
      5 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/partials/uref/parameters.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} 2 | 3 | {{#properties.0}} 4 |
      Properties
      5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | {{/properties.0}} 15 | {{#properties}} 16 | 17 | 18 | 19 | 23 | 24 | {{/properties}} 25 | {{#properties.0}} 26 | 27 |
      {{__global.type}}{{__global.name}}{{__global.description}}
      {{{type.specName.0.value}}}{{{id}}} 20 | {{{description}}} 21 | {{>partials/parameters}} 22 |
      28 | {{/properties.0}} -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/old-vim/styles/main.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimaec/vim-format/fc4a98e02e51ad595ef3e9b51d6223afbf9e53bc/src/cs/math3d/docfx_project/templates/old-vim/styles/main.css -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/vim/VIM logo FULL COLOR landscape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimaec/vim-format/fc4a98e02e51ad595ef3e9b51d6223afbf9e53bc/src/cs/math3d/docfx_project/templates/vim/VIM logo FULL COLOR landscape.png -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/vim/VIM logo FULL COLOR landscape@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimaec/vim-format/fc4a98e02e51ad595ef3e9b51d6223afbf9e53bc/src/cs/math3d/docfx_project/templates/vim/VIM logo FULL COLOR landscape@2x.png -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/vim/VIM logo WHITE landscape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimaec/vim-format/fc4a98e02e51ad595ef3e9b51d6223afbf9e53bc/src/cs/math3d/docfx_project/templates/vim/VIM logo WHITE landscape.png -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/vim/VIM logo WHITE landscape@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimaec/vim-format/fc4a98e02e51ad595ef3e9b51d6223afbf9e53bc/src/cs/math3d/docfx_project/templates/vim/VIM logo WHITE landscape@2x.png -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/vim/VIM logo WHITE@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimaec/vim-format/fc4a98e02e51ad595ef3e9b51d6223afbf9e53bc/src/cs/math3d/docfx_project/templates/vim/VIM logo WHITE@2x.png -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/vim/partials/head.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{!Copyright (c) Oscar Vasquez. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} 2 | 3 | 4 | 5 | 6 | {{#title}}{{title}}{{/title}}{{^title}}{{>partials/title}}{{/title}} {{#_appTitle}}| {{_appTitle}} {{/_appTitle}} 7 | 8 | 9 | 10 | {{#_description}}{{/_description}} 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | {{#_noindex}}{{/_noindex}} 19 | {{#_enableSearch}}{{/_enableSearch}} 20 | {{#_enableNewTab}}{{/_enableNewTab}} 21 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/templates/vim/partials/logo.tmpl.partial: -------------------------------------------------------------------------------- 1 | {{!Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.}} 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/cs/math3d/docfx_project/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Articles 2 | href: articles/ 3 | - name: Api Documentation 4 | href: api/ -------------------------------------------------------------------------------- /src/cs/math3d/docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimaec/vim-format/fc4a98e02e51ad595ef3e9b51d6223afbf9e53bc/src/cs/math3d/docs/favicon.ico -------------------------------------------------------------------------------- /src/cs/math3d/docs/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimaec/vim-format/fc4a98e02e51ad595ef3e9b51d6223afbf9e53bc/src/cs/math3d/docs/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /src/cs/math3d/docs/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimaec/vim-format/fc4a98e02e51ad595ef3e9b51d6223afbf9e53bc/src/cs/math3d/docs/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /src/cs/math3d/docs/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimaec/vim-format/fc4a98e02e51ad595ef3e9b51d6223afbf9e53bc/src/cs/math3d/docs/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /src/cs/math3d/docs/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimaec/vim-format/fc4a98e02e51ad595ef3e9b51d6223afbf9e53bc/src/cs/math3d/docs/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /src/cs/math3d/docs/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimaec/vim-format/fc4a98e02e51ad595ef3e9b51d6223afbf9e53bc/src/cs/math3d/docs/images/favicon.ico -------------------------------------------------------------------------------- /src/cs/math3d/docs/images/vim_color_logo_landscape_whitetext_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimaec/vim-format/fc4a98e02e51ad595ef3e9b51d6223afbf9e53bc/src/cs/math3d/docs/images/vim_color_logo_landscape_whitetext_small.png -------------------------------------------------------------------------------- /src/cs/math3d/docs/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | Created by Docfx 9 | 10 | 12 | 15 | 21 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/cs/math3d/docs/styles/main.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information. 2 | -------------------------------------------------------------------------------- /src/cs/samples/Vim.Gltf.Converter.Tests/Vim.Gltf.Converter.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/cs/samples/Vim.Gltf.Converter/Vim.Gltf.Converter.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/cs/samples/Vim.JsonDigest.AzureFunction/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Hosting; 2 | 3 | var host = new HostBuilder() 4 | .ConfigureFunctionsWorkerDefaults() 5 | .Build(); 6 | 7 | host.Run(); -------------------------------------------------------------------------------- /src/cs/samples/Vim.JsonDigest.AzureFunction/Properties/serviceDependencies.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "appInsights1": { 4 | "type": "appInsights" 5 | }, 6 | "storage1": { 7 | "type": "storage", 8 | "connectionId": "AzureWebJobsStorage" 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /src/cs/samples/Vim.JsonDigest.AzureFunction/Properties/serviceDependencies.local.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "appInsights1": { 4 | "type": "appInsights.sdk" 5 | }, 6 | "storage1": { 7 | "type": "storage.emulator", 8 | "connectionId": "AzureWebJobsStorage" 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /src/cs/samples/Vim.JsonDigest.AzureFunction/Vim.JsonDigest.AzureFunction.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | v4 5 | Exe 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | PreserveNewest 20 | 21 | 22 | PreserveNewest 23 | Never 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/cs/samples/Vim.JsonDigest.AzureFunction/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "logging": { 4 | "applicationInsights": { 5 | "samplingSettings": { 6 | "isEnabled": true, 7 | "excludedTypes": "Request" 8 | } 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /src/cs/samples/Vim.JsonDigest.AzureFunction/local.settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "IsEncrypted": false, 3 | "Values": { 4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true", 5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated" 6 | } 7 | } -------------------------------------------------------------------------------- /src/cs/samples/Vim.JsonDigest.Tests/Vim.JsonDigest.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/cs/samples/Vim.JsonDigest/Vim.JsonDigest.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/cs/util/Vim.Util.Logging.Serilog/SerilogLoggerAdapter.cs: -------------------------------------------------------------------------------- 1 | using SerilogLogger = Serilog.Core.Logger; 2 | using SerilogLogEventLevel = Serilog.Events.LogEventLevel; 3 | 4 | namespace Vim.Util.Logging.Serilog 5 | { 6 | public class SerilogLoggerAdapter : ILogger 7 | { 8 | public readonly SerilogLogger Logger; 9 | 10 | public SerilogLoggerAdapter(SerilogLogger logger) 11 | => Logger = logger; 12 | 13 | public ILogger Log(string message = "", LogLevel level = LogLevel.Trace) 14 | { 15 | Logger.Write(level.ToSerilogLogEventLevel(), message); 16 | return this; 17 | } 18 | } 19 | 20 | public static class SerilogExtensions 21 | { 22 | public static SerilogLogEventLevel ToSerilogLogEventLevel(this LogLevel level) 23 | { 24 | switch (level) 25 | { 26 | case LogLevel.Debug: 27 | return SerilogLogEventLevel.Debug; 28 | case LogLevel.Warning: 29 | return SerilogLogEventLevel.Warning; 30 | case LogLevel.Error: 31 | return SerilogLogEventLevel.Error; 32 | case LogLevel.Critical: 33 | return SerilogLogEventLevel.Fatal; 34 | case LogLevel.Trace: 35 | case LogLevel.Information: 36 | case LogLevel.None: 37 | default: 38 | return SerilogLogEventLevel.Information; 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/cs/util/Vim.Util.Logging.Serilog/Vim.Util.Logging.Serilog.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/cs/util/Vim.Util.Tests/MD5Tests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace Vim.Util.Tests 4 | { 5 | [TestFixture] 6 | // ReSharper disable once InconsistentNaming 7 | public static class MD5Tests 8 | { 9 | [Test] 10 | public static void TestMD5Hashes() 11 | { 12 | const string content = "I'm a little teapot!"; 13 | 14 | var rawHash = content.ToBytesUtf8().MD5Hash(); 15 | var md5base64 = content.MD5HashAsBase64(); 16 | var md5Hex = content.MD5HashAsHex(); 17 | 18 | Assert.AreEqual(rawHash.ToBase64(), md5base64); 19 | Assert.AreEqual(rawHash.ToHex(), md5Hex); 20 | Assert.AreEqual(md5Hex, md5base64.Base64ToHex()); 21 | 22 | Assert.IsTrue(MD5Extensions.IsMD5HexString(md5Hex)); 23 | Assert.IsTrue(MD5Extensions.IsMD5HexString(md5base64.Base64ToHex())); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/cs/util/Vim.Util.Tests/Resources/.gitignore: -------------------------------------------------------------------------------- 1 | ProjDir.txt 2 | -------------------------------------------------------------------------------- /src/cs/util/Vim.Util.Tests/ShellProcess.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.IO; 4 | 5 | namespace Vim.Util.Tests; 6 | 7 | /// 8 | /// A utility class to automate command line processes. 9 | /// 10 | public abstract class ShellProcess 11 | { 12 | public const string DefaultConfig = 13 | #if DEBUG 14 | "Debug"; 15 | #else 16 | "Release"; 17 | #endif 18 | 19 | public abstract string GetExePath(string projectConfig); 20 | 21 | public Process StartProcess(T options, string workingDirectory = null, string projectConfig = DefaultConfig) 22 | { 23 | var argStr = string.Join(" ", options.ToArgList()); 24 | return StartProcess(argStr, workingDirectory, projectConfig); 25 | } 26 | 27 | public Process StartProcess(string argStr = null, string workingDirectory = null, string projectConfig = DefaultConfig) 28 | { 29 | var exePath = GetExePath(projectConfig); 30 | if (!File.Exists(exePath)) 31 | throw new Exception($"Executable not found: {exePath}"); 32 | 33 | var startInfo = new ProcessStartInfo { FileName = exePath, Arguments = argStr ?? "", UseShellExecute = true }; 34 | if (workingDirectory != null) 35 | startInfo.WorkingDirectory = workingDirectory; 36 | 37 | var process = new Process { StartInfo = startInfo }; 38 | 39 | process.Start(); 40 | 41 | return process; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/cs/util/Vim.Util.Tests/Vim.Util.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | True 22 | True 23 | Resources.resx 24 | 25 | 26 | 27 | 28 | 29 | ResXFileCodeGenerator 30 | Resources.Designer.cs 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/cs/util/Vim.Util.Tests/VimFormatRepoPaths.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Linq; 3 | 4 | namespace Vim.Util.Tests 5 | { 6 | /// 7 | /// A global interface to the repository's path configurations. 8 | /// 9 | public static class VimFormatRepoPaths 10 | { 11 | 12 | /// 13 | /// This value ProjDir is set by a pre-build step to our projects folder 14 | /// We use it to set our Repo dir (which is the parent of this folder) 15 | /// 16 | public static readonly string ProjDir = new DirectoryInfo(Properties.Resources.ProjDir.Trim()).FullName; 17 | 18 | public static string RootDir => Path.Combine(ProjDir, "..", "..", "..", ".."); 19 | public static string DocsDir => Path.Combine(RootDir, "docs"); 20 | public static string SrcDir => Path.Combine(RootDir, "src"); 21 | public static string OutDir => Path.Combine(RootDir, "out"); 22 | public static string DataDir => Path.Combine(RootDir, "data"); 23 | 24 | /// 25 | /// Returns the file path to the highest versioned mechanical room file among the version snapshots. 26 | /// 27 | public static string GetLatestWolfordResidenceVim() 28 | { 29 | var matchingVim = Directory.GetFiles(DataDir, "Wolford_Residence*.vim", SearchOption.AllDirectories).FirstOrDefault(); 30 | 31 | if (matchingVim == null) 32 | throw new FileNotFoundException($"Could not find the latest Wolford Residence VIM."); 33 | 34 | return matchingVim; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/cs/util/Vim.Util/ArrayEqualityComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Vim.Util 5 | { 6 | public class ArrayEqualityComparer : IEqualityComparer where T : IEquatable 7 | { 8 | public bool Equals(T[] x, T[] y) 9 | { 10 | if (x == y) return true; 11 | if (x == null || y == null) return false; 12 | if (x.Length != y.Length) return false; 13 | for (var i = 0; i < x.Length; ++i) 14 | { 15 | if (!x[i].Equals(y[i])) 16 | return false; 17 | } 18 | 19 | return true; 20 | } 21 | 22 | public int GetHashCode(T[] obj) => obj.GetHashCode(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/cs/util/Vim.Util/Disposer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Vim.Util 4 | { 5 | public sealed class Disposer : IDisposable 6 | { 7 | readonly Action OnDispose; 8 | 9 | public Disposer(Action onDispose) 10 | => OnDispose = onDispose; 11 | 12 | public void Dispose() 13 | => OnDispose(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/cs/util/Vim.Util/Either.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Vim.Util 4 | { 5 | /// 6 | /// Contains either a Left object or a Right object. 7 | /// 8 | public class Either 9 | { 10 | public readonly TL Left; 11 | public readonly TR Right; 12 | public readonly bool IsLeft; 13 | 14 | public Either(TL left) 15 | { 16 | Left = left; 17 | IsLeft = true; 18 | } 19 | 20 | public Either(TR right) 21 | { 22 | Right = right; 23 | IsLeft = false; 24 | } 25 | 26 | public T Match(Func leftFunc, Func rightFunc) 27 | => IsLeft ? leftFunc(Left) : rightFunc(Right); 28 | 29 | public static implicit operator Either(TL left) => new Either(left); 30 | 31 | public static implicit operator Either(TR right) => new Either(right); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/cs/util/Vim.Util/EnumWithDescription.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Linq; 5 | 6 | namespace Vim.Util 7 | { 8 | public class EnumWithDescription 9 | { 10 | public Enum Value { get; set; } 11 | 12 | public string Description { get; set; } 13 | } 14 | 15 | public static class EnumWithDescriptionExtensions 16 | { 17 | public static string Description(this Enum value) 18 | { 19 | var attributes = value.GetType().GetField(value.ToString())?.GetCustomAttributes(typeof(DescriptionAttribute), false); 20 | return (attributes?.FirstOrDefault() as DescriptionAttribute)?.Description ?? value.ToString(); 21 | } 22 | 23 | public static IEnumerable GetAllValuesAndDescriptions(Type t) 24 | { 25 | return !t.IsEnum 26 | ? throw new ArgumentException($"{nameof(t)} must be an enum type") 27 | : Enum.GetValues(t).Cast() 28 | .Select((e) => new EnumWithDescription { Value = e, Description = e.Description() }).ToList(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/cs/util/Vim.Util/Logging/ILogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Vim.Util.Logging 4 | { 5 | public interface ILogger 6 | { 7 | ILogger Log(string message = "", LogLevel level = LogLevel.Trace); 8 | } 9 | 10 | public static class LoggerExtensions 11 | { 12 | public static ILogger StartLog(this ILogger logger) 13 | => logger.Log($"Started logging {DateTime.Now}"); 14 | 15 | public static void LogInformation(this ILogger logger, string message = "") 16 | => logger.Log(message, LogLevel.Information); 17 | 18 | public static void LogDebug(this ILogger logger, string message = "") 19 | => logger.Log(message, LogLevel.Debug); 20 | 21 | public static void LogError(this ILogger logger, string message = "") 22 | => logger.Log(message, LogLevel.Error); 23 | 24 | public static void LogError(this ILogger logger, Exception e) 25 | => logger.LogError(e.ToString()); 26 | 27 | public static void LogException(this ILogger logger, Exception e) 28 | => logger.Log(e.ToString(), LogLevel.Error); 29 | 30 | public static void LogWarning(this ILogger logger, string message = "") 31 | => logger.Log(message, LogLevel.Warning); 32 | 33 | public static void LogWarning(this ILogger logger, Exception e) 34 | => logger.Log(e.ToString(), LogLevel.Warning); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/cs/util/Vim.Util/Logging/IndentLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Vim.Util.Logging 5 | { 6 | public class IndentLogger : ILogger 7 | { 8 | private const string _indentation = " "; 9 | 10 | public readonly ILogger InnerLogger; 11 | private string _indentPrefix = string.Empty; 12 | 13 | public IndentLogger(ILogger innerLogger) 14 | => InnerLogger = innerLogger; 15 | 16 | public IndentLogger Indent() 17 | { 18 | _indentPrefix += _indentation; 19 | return this; 20 | } 21 | 22 | public IndentLogger Outdent() 23 | { 24 | _indentPrefix = _indentPrefix.Substring(0, Math.Max(_indentPrefix.Length - _indentation.Length, 0)); 25 | return this; 26 | } 27 | 28 | public Disposer IndentedLog(string message) 29 | { 30 | Log(message); 31 | Indent(); 32 | return new Disposer(() => Outdent()); 33 | } 34 | 35 | public ILogger Log(string message = "", LogLevel level = LogLevel.Trace) 36 | { 37 | InnerLogger.Log(_indentPrefix + message, level); 38 | return this; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/cs/util/Vim.Util/Logging/NullLogger.cs: -------------------------------------------------------------------------------- 1 | namespace Vim.Util.Logging 2 | { 3 | public class NullLogger : ILogger 4 | { 5 | public ILogger Log(string message = "", LogLevel level = LogLevel.Trace) 6 | => this; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/cs/util/Vim.Util/Logging/RecordLogger.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | 4 | namespace Vim.Util.Logging 5 | { 6 | public class LogRecord 7 | { 8 | public readonly string Message; 9 | public readonly LogLevel LogLevel; 10 | public LogRecord(string message, LogLevel logLevel) 11 | => (Message, LogLevel) = (message, logLevel); 12 | } 13 | 14 | public class RecordLogger : ILogger, IEnumerable 15 | { 16 | public List LogRecords { get; } = new List(); 17 | 18 | public ILogger Log(string message = "", LogLevel level = LogLevel.Trace) 19 | { 20 | LogRecords.Add(new LogRecord(message, level)); 21 | return this; 22 | } 23 | 24 | public IEnumerator GetEnumerator() 25 | => LogRecords.GetEnumerator(); 26 | 27 | IEnumerator IEnumerable.GetEnumerator() 28 | => GetEnumerator(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/cs/util/Vim.Util/Logging/StdLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace Vim.Util.Logging 5 | { 6 | public class StdLogger : ILogger 7 | { 8 | public Stopwatch Stopwatch = Stopwatch.StartNew(); 9 | 10 | private readonly bool _writeToConsole; 11 | private readonly bool _writeToDebug; 12 | 13 | public StdLogger(bool writeToConsole = true, bool writeToDebug = true) 14 | { 15 | _writeToConsole = writeToConsole; 16 | _writeToDebug = writeToDebug; 17 | this.StartLog(); 18 | } 19 | 20 | public ILogger Log(string message = "", LogLevel level = LogLevel.None) 21 | { 22 | var timeStamp = Stopwatch.Elapsed.ToString(@"hh\:mm\:ss\.ff"); 23 | var msg = $"[{timeStamp}][{level:G}] {message}"; 24 | if (_writeToConsole) Console.WriteLine(msg); 25 | if (_writeToDebug) Debug.WriteLine(msg); 26 | return this; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/cs/util/Vim.Util/Result.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Vim.Util 4 | { 5 | /// 6 | /// A generic result class which contains a value upon success, and an exception upon failure. 7 | /// 8 | public class Result 9 | { 10 | public readonly T Value; 11 | public readonly Exception Exception; 12 | 13 | public bool IsSuccess 14 | => Exception == null; 15 | 16 | private Result(T value, Exception exception = null) 17 | { 18 | Value = value; 19 | Exception = exception; 20 | } 21 | 22 | public override string ToString() 23 | => IsSuccess ? "Success" : Exception?.ToString() ?? "Failure"; 24 | 25 | public static Result Success(T value) 26 | => new Result(value); 27 | 28 | public static Result Failure(Exception exception) 29 | => new Result(default, exception); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/cs/util/Vim.Util/SpecialFolders.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Vim.Util 4 | { 5 | public static class SpecialFolders 6 | { 7 | public static string RoamingAppData => 8 | Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); 9 | 10 | public static string LocalAppData => 11 | Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); 12 | 13 | public static string ProgramData 14 | => Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); 15 | 16 | public static string MyDocuments => 17 | Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); 18 | 19 | public static string ProgramFiles 20 | => Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); 21 | 22 | public static string UserProfile 23 | => Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); 24 | 25 | public static string CommonProgramFiles 26 | => Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/cs/util/Vim.Util/SynchronousProgress.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Vim.Util 4 | { 5 | /// 6 | /// A synchronous Progress implementation. 7 | ///

      8 | /// NOTE: this avoids having the progress callback scheduled on a separate thread 9 | /// and solves the issue of having progress reports appear out-of-order. 10 | ///

      11 | /// SEE: https://stackoverflow.com/a/39744807 12 | ///
      13 | public class SynchronousProgress : IProgress 14 | { 15 | private readonly Action _callback; 16 | 17 | public SynchronousProgress(Action callback) 18 | { 19 | _callback = callback; 20 | } 21 | 22 | void IProgress.Report(T data) 23 | { 24 | _callback(data); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/cs/util/Vim.Util/Vim.Util.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.CodeGen/HandWrittenCpp.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vimaec/vim-format/fc4a98e02e51ad595ef3e9b51d6223afbf9e53bc/src/cs/vim/Vim.Format.CodeGen/HandWrittenCpp.cpp -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.CodeGen/Program.cs: -------------------------------------------------------------------------------- 1 | namespace Vim.Format.CodeGen 2 | { 3 | public static class Program 4 | { 5 | public static void Main(string[] args) 6 | { 7 | var file = args[0]; 8 | var tsFile = args[1]; 9 | var hFile = args[2]; 10 | 11 | ObjectModelGenerator.WriteDocument(file); 12 | ObjectModelTypeScriptGenerator.WriteDocument(tsFile); 13 | ObjectModelCppGenerator.WriteDocument(hFile); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.CodeGen/Vim.Format.CodeGen.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | 6 | Exe 7 | Vim.Format.CodeGen.Program 8 | OnOutputUpdated 9 | 10 | 11 | 12 | 13 | 14 | 15 | Always 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.Core/CascadeElementRemapAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Vim.Format 4 | { 5 | [AttributeUsage(AttributeTargets.Class)] 6 | public class CascadeElementRemapAttribute : Attribute 7 | { 8 | public CascadeElementRemapAttribute() 9 | { } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.Core/ColumnInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace Vim.Format 6 | { 7 | public enum ColumnType 8 | { 9 | IndexColumn, 10 | StringColumn, 11 | DataColumn, 12 | } 13 | 14 | public class ColumnInfo 15 | { 16 | public readonly ColumnType ColumnType; 17 | public readonly string TypePrefix; 18 | public readonly Type SerializedType; 19 | public readonly ISet CastTypes; 20 | 21 | public ColumnInfo(ColumnType columnType, string typePrefix, Type serializedType, params Type[] castTypes) 22 | { 23 | (ColumnType, TypePrefix, SerializedType) = (columnType, typePrefix, serializedType); 24 | CastTypes = new HashSet(castTypes); 25 | } 26 | 27 | public IEnumerable RelatedTypes 28 | => CastTypes.Prepend(SerializedType); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.Core/Document.cs: -------------------------------------------------------------------------------- 1 | using Vim.LinqArray; 2 | using Vim.BFast; 3 | 4 | namespace Vim.Format 5 | { 6 | // TODO: this should be merged into Serializable document. 7 | public class Document 8 | { 9 | public Document(SerializableDocument document) 10 | { 11 | _Document = document; 12 | Header = _Document.Header; 13 | Geometry = _Document.Geometry; 14 | StringTable = _Document.StringTable.ToIArray(); 15 | EntityTables = _Document.EntityTables.ToLookup( 16 | et => et.Name, 17 | et => et.ToEntityTable(this)); 18 | Assets = _Document.Assets.ToLookup(et => et.Name, et => et); 19 | } 20 | 21 | public string FileName => _Document.FileName; 22 | private SerializableDocument _Document { get; } 23 | public SerializableHeader Header { get; } 24 | public ILookup EntityTables { get; } 25 | public ILookup Assets { get; } 26 | public IArray StringTable { get; } 27 | public string GetString(int index) => StringTable.ElementAtOrDefault(index); 28 | public G3d.G3D Geometry { get; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.Core/EntityColumnLoadingInfo.cs: -------------------------------------------------------------------------------- 1 | namespace Vim.Format 2 | { 3 | public class EntityColumnLoadingInfo 4 | { 5 | public readonly ValueSerializationStrategy Strategy; 6 | public readonly string TypePrefix; 7 | public readonly EntityColumnLoaderAttribute EntityColumnAttribute; 8 | public string SerializedValueColumnName 9 | => EntityColumnAttribute.SerializedValueColumnName; 10 | 11 | public EntityColumnLoadingInfo( 12 | ValueSerializationStrategy strategy, 13 | string typePrefix, 14 | EntityColumnLoaderAttribute entityColumnAttribute) 15 | { 16 | Strategy = strategy; 17 | TypePrefix = typePrefix; 18 | EntityColumnAttribute = entityColumnAttribute; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.Core/Geometry/Bounded.cs: -------------------------------------------------------------------------------- 1 | using Vim.Math3d; 2 | 3 | namespace Vim.Format.Geometry 4 | { 5 | public interface IBounded 6 | { 7 | AABox Bounds { get; } 8 | } 9 | 10 | public static class Bounded 11 | { 12 | public static AABox UpdateBounds(this IBounded self, AABox box) 13 | => box.Merge(self.Bounds); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.Core/Geometry/IMesh.cs: -------------------------------------------------------------------------------- 1 | using Vim.G3d; 2 | using Vim.LinqArray; 3 | using Vim.Math3d; 4 | 5 | namespace Vim.Format.Geometry 6 | { 7 | /// 8 | /// This is the interface for triangle meshes. 9 | /// 10 | public interface IMesh : 11 | IGeometryAttributes, 12 | ITransformable3D 13 | { 14 | IArray Vertices { get; } 15 | IArray Indices { get; } 16 | IArray VertexColors { get; } 17 | IArray VertexNormals { get; } 18 | IArray VertexUvs { get; } 19 | 20 | IArray SubmeshMaterials { get; } 21 | IArray SubmeshIndexOffsets { get; } 22 | IArray SubmeshIndexCount { get; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.Core/Geometry/IScene.cs: -------------------------------------------------------------------------------- 1 | using Vim.LinqArray; 2 | using Vim.Math3d; 3 | 4 | namespace Vim.Format.Geometry 5 | { 6 | /// 7 | /// An IScene is a generic representation of a 3D scene graph. 8 | /// 9 | public interface IScene 10 | { 11 | IArray Nodes { get; } 12 | IArray Meshes { get; } 13 | } 14 | 15 | /// 16 | /// A node in a scene graph. 17 | /// 18 | public interface ISceneNode 19 | { 20 | Matrix4x4 Transform { get; } 21 | int MeshIndex { get; } 22 | IMesh GetMesh(); 23 | ISceneNode Parent { get; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.Core/Geometry/MeshDebugView.cs: -------------------------------------------------------------------------------- 1 | using Vim.LinqArray; 2 | using Vim.Math3d; 3 | 4 | namespace Vim.Format.Geometry 5 | { 6 | public class MeshDebugView 7 | { 8 | IMesh Interface { get; } 9 | 10 | public int NumCorners => Interface.NumCorners; 11 | public int NumFaces => Interface.NumFaces; 12 | public int NumMeshes => Interface.NumMeshes; 13 | public int NumInstances => Interface.NumInstances; 14 | 15 | public Vector3[] Vertices => Interface.Vertices.ToArray(); 16 | public int[] Indices => Interface.Indices.ToArray(); 17 | 18 | public MeshDebugView(IMesh g) 19 | => Interface = g; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.Core/Geometry/QuadMesh.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Diagnostics; 3 | using Vim.Util; 4 | using Vim.G3d; 5 | 6 | namespace Vim.Format.Geometry 7 | { 8 | /// 9 | /// This is a quadrilateral mesh. Note that it does not implement the IMesh interface, 10 | /// but does implement IGeometryAttributes and inherits from a G3D. 11 | /// 12 | public class QuadMesh : G3D, IGeometryAttributes 13 | { 14 | public QuadMesh(IEnumerable attributes) 15 | : base(attributes.Append(new[] { 4 }.ToObjectFaceSizeAttribute())) 16 | => Debug.Assert(NumCornersPerFace == 4); 17 | 18 | public IMesh ToTriMesh() 19 | => this.TriangulateQuadMesh().ToIMesh(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.Core/Geometry/Serialization.cs: -------------------------------------------------------------------------------- 1 | using Vim.G3d; 2 | 3 | namespace Vim.Format.Geometry 4 | { 5 | public static class Serialization 6 | { 7 | public static IMesh ReadG3D(string filePath) 8 | => G3D.Read(filePath).ToIMesh(); 9 | 10 | public static G3D ToG3d(this IMesh mesh) 11 | => mesh is G3D r ? r : mesh.Attributes.ToG3d(); 12 | 13 | public static void WriteG3d(this IMesh mesh, string filePath) 14 | => mesh.ToG3d().Write(filePath); 15 | 16 | public static void WriteObj(this IMesh mesh, string filePath) 17 | => mesh.ToG3d().WriteObj(filePath); 18 | 19 | public static void WritePly(this IMesh mesh, string filePath) 20 | => mesh.ToG3d().WritePly(filePath); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.Core/Geometry/TriMesh.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Diagnostics; 3 | using Vim.G3d; 4 | using Vim.Math3d; 5 | 6 | namespace Vim.Format.Geometry 7 | { 8 | /// 9 | /// A triangular mesh data structure. 10 | /// 11 | public class TriMesh : G3D, IMesh 12 | { 13 | public TriMesh(IEnumerable attributes) 14 | : base(attributes) 15 | => Debug.Assert(NumCornersPerFace == 3); 16 | 17 | public IMesh Transform(Matrix4x4 mat) 18 | => ((IGeometryAttributes)this).Transform(mat).ToIMesh(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.Core/Geometry/VimMaterial.cs: -------------------------------------------------------------------------------- 1 | using Vim.G3d; 2 | using Vim.Math3d; 3 | 4 | namespace Vim.Format.Geometry 5 | { 6 | public interface IMaterial 7 | { 8 | Vector4 Color { get; } 9 | float Smoothness { get; } 10 | float Glossiness { get; } 11 | } 12 | 13 | public class VimMaterial : IMaterial 14 | { 15 | public G3dMaterial Material; 16 | public VimMaterial(G3dMaterial material) => Material = material; 17 | public Vector4 Color => Material.Color; 18 | public float Smoothness => Material.Smoothness; 19 | public float Glossiness => Material.Glossiness; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.Core/TableNameAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Vim.Format 4 | { 5 | public class TableNameAttribute : Attribute 6 | { 7 | public string Name { get; } 8 | public TableNameAttribute(string name) 9 | => Name = name; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.Core/ValueSerializationStrategy.cs: -------------------------------------------------------------------------------- 1 | namespace Vim.Format 2 | { 3 | public enum ValueSerializationStrategy 4 | { 5 | SerializeAsStringColumn, 6 | SerializeAsDataColumn, 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.Core/Vim.Format.Core.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | true 6 | Vim.Format 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 4.5.4 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | TextTemplatingFileGenerator 30 | ArrayOps.cs 31 | 32 | 33 | 34 | 35 | 36 | True 37 | True 38 | ArrayOps.tt 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.Core/VimFormatVersion.cs: -------------------------------------------------------------------------------- 1 | using Vim.Util; 2 | 3 | namespace Vim.Format 4 | { 5 | public static class VimFormatVersion 6 | { 7 | public static SerializableVersion Current => v1_0_0; 8 | public static SerializableVersion v1_0_0 => SerializableVersion.Parse("1.0.0"); 9 | public static SerializableVersion v0_9_0 => SerializableVersion.Parse("0.9.0"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.ILMerge.Tests/Vim.Format.ILMerge.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | all 15 | runtime; build; native; contentfiles; analyzers; buildtransitive 16 | 17 | 18 | 19 | 20 | 21 | false 22 | 23 | 24 | true 25 | ..\Vim.Format.ILMerge\bin\$(Configuration)\Vim.Format.Standalone.dll 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.ILMerge.Tests/VimFormatILMergeTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System.IO; 3 | using Vim.Util; 4 | using Vim.Util.Logging; 5 | using Serilog; 6 | 7 | namespace Vim.Format.ILMerge.Tests; 8 | 9 | [TestFixture] 10 | public static class VimFormatILMergeTests 11 | { 12 | [Test] 13 | public static void TestVimFormatStandalone() 14 | { 15 | // This test makes use of the merged version of serilog. 16 | // We had to create a merged standalone version of Vim.Format to minimize collisions with other assemblies in Revit. 17 | var fileName = "standalone.log"; 18 | var msg = "This is a log message which uses the ILMerged version of serilog"; 19 | 20 | { 21 | // setup 22 | IO.Delete(fileName); 23 | Assert.IsTrue(!File.Exists(fileName)); 24 | } 25 | 26 | { 27 | // action 28 | var logger = Util.Logging.Serilog.Log.Init("toot", fileName, true); 29 | logger.LogInformation(msg); 30 | Log.CloseAndFlush(); 31 | } 32 | 33 | { 34 | // verify 35 | var fileInfo = new FileInfo(fileName); 36 | Assert.IsTrue(fileInfo.Exists, $"File not found: {fileInfo.FullName}"); 37 | var logged = File.ReadAllText(fileInfo.FullName); 38 | Assert.IsTrue(logged.Contains(msg)); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.ILMerge/ILRepack.Config.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | False 6 | $(ProjectDir)ILRepack.targets 7 | 8 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.ILMerge/Vim.Format.ILMerge.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard2.0 5 | false 6 | Always 7 | Vim.Format.ILMerge 8 | 12 | true 13 | 14 | 15 | 16 | 17 | 18 | 19 | all 20 | runtime; build; native; contentfiles; analyzers; buildtransitive 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.Tests/Geometry/PerimeterTest.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using Vim.Format.Geometry; 3 | using Vim.Math3d; 4 | 5 | namespace Vim.Format.Tests.Geometry 6 | { 7 | public static class PerimeterTest 8 | { 9 | 10 | [Test] 11 | public static void Test() 12 | { 13 | var torus = Primitives.QuadMesh(uv => TorusFunction(uv, 10, 0.2f), 10, 24); 14 | 15 | var perimeter = torus.GeneratePerimeter(Vector3.UnitX); 16 | } 17 | 18 | public static Vector3 TorusFunction(Vector2 uv, float radius, float tube) 19 | { 20 | uv = uv * Constants.TwoPi; 21 | return new Vector3( 22 | (radius + tube * uv.Y.Cos()) * uv.X.Cos(), 23 | (radius + tube * uv.Y.Cos()) * uv.X.Sin(), 24 | tube * uv.X.Sin()); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.Tests/Vim.Format.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | all 15 | runtime; build; native; contentfiles; analyzers; buildtransitive 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format.Tests/VimCppTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System.IO; 3 | using Vim.Util; 4 | using Vim.Util.Tests; 5 | 6 | namespace Vim.Format.Tests; 7 | 8 | [TestFixture] 9 | [Ignore("C++ Windows-specific tests")] 10 | public static class VimCppTests 11 | { 12 | 13 | public class VimCppTestsShell : ShellProcess 14 | { 15 | public override string GetExePath(string projectConfig) 16 | { 17 | return Path.Combine(VimFormatRepoPaths.SrcDir, "cpp", "vim", "bin", "x64", projectConfig, "Vim.Cpp.exe"); 18 | } 19 | } 20 | 21 | [Test] 22 | public static void RunVimCppTestsShell() 23 | { 24 | var vimCppTestsShell = new VimCppTestsShell(); 25 | var result = vimCppTestsShell.StartProcess().GetResult(); 26 | Assert.IsTrue(result.IsSuccess(), result.ToString()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format/Merge/MergeConfigOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Vim.Format.Merge 2 | { 3 | public class MergeConfigOptions 4 | { 5 | /// 6 | /// The generator string to embed into the VIM file header 7 | /// 8 | public string GeneratorString { get; set; } = "Unknown"; 9 | 10 | /// 11 | /// The version string to embed into the VIM file header. 12 | /// 13 | public string VersionString { get; set; } = "0.0.0"; 14 | 15 | /// 16 | /// Preserves the BIM data 17 | /// 18 | public bool KeepBimData { get; set; } = true; 19 | 20 | /// 21 | /// Merges the given VIM files as a grid. 22 | /// 23 | public bool MergeAsGrid { get; set; } = false; 24 | 25 | /// 26 | /// Applied when merging as a grid. 27 | /// 28 | public float GridPadding { get; set; } = 0f; 29 | 30 | /// 31 | /// Deduplicates Elements and EntityWithElements based on their Element's unique ids. 32 | /// If the unique ID is empty, the entities are not merged. 33 | /// 34 | public bool DeduplicateEntities { get; set; } = true; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format/Merge/MergeConfigVimScenes.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Vim.Math3d; 3 | 4 | namespace Vim.Format.Merge 5 | { 6 | public class MergeConfigVimScenes 7 | { 8 | /// 9 | /// The input VIM scenes and their transforms. 10 | /// 11 | public (VimScene VimScene, Matrix4x4 Transform)[] InputVimScenesAndTransforms { get; } 12 | 13 | /// 14 | /// The input VIM scenes 15 | /// 16 | public VimScene[] InputVimScenes 17 | => InputVimScenesAndTransforms.Select(t => t.VimScene).ToArray(); 18 | 19 | /// 20 | /// The input VIM scene transforms 21 | /// 22 | public Matrix4x4[] InputTransforms 23 | => InputVimScenesAndTransforms.Select(t => t.Transform).ToArray(); 24 | 25 | /// 26 | /// Constructor. 27 | /// 28 | public MergeConfigVimScenes((VimScene VimScene, Matrix4x4 Transform)[] inputVimScenesAndTransforms) 29 | => InputVimScenesAndTransforms = inputVimScenesAndTransforms; 30 | 31 | /// 32 | /// Constructor. Applies an identity matrix to the input VimScenes 33 | /// 34 | public MergeConfigVimScenes(VimScene[] vimScenes) 35 | : this(vimScenes.Select(v => (v, Matrix4x4.Identity)).ToArray()) 36 | { } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format/ObjectModel/EntityTableSet.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | 5 | namespace Vim.Format.ObjectModel 6 | { 7 | /// 8 | /// Additional partial definitions of EntityTableSet. 9 | /// 10 | public partial class EntityTableSet 11 | { 12 | /// 13 | /// Convenience constructor for seeking entity table information in a VIM file. 14 | /// 15 | public EntityTableSet( 16 | FileInfo vimFileInfo, 17 | bool schemaOnly, 18 | string[] stringBuffer, 19 | Func entityTableNameFilterFunc = null, 20 | bool inParallel = true) 21 | : this( 22 | vimFileInfo.EnumerateEntityTables(schemaOnly, entityTableNameFilterFunc).ToArray(), 23 | stringBuffer, 24 | inParallel) 25 | { } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/cs/vim/Vim.Format/SceneBuilder/VimShape.cs: -------------------------------------------------------------------------------- 1 | using Vim.Format.ObjectModel; 2 | using Vim.G3d; 3 | using Vim.LinqArray; 4 | using Vim.Math3d; 5 | 6 | namespace Vim 7 | { 8 | public class VimShape : ElementInfo 9 | { 10 | public readonly VimScene Scene; 11 | public readonly int ShapeIndex; 12 | 13 | public G3dShape G3dShape => Scene.Document.Geometry.Shapes[ShapeIndex]; 14 | public IArray Vertices => G3dShape.Vertices; 15 | public Vector4 Color => G3dShape.Color; 16 | public float Width => G3dShape.Width; 17 | 18 | public VimShape(VimScene scene, int shapeIndex) 19 | : base(scene.DocumentModel, scene.DocumentModel.GetShapeElementIndex(shapeIndex)) 20 | { 21 | Scene = scene; 22 | ShapeIndex = shapeIndex; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/rust/bfast/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "autocfg" 7 | version = "1.1.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 10 | 11 | [[package]] 12 | name = "bfast" 13 | version = "0.1.0" 14 | dependencies = [ 15 | "num-traits", 16 | ] 17 | 18 | [[package]] 19 | name = "num-traits" 20 | version = "0.2.15" 21 | source = "registry+https://github.com/rust-lang/crates.io-index" 22 | checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" 23 | dependencies = [ 24 | "autocfg", 25 | ] 26 | -------------------------------------------------------------------------------- /src/rust/bfast/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bfast" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | num-traits = "0.2.15" 10 | -------------------------------------------------------------------------------- /src/rust/g3d/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "autocfg" 7 | version = "1.1.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 10 | 11 | [[package]] 12 | name = "bfast" 13 | version = "0.1.0" 14 | dependencies = [ 15 | "num-traits", 16 | ] 17 | 18 | [[package]] 19 | name = "g3d" 20 | version = "0.1.0" 21 | dependencies = [ 22 | "bfast", 23 | ] 24 | 25 | [[package]] 26 | name = "num-traits" 27 | version = "0.2.15" 28 | source = "registry+https://github.com/rust-lang/crates.io-index" 29 | checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" 30 | dependencies = [ 31 | "autocfg", 32 | ] 33 | -------------------------------------------------------------------------------- /src/rust/g3d/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "g3d" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | bfast = { path = "../bfast" } -------------------------------------------------------------------------------- /src/rust/math3d/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "math3d" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | num-traits = "0.2.15" 10 | math3d_macro_derive = { path = "./math3d_macro_derive" } -------------------------------------------------------------------------------- /src/rust/math3d/math3d_macro_derive/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "math3d_macro_derive" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [lib] 9 | proc-macro = true 10 | 11 | [dependencies] 12 | syn = "2.0.11" 13 | quote = "1.0.26" 14 | num-traits = "0.2.15" 15 | -------------------------------------------------------------------------------- /src/rust/math3d/src/constants.rs: -------------------------------------------------------------------------------- 1 | use num_traits::{Float, FloatConst}; 2 | use crate::{Plane, Vector3}; 3 | 4 | pub fn xy_plane() -> Plane { Plane:: { normal: Vector3::new(T::zero(), T::zero(), T::one()), d: T::zero() } } 5 | pub fn xz_plane() -> Plane { Plane:: { normal: Vector3::new(T::zero(), T::one(), T::zero()), d: T::zero() } } 6 | pub fn yz_plane() -> Plane { Plane:: { normal: Vector3::new(T::one(), T::zero(), T::zero()), d: T::zero() } } 7 | 8 | pub fn tolerance() -> T { T::from(0.0000001f32).unwrap() } 9 | pub fn pi() -> T { T::PI() } 10 | pub fn half_pi() -> T { T::PI() / T::from(2).unwrap() } 11 | pub fn two_pi() -> T { T::PI() * T::from(2).unwrap() } 12 | 13 | pub fn log2_e() -> T { T::LOG2_E() } 14 | pub fn log10_e() -> T { T::LOG10_E() } 15 | pub fn e() -> T { T::E() } 16 | 17 | pub const RADIANS_TO_DEGREES: f64 = 57.295779513082320876798154814105; 18 | pub const DEGREES_TO_RADIANS: f64 = 0.017453292519943295769236907684886; 19 | pub const ONE_TENTH_OF_A_DEGREE: f64 = DEGREES_TO_RADIANS / 10.0; 20 | 21 | pub fn mm_to_feet() -> T { T::from(0.00328084).unwrap() } 22 | pub fn feet_to_mm() -> T { T::one() / mm_to_feet() } 23 | -------------------------------------------------------------------------------- /src/rust/math3d/src/hash.rs: -------------------------------------------------------------------------------- 1 | use num_traits::Float; 2 | use std::hash::Hasher; 3 | use std::collections::hash_map::DefaultHasher; 4 | 5 | // Discussion: if we want to go deeper into the subject, check out 6 | // https://en.wikipedia.org/wiki/List_of_hash_functions 7 | // https://stackoverflow.com/questions/5889238/why-is-xor-the-default-way-to-combine-hashes 8 | // https://en.wikipedia.org/wiki/Jenkins_hash_function#cite_note-11 9 | // https://referencesource.microsoft.com/#System.Numerics/System/Numerics/HashCodeHelper.cs 10 | // https://github.com/dotnet/corefx/blob/master/src/Common/src/CoreLib/System/Numerics/Hashing/HashHelpers.cs 11 | 12 | pub fn combine(h1: u64, h2: u64) -> u64 { 13 | let rol5 = ((h1) << 5) | ((h1) >> 27); 14 | ((rol5) + h1) ^ h2 15 | } 16 | pub fn combine_list(xs: &[u64]) -> u64 { 17 | if xs.is_empty() { return 0; } 18 | let mut r = xs[0]; 19 | for i in 1..xs.len() { r = combine::(r, xs[i]); } 20 | r 21 | } 22 | pub fn combine_array(xs: &[u64]) -> u64 { combine_list::(xs) } 23 | pub fn combine_multiple(x0: u64, x1: u64, x2: u64) -> u64 { 24 | combine::(combine::(x0, x1), x2) 25 | } 26 | pub fn combine_quadruple(x0: u64, x1: u64, x2: u64, x3: u64) -> u64 { 27 | combine::(combine_multiple::(x0, x1, x2), x3) 28 | } 29 | pub fn hash_values>(values: I) -> u64 { 30 | values.fold(0, |acc, x| combine::(acc, x)) 31 | } 32 | pub fn hash_codes>(values: I) -> u64 { 33 | let mut hasher = DefaultHasher::new(); 34 | values.fold(0, |acc, x| { 35 | x.hash(&mut hasher); 36 | combine::(acc, hasher.finish()) 37 | }) 38 | } 39 | -------------------------------------------------------------------------------- /src/rust/math3d/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod structs; 2 | pub mod math3d_ops; 3 | pub mod constants; 4 | pub mod transformable; 5 | pub mod hash; 6 | pub mod stateless_random; 7 | 8 | pub use structs::*; 9 | pub use transformable::*; 10 | -------------------------------------------------------------------------------- /src/rust/math3d/src/stateless_random.rs: -------------------------------------------------------------------------------- 1 | use crate::{hash, Vector2, Vector3, Vector4}; 2 | use num_traits::Float; 3 | 4 | pub fn random_uint(index: usize, seed: u64) -> u64 { 5 | hash::combine::(seed, index as u64) 6 | } 7 | 8 | pub fn random_int(index: usize, seed: u64) -> u64 { 9 | hash::combine::(seed, index as u64) 10 | } 11 | 12 | pub fn random_float(min: T, max: T, index: usize, seed: u64) -> T { 13 | let random_uint: T = T::from(random_uint::(index, seed)).unwrap(); 14 | let max_value: T = T::from(u64::MAX).unwrap(); 15 | let res:T = random_uint / max_value * (max - min) + min; 16 | res 17 | } 18 | 19 | pub fn random_float_default(index: usize, seed: u64) -> T { 20 | random_float(T::zero(), T::one(), index, seed) 21 | } 22 | 23 | pub fn random_vector2(index: usize, seed: u64) -> Vector2 { 24 | Vector2::::new( 25 | random_float_default(index * 2, seed), 26 | random_float_default(index * 2 + 1, seed), 27 | ) 28 | } 29 | 30 | pub fn random_vector3(index: usize, seed: u64) -> Vector3 { 31 | Vector3::::new( 32 | random_float_default(index * 3, seed), 33 | random_float_default(index * 3 + 1, seed), 34 | random_float_default(index * 3 + 2, seed), 35 | ) 36 | } 37 | 38 | pub fn random_vector4(index: usize, seed: u64) -> Vector4 { 39 | Vector4::::new( 40 | random_float_default(index * 4, seed), 41 | random_float_default(index * 4 + 1, seed), 42 | random_float_default(index * 4 + 2, seed), 43 | random_float_default(index * 4 + 3, seed), 44 | ) 45 | } -------------------------------------------------------------------------------- /src/rust/object_model/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "object_model" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | num-traits = "0.2.15" 10 | 11 | bfast = { path = "../bfast" } 12 | g3d = { path = "../g3d" } 13 | vim = { path = "../vim" } 14 | object_model_macro_derive = { path = "./object_model_macro_derive" } -------------------------------------------------------------------------------- /src/rust/object_model/object_model_macro_derive/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "object_model_macro_derive" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [lib] 9 | proc-macro = true 10 | 11 | [dependencies] 12 | syn = "2.0.11" 13 | quote = "1.0.26" 14 | num-traits = "0.2.15" 15 | -------------------------------------------------------------------------------- /src/rust/vim/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "autocfg" 7 | version = "1.1.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 10 | 11 | [[package]] 12 | name = "bfast" 13 | version = "0.1.0" 14 | dependencies = [ 15 | "num-traits", 16 | ] 17 | 18 | [[package]] 19 | name = "g3d" 20 | version = "0.1.0" 21 | dependencies = [ 22 | "bfast", 23 | ] 24 | 25 | [[package]] 26 | name = "num-traits" 27 | version = "0.2.15" 28 | source = "registry+https://github.com/rust-lang/crates.io-index" 29 | checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" 30 | dependencies = [ 31 | "autocfg", 32 | ] 33 | 34 | [[package]] 35 | name = "vim" 36 | version = "0.1.0" 37 | dependencies = [ 38 | "bfast", 39 | "g3d", 40 | ] 41 | -------------------------------------------------------------------------------- /src/rust/vim/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "vim" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | bfast = { path = "../bfast" } 10 | g3d = { path = "../g3d" } -------------------------------------------------------------------------------- /src/rust/vim_format/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "vim_format" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | bfast = { path = "../bfast" } 10 | g3d = { path = "../g3d" } 11 | vim = { path = "../vim" } 12 | math3d = { path = "../math3d" } 13 | object_model = { path = "../object_model" } -------------------------------------------------------------------------------- /src/rust/vim_format/src/main.rs: -------------------------------------------------------------------------------- 1 | use object_model::*; 2 | 3 | fn main() { 4 | //let asset = Parameter2 { index: &2, element_index: 2, element: todo!(), parameter_descriptor_index: todo!(), parameter_descriptor: todo!(), value: todo!() }; 5 | 6 | println!("Hello, {:?}", AssetTable::BUFFER_NAME_COLUMN_NAME); 7 | } 8 | -------------------------------------------------------------------------------- /src/ts/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | src/ts/dist/* 3 | *.d.ts -------------------------------------------------------------------------------- /src/ts/README.md: -------------------------------------------------------------------------------- 1 | # vim-ts 2 | VIM TypeScript Implementation 3 | -------------------------------------------------------------------------------- /src/ts/dist/abstractG3d.d.ts: -------------------------------------------------------------------------------- 1 | import { G3dAttribute } from './g3dAttributes'; 2 | import { BFast } from './bfast'; 3 | /** 4 | * G3D is a simple, efficient, generic binary format for storing and transmitting geometry. 5 | * The G3D format is designed to be used either as a serialization format or as an in-memory data structure. 6 | * See https://github.com/vimaec/g3d 7 | */ 8 | export declare class AbstractG3d { 9 | meta: string; 10 | attributes: G3dAttribute[]; 11 | constructor(meta: string, attributes: G3dAttribute[]); 12 | findAttribute(descriptor: string): G3dAttribute | undefined; 13 | /** 14 | * Create g3d from bfast by requesting all necessary buffers individually. 15 | */ 16 | static createFromBfast(bfast: BFast, names: string[]): Promise; 17 | } 18 | -------------------------------------------------------------------------------- /src/ts/dist/abstractG3d.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.AbstractG3d = void 0; 4 | const g3dAttributes_1 = require("./g3dAttributes"); 5 | /** 6 | * G3D is a simple, efficient, generic binary format for storing and transmitting geometry. 7 | * The G3D format is designed to be used either as a serialization format or as an in-memory data structure. 8 | * See https://github.com/vimaec/g3d 9 | */ 10 | class AbstractG3d { 11 | constructor(meta, attributes) { 12 | this.meta = meta; 13 | this.attributes = attributes; 14 | } 15 | findAttribute(descriptor) { 16 | const filter = g3dAttributes_1.G3dAttributeDescriptor.fromString(descriptor); 17 | for (let i = 0; i < this.attributes.length; ++i) { 18 | const attribute = this.attributes[i]; 19 | if (attribute.descriptor.matches(filter)) 20 | return attribute; 21 | } 22 | } 23 | /** 24 | * Create g3d from bfast by requesting all necessary buffers individually. 25 | */ 26 | static async createFromBfast(bfast, names) { 27 | const attributes = await Promise.all(names.map(async (a) => { 28 | const bytes = await bfast.getBytes(a); 29 | if (!bytes) 30 | return; 31 | const decriptor = g3dAttributes_1.G3dAttributeDescriptor.fromString(a); 32 | return new g3dAttributes_1.G3dAttribute(decriptor, bytes); 33 | })); 34 | const validAttributes = attributes.filter((a) => a !== undefined); 35 | const g3d = new AbstractG3d('meta', validAttributes); 36 | return g3d; 37 | } 38 | } 39 | exports.AbstractG3d = AbstractG3d; 40 | -------------------------------------------------------------------------------- /src/ts/dist/entityTable.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module vim-ts 3 | */ 4 | import { BFast, NumericArray } from './bfast'; 5 | export declare class EntityTable { 6 | private readonly bfast; 7 | private readonly strings; 8 | constructor(bfast: BFast, strings: string[] | undefined); 9 | getLocal(): Promise; 10 | static getTypeSize(colName: string): number; 11 | getCount(): Promise; 12 | getArray(columnName: string): Promise; 13 | getNumberArray(columnName: string): Promise; 14 | getNumber(elementIndex: number, columnName: string): Promise; 15 | getBigIntArray(columnName: string): Promise; 16 | getBigInt(elementIndex: number, columnName: string): Promise; 17 | getBoolean(elementIndex: number, columnName: string): Promise; 18 | getBooleanArray(columnName: string): Promise; 19 | toIndex(value: number | bigint): number; 20 | getString(elementIndex: number, columnName: string): Promise; 21 | getStringArray(columnName: string): Promise; 22 | } 23 | -------------------------------------------------------------------------------- /src/ts/dist/g3dAttributes.d.ts: -------------------------------------------------------------------------------- 1 | export declare class G3dAttributeDescriptor { 2 | description: string; 3 | association: string; 4 | semantic: string; 5 | attributeTypeIndex: string; 6 | dataType: string; 7 | dataArity: number; 8 | constructor(description: string, association: string, semantic: string, attributeTypeIndex: string, dataType: string, dataArity: string); 9 | static fromString(descriptor: string): G3dAttributeDescriptor; 10 | matches(other: G3dAttributeDescriptor): boolean; 11 | } 12 | export declare type TypedArray = Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Uint32Array | BigUint64Array | BigInt64Array | Float64Array; 13 | export declare class G3dAttribute { 14 | descriptor: G3dAttributeDescriptor; 15 | bytes: Uint8Array; 16 | data: TypedArray | undefined; 17 | constructor(descriptor: G3dAttributeDescriptor, bytes: Uint8Array); 18 | static fromString(descriptor: string, buffer: Uint8Array): G3dAttribute; 19 | static castData(bytes: Uint8Array, dataType: string): TypedArray | undefined; 20 | } 21 | -------------------------------------------------------------------------------- /src/ts/dist/g3dMaterials.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module vim-ts 3 | */ 4 | import { BFast } from './bfast'; 5 | /** 6 | * See https://github.com/vimaec/vim#vim-geometry-attributes 7 | */ 8 | export declare class MaterialAttributes { 9 | static materialColors: string; 10 | } 11 | /** 12 | * G3D is a simple, efficient, generic binary format for storing and transmitting geometry. 13 | * The G3D format is designed to be used either as a serialization format or as an in-memory data structure. 14 | * A G3d with specific attributes according to the VIM format specification. 15 | * See https://github.com/vimaec/vim#vim-geometry-attributes for the vim specification. 16 | * See https://github.com/vimaec/g3d for the g3d specification. 17 | */ 18 | export declare class G3dMaterial { 19 | static readonly COLOR_SIZE = 4; 20 | static readonly DEFAULT_COLOR: Float32Array; 21 | materialColors: Float32Array; 22 | constructor(materialColors: Float32Array); 23 | static createFromBfast(bfast: BFast): Promise; 24 | getMaterialCount: () => number; 25 | /** 26 | * Returns color of given material as a 4-number array (RGBA) 27 | * @param material g3d material index 28 | */ 29 | getMaterialColor(material: number): Float32Array; 30 | getMaterialAlpha(material: number): number; 31 | } 32 | -------------------------------------------------------------------------------- /src/ts/dist/g3dMesh.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module vim-ts 3 | */ 4 | import { G3dChunk } from './g3dChunk'; 5 | import { MeshSection } from './g3d'; 6 | import { G3dScene } from './g3dScene'; 7 | export declare class G3dMesh { 8 | readonly scene: G3dScene; 9 | readonly chunk: G3dChunk; 10 | readonly index: number; 11 | constructor(scene: G3dScene, chunk: G3dChunk, index: number); 12 | getVertexStart(section?: MeshSection): number; 13 | getVertexEnd(section?: MeshSection): number; 14 | getVertexCount(section?: MeshSection): number; 15 | getIndexStart(section?: MeshSection): number; 16 | getIndexEnd(section?: MeshSection): number; 17 | getIndexCount(section?: MeshSection): number; 18 | getHasTransparency(mesh: number): boolean; 19 | getSubmeshStart(section: MeshSection): number; 20 | getSubmeshEnd(section: MeshSection): number; 21 | getSubmeshCount(section: MeshSection): number; 22 | getSubmeshIndexStart(submesh: number): number; 23 | getSubmeshIndexEnd(submesh: number): number; 24 | getSubmeshIndexCount(submesh: number): number; 25 | getSubmeshVertexStart(submesh: number): number; 26 | getSubmeshVertexEnd(submesh: number): number; 27 | getSubmeshVertexCount(submesh: number): number; 28 | } 29 | -------------------------------------------------------------------------------- /src/ts/dist/g3dMeshOffsets.d.ts: -------------------------------------------------------------------------------- 1 | import { MeshSection } from "./g3d"; 2 | import { G3dSubset } from "./g3dSubset"; 3 | export declare class G3dMeshCounts { 4 | instances: number; 5 | meshes: number; 6 | indices: number; 7 | vertices: number; 8 | } 9 | /** 10 | * Holds the offsets needed to preallocate geometry for a given meshIndexSubset 11 | */ 12 | export declare class G3dMeshOffsets { 13 | subset: G3dSubset; 14 | section: MeshSection; 15 | counts: G3dMeshCounts; 16 | indexOffsets: Int32Array; 17 | vertexOffsets: Int32Array; 18 | /** 19 | * Computes geometry offsets for given subset and section 20 | * @param subset subset for which to compute offsets 21 | * @param section on of 'opaque' | 'transparent' | 'all' 22 | */ 23 | static fromSubset(subset: G3dSubset, section: MeshSection): G3dMeshOffsets; 24 | getIndexOffset(mesh: number): number; 25 | getVertexOffset(mesh: number): number; 26 | /** 27 | * Returns how many instances of given meshes are the filtered view. 28 | */ 29 | getMeshInstanceCount(mesh: number): number; 30 | /** 31 | * Returns instance for given mesh. 32 | * @mesh view-relative mesh index 33 | * @at view-relative instance index for given mesh 34 | * @returns mesh-relative instance index 35 | */ 36 | getMeshInstance(mesh: number, index: number): number; 37 | /** 38 | * Returns the vim-relative mesh index at given index 39 | */ 40 | getMesh(index: number): number; 41 | } 42 | -------------------------------------------------------------------------------- /src/ts/dist/http/logging.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * @module vim-ts 4 | */ 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | exports.NoLog = exports.DefaultLog = exports.Logger = void 0; 7 | class Logger { 8 | } 9 | exports.Logger = Logger; 10 | class DefaultLog { 11 | constructor() { 12 | this.log = (s) => console.log(s); 13 | this.warn = (s) => console.warn(s); 14 | this.error = (s) => console.error(s); 15 | } 16 | } 17 | exports.DefaultLog = DefaultLog; 18 | class NoLog { 19 | constructor() { 20 | this.log = (s) => { }; 21 | this.warn = (s) => { }; 22 | this.error = (s) => { }; 23 | } 24 | } 25 | exports.NoLog = NoLog; 26 | -------------------------------------------------------------------------------- /src/ts/dist/http/remoteValue.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * @module vim-ts 4 | */ 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | exports.RemoteValue = void 0; 7 | /** 8 | * Returns a value from cache or queue up existing request or start a new requests 9 | */ 10 | class RemoteValue { 11 | constructor(getter, label) { 12 | this._getter = getter; 13 | this.label = label ?? ''; 14 | } 15 | abort() { 16 | this._request = undefined; 17 | } 18 | /** 19 | * Returns a value from cache or queue up existing request or start a new requests 20 | */ 21 | get() { 22 | if (this._value !== undefined) { 23 | // console.log(this.label + ' returning cached value ') 24 | return Promise.resolve(this._value); 25 | } 26 | if (this._request) { 27 | // console.log(this.label + ' returning existing request') 28 | return this._request; 29 | } 30 | // console.log(this.label + ' creating new request') 31 | this._request = this._getter().then((value) => { 32 | this._value = value; 33 | this._request = undefined; 34 | return this._value; 35 | }); 36 | return this._request; 37 | } 38 | } 39 | exports.RemoteValue = RemoteValue; 40 | -------------------------------------------------------------------------------- /src/ts/dist/http/retriableRequest.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.RetriableRequest = void 0; 4 | class RetriableRequest { 5 | constructor(url, headers, range, 6 | // eslint-disable-next-line no-undef 7 | responseType) { 8 | this.url = url; 9 | this.headers = headers ?? {}; 10 | this.range = range; 11 | this.responseType = responseType; 12 | } 13 | abort() { 14 | this.xhr?.abort(); 15 | } 16 | send() { 17 | this.xhr?.abort(); 18 | const xhr = new XMLHttpRequest(); 19 | xhr.open('GET', this.url); 20 | xhr.responseType = this.responseType; 21 | for (const key in this.headers) { 22 | xhr.setRequestHeader(key, this.headers[key]); 23 | } 24 | if (this.range) { 25 | xhr.setRequestHeader('Range', this.range); 26 | } 27 | xhr.onprogress = (e) => { 28 | this.onProgress?.(e); 29 | }; 30 | xhr.onload = (e) => { 31 | this.onProgress?.(e); 32 | this.onLoad?.(xhr.response); 33 | }; 34 | xhr.onerror = (_) => { 35 | this.onError?.(); 36 | }; 37 | xhr.send(); 38 | this.xhr = xhr; 39 | } 40 | } 41 | exports.RetriableRequest = RetriableRequest; 42 | -------------------------------------------------------------------------------- /src/ts/dist/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './bfast'; 2 | export * from './g3d/g3d'; 3 | export * from './remoteVimx'; 4 | export * from './g3d/g3dMaterials'; 5 | export * from './g3d/g3dMesh'; 6 | export * from './g3d/g3dChunk'; 7 | export * from './g3d/g3dScene'; 8 | export * from './http/remoteBuffer'; 9 | export * from './http/requestTracker'; 10 | export * from './http/requester'; 11 | export * from './http/remoteValue'; 12 | export * from './vimHeader'; 13 | export * from './objectModel'; 14 | export * from './structures'; 15 | export * as VimHelpers from './vimHelpers'; 16 | -------------------------------------------------------------------------------- /src/ts/dist/logging.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module vim-ts 3 | */ 4 | export declare class Logger { 5 | log: (s: any) => void; 6 | warn: (s: any) => void; 7 | error: (s: any) => void; 8 | } 9 | export declare class DefaultLog implements Logger { 10 | log: (s: any) => void; 11 | warn: (s: any) => void; 12 | error: (s: any) => void; 13 | } 14 | export declare class NoLog implements Logger { 15 | log: (s: any) => void; 16 | warn: (s: any) => void; 17 | error: (s: any) => void; 18 | } 19 | -------------------------------------------------------------------------------- /src/ts/dist/logging.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * @module vim-ts 4 | */ 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | exports.NoLog = exports.DefaultLog = exports.Logger = void 0; 7 | class Logger { 8 | } 9 | exports.Logger = Logger; 10 | class DefaultLog { 11 | constructor() { 12 | this.log = (s) => console.log(s); 13 | this.warn = (s) => console.warn(s); 14 | this.error = (s) => console.error(s); 15 | } 16 | } 17 | exports.DefaultLog = DefaultLog; 18 | class NoLog { 19 | constructor() { 20 | this.log = (s) => { }; 21 | this.warn = (s) => { }; 22 | this.error = (s) => { }; 23 | } 24 | } 25 | exports.NoLog = NoLog; 26 | -------------------------------------------------------------------------------- /src/ts/dist/remoteBuffer.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module vim-ts 3 | */ 4 | import { Range } from './bfast'; 5 | import { IProgressLogs } from './requestTracker'; 6 | export declare function setRemoteBufferMaxConcurency(value: number): void; 7 | /** 8 | * Wrapper to provide tracking for all webrequests via request logger. 9 | */ 10 | export declare class RemoteBuffer { 11 | url: string; 12 | maxConcurency: number; 13 | onProgress: (progress: IProgressLogs) => void; 14 | private _tracker; 15 | private _logs; 16 | private _queue; 17 | private _active; 18 | private _encoded; 19 | constructor(url: string, verbose?: boolean); 20 | private requestEncoding; 21 | abort(): void; 22 | http(range: Range | undefined, label: string): Promise; 23 | private enqueue; 24 | private retry; 25 | private end; 26 | private next; 27 | } 28 | -------------------------------------------------------------------------------- /src/ts/dist/remoteGeometry.d.ts: -------------------------------------------------------------------------------- 1 | import { BFast } from "./bfast"; 2 | import { G3dMaterial as G3dMaterials } from "./g3dMaterials"; 3 | import { G3dMesh } from "./g3dMesh"; 4 | import { G3dScene } from "./g3dScene"; 5 | import { RemoteValue } from "./remoteValue"; 6 | export declare class RemoteGeometry { 7 | bfast: BFast; 8 | scene: RemoteValue; 9 | sceneRaw: RemoteValue; 10 | constructor(bfast: BFast); 11 | static fromPath(path: string): Promise; 12 | /** 13 | * Aborts all downloads from the underlying BFAST. 14 | */ 15 | abort(): void; 16 | /** 17 | * Downloads underlying bfast making all subsequent request local. 18 | */ 19 | download(): Promise; 20 | /** 21 | * Fetches and returns the vimx G3dMeshIndex 22 | */ 23 | private requestIndex; 24 | private requestIndexRaw; 25 | getIndex(): Promise; 26 | getIndexRaw(): Promise; 27 | /** 28 | * Fetches and returns the vimx G3dMaterials 29 | */ 30 | getMaterials(): Promise; 31 | /** 32 | * Fetches and returns the vimx G3dMesh with given index 33 | */ 34 | getMesh(mesh: number): Promise; 35 | /** 36 | * Fetches and returns the vimx G3dMaterials 37 | */ 38 | getMaterialsRaw(): Promise; 39 | /** 40 | * Fetches and returns the vimx G3dMesh with given index 41 | */ 42 | getMeshRaw(mesh: number): Promise; 43 | } 44 | -------------------------------------------------------------------------------- /src/ts/dist/remoteValue.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module vim-ts 3 | */ 4 | /** 5 | * Returns a value from cache or queue up existing request or start a new requests 6 | */ 7 | export declare class RemoteValue { 8 | label: string; 9 | private _getter; 10 | private _value; 11 | private _request; 12 | constructor(getter: () => Promise, label?: string); 13 | /** 14 | * Returns a value from cache or queue up existing request or start a new requests 15 | */ 16 | get(): Promise; 17 | } 18 | -------------------------------------------------------------------------------- /src/ts/dist/remoteValue.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * @module vim-ts 4 | */ 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | exports.RemoteValue = void 0; 7 | /** 8 | * Returns a value from cache or queue up existing request or start a new requests 9 | */ 10 | class RemoteValue { 11 | constructor(getter, label) { 12 | this._getter = getter; 13 | this.label = label ?? ''; 14 | } 15 | /** 16 | * Returns a value from cache or queue up existing request or start a new requests 17 | */ 18 | get() { 19 | if (this._value !== undefined) { 20 | // console.log(this.label + ' returning cached value ') 21 | return Promise.resolve(this._value); 22 | } 23 | if (this._request) { 24 | // console.log(this.label + ' returning existing request') 25 | return this._request; 26 | } 27 | // console.log(this.label + ' creating new request') 28 | this._request = this._getter().then((value) => { 29 | this._value = value; 30 | this._request = undefined; 31 | return this._value; 32 | }); 33 | return this._request; 34 | } 35 | } 36 | exports.RemoteValue = RemoteValue; 37 | -------------------------------------------------------------------------------- /src/ts/dist/remoteVimx.d.ts: -------------------------------------------------------------------------------- 1 | import { BFast } from "./bfast"; 2 | import { G3dMaterial as G3dMaterials } from "./g3d/g3dMaterials"; 3 | import { G3dChunk } from './g3d/g3dChunk'; 4 | import { G3dScene } from "./g3d/g3dScene"; 5 | import { RemoteValue } from "./http/remoteValue"; 6 | import { G3dMesh } from "./g3d/g3dMesh"; 7 | export declare class RemoteVimx { 8 | bfast: BFast; 9 | scene: RemoteValue; 10 | chunkCache: Map>; 11 | constructor(bfast: BFast); 12 | /** 13 | * Aborts all downloads from the underlying BFAST. 14 | */ 15 | abort(): void; 16 | /** 17 | * Downloads underlying bfast making all subsequent request local. 18 | */ 19 | download(): Promise; 20 | private requestScene; 21 | getHeader(): Promise; 22 | /** 23 | * Fetches and returns the vimx G3dScene 24 | */ 25 | getScene(): Promise; 26 | /** 27 | * Fetches and returns the vimx G3dMaterials 28 | */ 29 | getMaterials(): Promise; 30 | /** 31 | * Fetches and returns the vimx G3dMesh with given index 32 | */ 33 | getChunk(chunk: number): Promise; 34 | private requestChunk; 35 | getMesh(mesh: number): Promise; 36 | } 37 | -------------------------------------------------------------------------------- /src/ts/dist/requestTracker.d.ts: -------------------------------------------------------------------------------- 1 | import { Logger } from "./logging"; 2 | /** 3 | * Represents the state of a single web request 4 | */ 5 | declare class Request { 6 | status: 'active' | 'completed' | 'failed'; 7 | field: string; 8 | loaded: number; 9 | total: number; 10 | lengthComputable: boolean; 11 | constructor(field: string); 12 | } 13 | export interface IProgressLogs { 14 | get loaded(): number; 15 | get total(): number; 16 | get all(): Map; 17 | } 18 | /** 19 | * Represents a collection of webrequests 20 | * Will only send update signal at most every delay 21 | * Provides convenient aggregation of metrics. 22 | */ 23 | export declare class RequestTracker { 24 | source: string; 25 | all: Map; 26 | lastUpdate: number; 27 | delay: number; 28 | sleeping: boolean; 29 | logs: Logger; 30 | /** 31 | * callback on update, called at most every delay time. 32 | */ 33 | onUpdate: ((self: RequestTracker) => void) | undefined; 34 | constructor(source: string, logger?: Logger); 35 | /** 36 | * Returns the sum of .loaded across all requests 37 | */ 38 | get loaded(): number; 39 | /** 40 | * Returns the sum of .total across all requests 41 | */ 42 | get total(): number; 43 | /** 44 | * Starts tracking a new web request 45 | */ 46 | start(field: string): void; 47 | /** 48 | * Update an existing web request 49 | */ 50 | update(field: string, progress: ProgressEvent): void; 51 | /** 52 | * Notify a webrequest of failure 53 | */ 54 | fail(field: string): void; 55 | /** 56 | * Notify a webrequest of success 57 | */ 58 | end(field: string): void; 59 | private signal; 60 | } 61 | export {}; 62 | -------------------------------------------------------------------------------- /src/ts/dist/requester.d.ts: -------------------------------------------------------------------------------- 1 | import { IProgressLogs } from "./requestTracker"; 2 | /** 3 | * Wrapper to provide tracking for all webrequests via request logger. 4 | */ 5 | export declare class Requester { 6 | maxConcurency: number; 7 | onProgress: (progress: IProgressLogs) => void; 8 | private _tracker; 9 | private _logs; 10 | private _queue; 11 | private _active; 12 | constructor(verbose?: boolean); 13 | abort(): void; 14 | http(url: string, label?: string): Promise; 15 | private enqueue; 16 | private retry; 17 | private end; 18 | private next; 19 | } 20 | -------------------------------------------------------------------------------- /src/ts/dist/retriableRequest.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.RetriableRequest = void 0; 4 | class RetriableRequest { 5 | constructor(url, range, 6 | // eslint-disable-next-line no-undef 7 | responseType) { 8 | this.url = url; 9 | this.range = range; 10 | this.responseType = responseType; 11 | } 12 | abort() { 13 | this.xhr?.abort(); 14 | } 15 | send() { 16 | this.xhr?.abort(); 17 | const xhr = new XMLHttpRequest(); 18 | xhr.open('GET', this.url); 19 | xhr.responseType = this.responseType; 20 | if (this.range) { 21 | xhr.setRequestHeader('Range', this.range); 22 | } 23 | xhr.onprogress = (e) => { 24 | this.onProgress?.(e); 25 | }; 26 | xhr.onload = (e) => { 27 | this.onProgress?.(e); 28 | this.onLoad?.(xhr.response); 29 | }; 30 | xhr.onerror = (_) => { 31 | this.onError?.(); 32 | }; 33 | xhr.send(); 34 | this.xhr = xhr; 35 | } 36 | } 37 | exports.RetriableRequest = RetriableRequest; 38 | -------------------------------------------------------------------------------- /src/ts/dist/structures.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module vim-ts 3 | */ 4 | export declare type Vector2 = { 5 | x: number; 6 | y: number; 7 | }; 8 | export declare type Vector3 = { 9 | x: number; 10 | y: number; 11 | z: number; 12 | }; 13 | export declare type Vector4 = { 14 | x: number; 15 | y: number; 16 | z: number; 17 | w: number; 18 | }; 19 | export declare type AABox = { 20 | min: Vector3; 21 | max: Vector3; 22 | }; 23 | export declare type AABox2D = { 24 | min: Vector2; 25 | max: Vector2; 26 | }; 27 | export declare type AABox4D = { 28 | min: Vector4; 29 | max: Vector4; 30 | }; 31 | export declare type Matrix4x4 = { 32 | m11: number; 33 | m12: number; 34 | m13: number; 35 | m14: number; 36 | m21: number; 37 | m22: number; 38 | m23: number; 39 | m24: number; 40 | m31: number; 41 | m32: number; 42 | m33: number; 43 | m34: number; 44 | m41: number; 45 | m42: number; 46 | m43: number; 47 | m44: number; 48 | }; 49 | -------------------------------------------------------------------------------- /src/ts/dist/structures.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * @module vim-ts 4 | */ 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | -------------------------------------------------------------------------------- /src/ts/dist/types/abstractG3d.d.ts: -------------------------------------------------------------------------------- 1 | import { G3dAttribute } from './g3dAttributes'; 2 | import { BFast } from './bfast'; 3 | /** 4 | * G3D is a simple, efficient, generic binary format for storing and transmitting geometry. 5 | * The G3D format is designed to be used either as a serialization format or as an in-memory data structure. 6 | * See https://github.com/vimaec/g3d 7 | */ 8 | export declare class AbstractG3d { 9 | meta: string; 10 | attributes: G3dAttribute[]; 11 | constructor(meta: string, attributes: G3dAttribute[]); 12 | findAttribute(descriptor: string): G3dAttribute | undefined; 13 | /** 14 | * Create g3d from bfast by requesting all necessary buffers individually. 15 | */ 16 | static createFromBfast(bfast: BFast, names: string[]): Promise; 17 | } 18 | -------------------------------------------------------------------------------- /src/ts/dist/types/entityTable.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module vim-ts 3 | */ 4 | import { BFast, NumericArray } from './bfast'; 5 | export declare class EntityTable { 6 | private readonly bfast; 7 | private readonly strings; 8 | constructor(bfast: BFast, strings: string[] | undefined); 9 | getLocal(): Promise; 10 | static getTypeSize(colName: string): number; 11 | getCount(): Promise; 12 | getArray(columnName: string): Promise; 13 | getNumberArray(columnName: string): Promise; 14 | getNumber(elementIndex: number, columnName: string): Promise; 15 | getBigIntArray(columnName: string): Promise; 16 | getBigInt(elementIndex: number, columnName: string): Promise; 17 | getBoolean(elementIndex: number, columnName: string): Promise; 18 | getBooleanArray(columnName: string): Promise; 19 | toIndex(value: number | bigint): number; 20 | getString(elementIndex: number, columnName: string): Promise; 21 | getStringArray(columnName: string): Promise; 22 | } 23 | -------------------------------------------------------------------------------- /src/ts/dist/types/g3dAttributes.d.ts: -------------------------------------------------------------------------------- 1 | export declare class G3dAttributeDescriptor { 2 | description: string; 3 | association: string; 4 | semantic: string; 5 | attributeTypeIndex: string; 6 | dataType: string; 7 | dataArity: number; 8 | constructor(description: string, association: string, semantic: string, attributeTypeIndex: string, dataType: string, dataArity: string); 9 | static fromString(descriptor: string): G3dAttributeDescriptor; 10 | matches(other: G3dAttributeDescriptor): boolean; 11 | } 12 | export declare type TypedArray = Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Uint32Array | BigUint64Array | BigInt64Array | Float64Array; 13 | export declare class G3dAttribute { 14 | descriptor: G3dAttributeDescriptor; 15 | bytes: Uint8Array; 16 | data: TypedArray | undefined; 17 | constructor(descriptor: G3dAttributeDescriptor, bytes: Uint8Array); 18 | static fromString(descriptor: string, buffer: Uint8Array): G3dAttribute; 19 | static castData(bytes: Uint8Array, dataType: string): TypedArray | undefined; 20 | } 21 | -------------------------------------------------------------------------------- /src/ts/dist/types/g3dMaterials.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module vim-ts 3 | */ 4 | import { BFast } from './bfast'; 5 | /** 6 | * See https://github.com/vimaec/vim#vim-geometry-attributes 7 | */ 8 | export declare class MaterialAttributes { 9 | static materialColors: string; 10 | } 11 | /** 12 | * G3D is a simple, efficient, generic binary format for storing and transmitting geometry. 13 | * The G3D format is designed to be used either as a serialization format or as an in-memory data structure. 14 | * A G3d with specific attributes according to the VIM format specification. 15 | * See https://github.com/vimaec/vim#vim-geometry-attributes for the vim specification. 16 | * See https://github.com/vimaec/g3d for the g3d specification. 17 | */ 18 | export declare class G3dMaterial { 19 | static readonly COLOR_SIZE = 4; 20 | static readonly DEFAULT_COLOR: Float32Array; 21 | materialColors: Float32Array; 22 | constructor(materialColors: Float32Array); 23 | static createFromBfast(bfast: BFast): Promise; 24 | getMaterialCount: () => number; 25 | /** 26 | * Returns color of given material as a 4-number array (RGBA) 27 | * @param material g3d material index 28 | */ 29 | getMaterialColor(material: number): Float32Array; 30 | getMaterialAlpha(material: number): number; 31 | } 32 | -------------------------------------------------------------------------------- /src/ts/dist/types/g3dMesh.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module vim-ts 3 | */ 4 | import { G3dChunk } from './g3dChunk'; 5 | import { MeshSection } from './g3d'; 6 | import { G3dScene } from './g3dScene'; 7 | export declare class G3dMesh { 8 | readonly scene: G3dScene; 9 | readonly chunk: G3dChunk; 10 | readonly index: number; 11 | constructor(scene: G3dScene, chunk: G3dChunk, index: number); 12 | getVertexStart(section?: MeshSection): number; 13 | getVertexEnd(section?: MeshSection): number; 14 | getVertexCount(section?: MeshSection): number; 15 | getIndexStart(section?: MeshSection): number; 16 | getIndexEnd(section?: MeshSection): number; 17 | getIndexCount(section?: MeshSection): number; 18 | getHasTransparency(mesh: number): boolean; 19 | getSubmeshStart(section: MeshSection): number; 20 | getSubmeshEnd(section: MeshSection): number; 21 | getSubmeshCount(section: MeshSection): number; 22 | getSubmeshIndexStart(submesh: number): number; 23 | getSubmeshIndexEnd(submesh: number): number; 24 | getSubmeshIndexCount(submesh: number): number; 25 | getSubmeshVertexStart(submesh: number): number; 26 | getSubmeshVertexEnd(submesh: number): number; 27 | getSubmeshVertexCount(submesh: number): number; 28 | } 29 | -------------------------------------------------------------------------------- /src/ts/dist/types/g3dMeshOffsets.d.ts: -------------------------------------------------------------------------------- 1 | import { MeshSection } from "./g3d"; 2 | import { G3dSubset } from "./g3dSubset"; 3 | export declare class G3dMeshCounts { 4 | instances: number; 5 | meshes: number; 6 | indices: number; 7 | vertices: number; 8 | } 9 | /** 10 | * Holds the offsets needed to preallocate geometry for a given meshIndexSubset 11 | */ 12 | export declare class G3dMeshOffsets { 13 | subset: G3dSubset; 14 | section: MeshSection; 15 | counts: G3dMeshCounts; 16 | indexOffsets: Int32Array; 17 | vertexOffsets: Int32Array; 18 | /** 19 | * Computes geometry offsets for given subset and section 20 | * @param subset subset for which to compute offsets 21 | * @param section on of 'opaque' | 'transparent' | 'all' 22 | */ 23 | static fromSubset(subset: G3dSubset, section: MeshSection): G3dMeshOffsets; 24 | getIndexOffset(mesh: number): number; 25 | getVertexOffset(mesh: number): number; 26 | /** 27 | * Returns how many instances of given meshes are the filtered view. 28 | */ 29 | getMeshInstanceCount(mesh: number): number; 30 | /** 31 | * Returns instance for given mesh. 32 | * @mesh view-relative mesh index 33 | * @at view-relative instance index for given mesh 34 | * @returns mesh-relative instance index 35 | */ 36 | getMeshInstance(mesh: number, index: number): number; 37 | /** 38 | * Returns the vim-relative mesh index at given index 39 | */ 40 | getMesh(index: number): number; 41 | } 42 | -------------------------------------------------------------------------------- /src/ts/dist/types/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './bfast'; 2 | export * from './g3d/g3d'; 3 | export * from './remoteVimx'; 4 | export * from './g3d/g3dMaterials'; 5 | export * from './g3d/g3dMesh'; 6 | export * from './g3d/g3dChunk'; 7 | export * from './g3d/g3dScene'; 8 | export * from './http/remoteBuffer'; 9 | export * from './http/requestTracker'; 10 | export * from './http/requester'; 11 | export * from './http/remoteValue'; 12 | export * from './vimHeader'; 13 | export * from './objectModel'; 14 | export * from './structures'; 15 | export * as VimHelpers from './vimHelpers'; 16 | -------------------------------------------------------------------------------- /src/ts/dist/types/logging.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module vim-ts 3 | */ 4 | export declare class Logger { 5 | log: (s: any) => void; 6 | warn: (s: any) => void; 7 | error: (s: any) => void; 8 | } 9 | export declare class DefaultLog implements Logger { 10 | log: (s: any) => void; 11 | warn: (s: any) => void; 12 | error: (s: any) => void; 13 | } 14 | export declare class NoLog implements Logger { 15 | log: (s: any) => void; 16 | warn: (s: any) => void; 17 | error: (s: any) => void; 18 | } 19 | -------------------------------------------------------------------------------- /src/ts/dist/types/remoteBuffer.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module vim-ts 3 | */ 4 | import { Range } from './bfast'; 5 | import { IProgressLogs } from './requestTracker'; 6 | export declare function setRemoteBufferMaxConcurency(value: number): void; 7 | /** 8 | * Wrapper to provide tracking for all webrequests via request logger. 9 | */ 10 | export declare class RemoteBuffer { 11 | url: string; 12 | maxConcurency: number; 13 | onProgress: (progress: IProgressLogs) => void; 14 | private _tracker; 15 | private _logs; 16 | private _queue; 17 | private _active; 18 | private _encoded; 19 | constructor(url: string, verbose?: boolean); 20 | private requestEncoding; 21 | abort(): void; 22 | http(range: Range | undefined, label: string): Promise; 23 | private enqueue; 24 | private retry; 25 | private end; 26 | private next; 27 | } 28 | -------------------------------------------------------------------------------- /src/ts/dist/types/remoteGeometry.d.ts: -------------------------------------------------------------------------------- 1 | import { BFast } from "./bfast"; 2 | import { G3dMaterial as G3dMaterials } from "./g3dMaterials"; 3 | import { G3dMesh } from "./g3dMesh"; 4 | import { G3dScene } from "./g3dScene"; 5 | import { RemoteValue } from "./remoteValue"; 6 | export declare class RemoteGeometry { 7 | bfast: BFast; 8 | scene: RemoteValue; 9 | sceneRaw: RemoteValue; 10 | constructor(bfast: BFast); 11 | static fromPath(path: string): Promise; 12 | /** 13 | * Aborts all downloads from the underlying BFAST. 14 | */ 15 | abort(): void; 16 | /** 17 | * Downloads underlying bfast making all subsequent request local. 18 | */ 19 | download(): Promise; 20 | /** 21 | * Fetches and returns the vimx G3dMeshIndex 22 | */ 23 | private requestIndex; 24 | private requestIndexRaw; 25 | getIndex(): Promise; 26 | getIndexRaw(): Promise; 27 | /** 28 | * Fetches and returns the vimx G3dMaterials 29 | */ 30 | getMaterials(): Promise; 31 | /** 32 | * Fetches and returns the vimx G3dMesh with given index 33 | */ 34 | getMesh(mesh: number): Promise; 35 | /** 36 | * Fetches and returns the vimx G3dMaterials 37 | */ 38 | getMaterialsRaw(): Promise; 39 | /** 40 | * Fetches and returns the vimx G3dMesh with given index 41 | */ 42 | getMeshRaw(mesh: number): Promise; 43 | } 44 | -------------------------------------------------------------------------------- /src/ts/dist/types/remoteValue.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module vim-ts 3 | */ 4 | /** 5 | * Returns a value from cache or queue up existing request or start a new requests 6 | */ 7 | export declare class RemoteValue { 8 | label: string; 9 | private _getter; 10 | private _value; 11 | private _request; 12 | constructor(getter: () => Promise, label?: string); 13 | /** 14 | * Returns a value from cache or queue up existing request or start a new requests 15 | */ 16 | get(): Promise; 17 | } 18 | -------------------------------------------------------------------------------- /src/ts/dist/types/remoteVimx.d.ts: -------------------------------------------------------------------------------- 1 | import { BFast } from "./bfast"; 2 | import { G3dMaterial as G3dMaterials } from "./g3d/g3dMaterials"; 3 | import { G3dChunk } from './g3d/g3dChunk'; 4 | import { G3dScene } from "./g3d/g3dScene"; 5 | import { RemoteValue } from "./http/remoteValue"; 6 | import { G3dMesh } from "./g3d/g3dMesh"; 7 | export declare class RemoteVimx { 8 | bfast: BFast; 9 | scene: RemoteValue; 10 | chunkCache: Map>; 11 | constructor(bfast: BFast); 12 | /** 13 | * Aborts all downloads from the underlying BFAST. 14 | */ 15 | abort(): void; 16 | /** 17 | * Downloads underlying bfast making all subsequent request local. 18 | */ 19 | download(): Promise; 20 | private requestScene; 21 | getHeader(): Promise; 22 | /** 23 | * Fetches and returns the vimx G3dScene 24 | */ 25 | getScene(): Promise; 26 | /** 27 | * Fetches and returns the vimx G3dMaterials 28 | */ 29 | getMaterials(): Promise; 30 | /** 31 | * Fetches and returns the vimx G3dMesh with given index 32 | */ 33 | getChunk(chunk: number): Promise; 34 | private requestChunk; 35 | getMesh(mesh: number): Promise; 36 | } 37 | -------------------------------------------------------------------------------- /src/ts/dist/types/requestTracker.d.ts: -------------------------------------------------------------------------------- 1 | import { Logger } from "./logging"; 2 | /** 3 | * Represents the state of a single web request 4 | */ 5 | declare class Request { 6 | status: 'active' | 'completed' | 'failed'; 7 | field: string; 8 | loaded: number; 9 | total: number; 10 | lengthComputable: boolean; 11 | constructor(field: string); 12 | } 13 | export interface IProgressLogs { 14 | get loaded(): number; 15 | get total(): number; 16 | get all(): Map; 17 | } 18 | /** 19 | * Represents a collection of webrequests 20 | * Will only send update signal at most every delay 21 | * Provides convenient aggregation of metrics. 22 | */ 23 | export declare class RequestTracker { 24 | source: string; 25 | all: Map; 26 | lastUpdate: number; 27 | delay: number; 28 | sleeping: boolean; 29 | logs: Logger; 30 | /** 31 | * callback on update, called at most every delay time. 32 | */ 33 | onUpdate: ((self: RequestTracker) => void) | undefined; 34 | constructor(source: string, logger?: Logger); 35 | /** 36 | * Returns the sum of .loaded across all requests 37 | */ 38 | get loaded(): number; 39 | /** 40 | * Returns the sum of .total across all requests 41 | */ 42 | get total(): number; 43 | /** 44 | * Starts tracking a new web request 45 | */ 46 | start(field: string): void; 47 | /** 48 | * Update an existing web request 49 | */ 50 | update(field: string, progress: ProgressEvent): void; 51 | /** 52 | * Notify a webrequest of failure 53 | */ 54 | fail(field: string): void; 55 | /** 56 | * Notify a webrequest of success 57 | */ 58 | end(field: string): void; 59 | private signal; 60 | } 61 | export {}; 62 | -------------------------------------------------------------------------------- /src/ts/dist/types/requester.d.ts: -------------------------------------------------------------------------------- 1 | import { IProgressLogs } from "./requestTracker"; 2 | /** 3 | * Wrapper to provide tracking for all webrequests via request logger. 4 | */ 5 | export declare class Requester { 6 | maxConcurency: number; 7 | onProgress: (progress: IProgressLogs) => void; 8 | private _tracker; 9 | private _logs; 10 | private _queue; 11 | private _active; 12 | constructor(verbose?: boolean); 13 | abort(): void; 14 | http(url: string, label?: string): Promise; 15 | private enqueue; 16 | private retry; 17 | private end; 18 | private next; 19 | } 20 | -------------------------------------------------------------------------------- /src/ts/dist/types/structures.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module vim-ts 3 | */ 4 | export declare type Vector2 = { 5 | x: number; 6 | y: number; 7 | }; 8 | export declare type Vector3 = { 9 | x: number; 10 | y: number; 11 | z: number; 12 | }; 13 | export declare type Vector4 = { 14 | x: number; 15 | y: number; 16 | z: number; 17 | w: number; 18 | }; 19 | export declare type AABox = { 20 | min: Vector3; 21 | max: Vector3; 22 | }; 23 | export declare type AABox2D = { 24 | min: Vector2; 25 | max: Vector2; 26 | }; 27 | export declare type AABox4D = { 28 | min: Vector4; 29 | max: Vector4; 30 | }; 31 | export declare type Matrix4x4 = { 32 | m11: number; 33 | m12: number; 34 | m13: number; 35 | m14: number; 36 | m21: number; 37 | m22: number; 38 | m23: number; 39 | m24: number; 40 | m31: number; 41 | m32: number; 42 | m33: number; 43 | m34: number; 44 | m41: number; 45 | m42: number; 46 | m43: number; 47 | m44: number; 48 | }; 49 | -------------------------------------------------------------------------------- /src/ts/dist/types/vimHeader.d.ts: -------------------------------------------------------------------------------- 1 | import { BFast } from "./bfast"; 2 | /** 3 | * Representation of VimHeader from the Vim format 4 | * See https://github.com/vimaec/vim#header-buffer 5 | */ 6 | export declare type VimHeader = { 7 | vim: string | undefined; 8 | vimx: string | undefined; 9 | id: string | undefined; 10 | revision: string | undefined; 11 | generator: string | undefined; 12 | created: string | undefined; 13 | schema: string | undefined; 14 | }; 15 | export declare function requestHeader(bfast: BFast): Promise; 16 | -------------------------------------------------------------------------------- /src/ts/dist/types/vimHelpers.d.ts: -------------------------------------------------------------------------------- 1 | import { VimDocument } from "./objectModel"; 2 | /** 3 | * Representation of ElementParameter entity from the entity model 4 | * See https://github.com/vimaec/vim/blob/master/ObjectModel/object-model-schema.json 5 | */ 6 | export declare type ElementParameter = { 7 | name: string | undefined; 8 | value: string | undefined; 9 | group: string | undefined; 10 | isInstance: boolean; 11 | }; 12 | /** 13 | * Returns all parameters of an element and of its family type and family 14 | * @param element element index 15 | * @returns An array of paramters with name, value, group 16 | */ 17 | export declare function getElementParameters(document: VimDocument, element: number): Promise; 18 | export declare function getFamilyElements(document: VimDocument, element: number): Promise; 19 | export declare function getElementsParameters(document: VimDocument, elements: Map): Promise; 20 | -------------------------------------------------------------------------------- /src/ts/dist/types/vimLoader.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module vim-ts 3 | */ 4 | import { BFast } from "./bfast"; 5 | export declare class VimLoader { 6 | static loadFromBfast(bfast: BFast, download: boolean, ignoreStrings: boolean): Promise<[BFast | undefined, string[] | undefined]>; 7 | private static requestStrings; 8 | private static requestEntities; 9 | } 10 | -------------------------------------------------------------------------------- /src/ts/dist/utils.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.isLocalResource = void 0; 4 | function isLocalResource(url) { 5 | // Ensure the URL is a string 6 | if (typeof url !== 'string') { 7 | return false; 8 | } 9 | // Trim whitespace 10 | url = url.trim(); 11 | // Normalize case for consistent comparison 12 | const lowerUrl = url.toLowerCase(); 13 | // Check for 'file://' protocol 14 | if (lowerUrl.startsWith('file://')) { 15 | return true; 16 | } 17 | // Check for Windows drive letter paths (e.g., 'C:/', 'D:/') 18 | if (/^[a-z]:[\\/]/i.test(url)) { 19 | return true; 20 | } 21 | // Check for UNIX-like absolute paths (e.g., '/home/user/file') 22 | if (lowerUrl.startsWith('/')) { 23 | return true; 24 | } 25 | // Check if the URL does not start with a known protocol (assumed to be relative or local) 26 | if (!/^(https?:|ftp:|file:|\/\/)/i.test(url)) { 27 | return true; 28 | } 29 | return false; 30 | } 31 | exports.isLocalResource = isLocalResource; 32 | -------------------------------------------------------------------------------- /src/ts/dist/vimHeader.d.ts: -------------------------------------------------------------------------------- 1 | import { BFast } from "./bfast"; 2 | /** 3 | * Representation of VimHeader from the Vim format 4 | * See https://github.com/vimaec/vim#header-buffer 5 | */ 6 | export declare type VimHeader = { 7 | vim: string | undefined; 8 | vimx: string | undefined; 9 | id: string | undefined; 10 | revision: string | undefined; 11 | generator: string | undefined; 12 | created: string | undefined; 13 | schema: string | undefined; 14 | }; 15 | export declare function requestHeader(bfast: BFast): Promise; 16 | -------------------------------------------------------------------------------- /src/ts/dist/vimHeader.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.requestHeader = void 0; 4 | async function requestHeader(bfast) { 5 | const header = await bfast.getBuffer('header'); 6 | const pairs = new TextDecoder('utf-8').decode(header).split('\n'); 7 | const map = new Map(pairs.map((p) => p.split('=')).map((p) => [p[0], p[1]])); 8 | return { 9 | vim: map.get('vim'), 10 | vimx: map.get('vimx'), 11 | id: map.get('id'), 12 | revision: map.get('revision'), 13 | generator: map.get('generator'), 14 | created: map.get('created'), 15 | schema: map.get('schema') 16 | }; 17 | } 18 | exports.requestHeader = requestHeader; 19 | -------------------------------------------------------------------------------- /src/ts/dist/vimHelpers.d.ts: -------------------------------------------------------------------------------- 1 | import { VimDocument } from "./objectModel"; 2 | /** 3 | * Representation of ElementParameter entity from the entity model 4 | * See https://github.com/vimaec/vim/blob/master/ObjectModel/object-model-schema.json 5 | */ 6 | export declare type ElementParameter = { 7 | name: string | undefined; 8 | value: string | undefined; 9 | group: string | undefined; 10 | isInstance: boolean; 11 | }; 12 | /** 13 | * Returns all parameters of an element and of its family type and family 14 | * @param element element index 15 | * @returns An array of paramters with name, value, group 16 | */ 17 | export declare function getElementParameters(document: VimDocument, element: number): Promise; 18 | export declare function getFamilyElements(document: VimDocument, element: number): Promise; 19 | export declare function getElementsParameters(document: VimDocument, elements: Map): Promise; 20 | -------------------------------------------------------------------------------- /src/ts/dist/vimLoader.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module vim-ts 3 | */ 4 | import { BFast } from "./bfast"; 5 | export declare class VimLoader { 6 | static loadFromBfast(bfast: BFast, ignoreStrings: boolean): Promise<[BFast | undefined, string[] | undefined]>; 7 | private static requestStrings; 8 | private static requestEntities; 9 | } 10 | -------------------------------------------------------------------------------- /src/ts/dist/vimLoader.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * @module vim-ts 4 | */ 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | exports.VimLoader = void 0; 7 | class VimLoader { 8 | static async loadFromBfast(bfast, ignoreStrings) { 9 | const [entity, strings] = await Promise.all([ 10 | VimLoader.requestEntities(bfast), 11 | ignoreStrings ? Promise.resolve(undefined) : VimLoader.requestStrings(bfast) 12 | ]); 13 | return [entity, strings]; 14 | } 15 | static async requestStrings(bfast) { 16 | const buffer = await bfast.getBuffer('strings'); 17 | if (!buffer) { 18 | console.error('Could not get String Data from VIM file. Bim features will be disabled.'); 19 | return; 20 | } 21 | const strings = new TextDecoder('utf-8').decode(buffer).split('\0'); 22 | return strings; 23 | } 24 | static async requestEntities(bfast) { 25 | const entities = await bfast.getBfast('entities'); 26 | if (!entities) { 27 | console.error('Could not get String Data from VIM file. Bim features will be disabled.'); 28 | } 29 | return entities; 30 | } 31 | } 32 | exports.VimLoader = VimLoader; 33 | -------------------------------------------------------------------------------- /src/ts/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | transform: {'^.+\\.ts?$': 'ts-jest'}, 3 | testEnvironment: 'node', 4 | testRegex: '/tests/.*\\.(test|spec)?\\.(ts|tsx)$', 5 | moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'] 6 | }; -------------------------------------------------------------------------------- /src/ts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vim-format", 3 | "version": "1.0.16-dev.3", 4 | "description": "The VIM format is a modern and efficient open 3D data interchange format designed for BIM and manufacturing data optimized for efficient loading and rendering on low-power devices.", 5 | "directories": { 6 | "test": "tests" 7 | }, 8 | "scripts": { 9 | "declarations": "tsc --declaration --emitDeclarationOnly --outdir ./dist/types", 10 | "build": "tsc", 11 | "package": "npm run build && npm run declarations && npm publish", 12 | "test": "jest" 13 | }, 14 | "author": "VIM ", 15 | "license": "MIT", 16 | "repository": { 17 | "type": "git", 18 | "url": "https://github.com/vimaec/vim-ts.git" 19 | }, 20 | "declaration": true, 21 | "types": "dist/index.d.ts", 22 | "module": "/dist/index.js", 23 | "files": [ 24 | "dist/**" 25 | ], 26 | "devDependencies": { 27 | "@types/jest": "^29.5.2", 28 | "@types/node": "^18.16.16", 29 | "@types/pako": "^2.0.0", 30 | "jest": "^29.2.2", 31 | "ts-jest": "^29.0.3", 32 | "typescript": "^4.8.4" 33 | }, 34 | "dependencies": { 35 | "pako": "^2.1.0" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/ts/src/http/logging.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module vim-ts 3 | */ 4 | 5 | 6 | export class Logger{ 7 | log : (s) => void 8 | warn : (s) => void 9 | error : (s) => void 10 | } 11 | 12 | export class DefaultLog implements Logger{ 13 | log = (s) => console.log(s) 14 | warn = (s) => console.warn(s) 15 | error = (s) => console.error(s) 16 | } 17 | 18 | export class NoLog implements Logger{ 19 | log = (s) => {} 20 | warn = (s) => {} 21 | error = (s) => {} 22 | } -------------------------------------------------------------------------------- /src/ts/src/http/remoteValue.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module vim-ts 3 | */ 4 | 5 | /** 6 | * Returns a value from cache or queue up existing request or start a new requests 7 | */ 8 | export class RemoteValue { 9 | label: string 10 | private _getter: () => Promise 11 | private _value: T | undefined 12 | private _request: Promise | undefined 13 | 14 | constructor (getter: () => Promise, label?: string) { 15 | this._getter = getter 16 | this.label = label ?? '' 17 | } 18 | 19 | abort(){ 20 | this._request = undefined 21 | } 22 | 23 | /** 24 | * Returns a value from cache or queue up existing request or start a new requests 25 | */ 26 | get (): Promise { 27 | if (this._value !== undefined) { 28 | // console.log(this.label + ' returning cached value ') 29 | return Promise.resolve(this._value) 30 | } 31 | 32 | if (this._request) { 33 | // console.log(this.label + ' returning existing request') 34 | return this._request 35 | } 36 | 37 | // console.log(this.label + ' creating new request') 38 | this._request = this._getter().then((value) => { 39 | this._value = value 40 | this._request = undefined 41 | return this._value 42 | }) 43 | return this._request 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/ts/src/http/retriableRequest.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | export class RetriableRequest { 4 | url: string; 5 | headers: Record | undefined; 6 | range: string | undefined; 7 | // eslint-disable-next-line no-undef 8 | responseType: XMLHttpRequestResponseType; 9 | msg: string | undefined; 10 | xhr: XMLHttpRequest | undefined; 11 | 12 | constructor( 13 | url: string, 14 | headers: Record | undefined, 15 | range: string | undefined, 16 | // eslint-disable-next-line no-undef 17 | responseType: XMLHttpRequestResponseType 18 | ) { 19 | this.url = url; 20 | this.headers = headers ?? {}; 21 | this.range = range; 22 | this.responseType = responseType; 23 | } 24 | 25 | onLoad: ((result: any) => void) | undefined; 26 | onError: (() => void) | undefined; 27 | onProgress: ((e: ProgressEvent) => void) | undefined; 28 | 29 | abort() { 30 | this.xhr?.abort(); 31 | } 32 | 33 | send() { 34 | this.xhr?.abort(); 35 | const xhr = new XMLHttpRequest(); 36 | xhr.open('GET', this.url); 37 | xhr.responseType = this.responseType; 38 | for (const key in this.headers) { 39 | xhr.setRequestHeader(key, this.headers[key]); 40 | } 41 | 42 | if (this.range) { 43 | xhr.setRequestHeader('Range', this.range); 44 | } 45 | 46 | xhr.onprogress = (e) => { 47 | this.onProgress?.(e); 48 | }; 49 | xhr.onload = (e) => { 50 | this.onProgress?.(e); 51 | this.onLoad?.(xhr.response); 52 | }; 53 | xhr.onerror = (_) => { 54 | this.onError?.(); 55 | }; 56 | xhr.send(); 57 | this.xhr = xhr; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/ts/src/index.ts: -------------------------------------------------------------------------------- 1 | // Links files to generate package type exports 2 | export * from './bfast' 3 | export * from './g3d/g3d' 4 | export * from './remoteVimx' 5 | export * from './g3d/g3dMaterials' 6 | export * from './g3d/g3dMesh' 7 | export * from './g3d/g3dChunk' 8 | export * from './g3d/g3dScene' 9 | export * from './http/remoteBuffer' 10 | export * from './http/requestTracker' 11 | export * from './http/requester' 12 | export * from './http/remoteValue' 13 | 14 | export * from './vimHeader' 15 | export * from './objectModel' 16 | export * from './structures' 17 | export * as VimHelpers from './vimHelpers' -------------------------------------------------------------------------------- /src/ts/src/logging.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module vim-ts 3 | */ 4 | 5 | 6 | export class Logger{ 7 | log : (s) => void 8 | warn : (s) => void 9 | error : (s) => void 10 | } 11 | 12 | export class DefaultLog implements Logger{ 13 | log = (s) => console.log(s) 14 | warn = (s) => console.warn(s) 15 | error = (s) => console.error(s) 16 | } 17 | 18 | export class NoLog implements Logger{ 19 | log = (s) => {} 20 | warn = (s) => {} 21 | error = (s) => {} 22 | } -------------------------------------------------------------------------------- /src/ts/src/structures.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module vim-ts 3 | */ 4 | 5 | export type Vector2 = { 6 | x: number, 7 | y: number 8 | } 9 | 10 | export type Vector3 = { 11 | x: number 12 | y: number 13 | z: number 14 | } 15 | 16 | export type Vector4 = { 17 | x: number 18 | y: number 19 | z: number 20 | w: number 21 | } 22 | 23 | export type AABox = { 24 | min: Vector3 25 | max: Vector3 26 | } 27 | 28 | export type AABox2D = { 29 | min: Vector2 30 | max: Vector2 31 | } 32 | 33 | export type AABox4D = { 34 | min: Vector4 35 | max: Vector4 36 | } 37 | 38 | export type Matrix4x4 = { 39 | m11: number 40 | m12: number 41 | m13: number 42 | m14: number 43 | 44 | m21: number 45 | m22: number 46 | m23: number 47 | m24: number 48 | 49 | m31: number 50 | m32: number 51 | m33: number 52 | m34: number 53 | 54 | m41: number 55 | m42: number 56 | m43: number 57 | m44: number 58 | } -------------------------------------------------------------------------------- /src/ts/src/vimHeader.ts: -------------------------------------------------------------------------------- 1 | import { BFast } from "./bfast" 2 | 3 | /** 4 | * Representation of VimHeader from the Vim format 5 | * See https://github.com/vimaec/vim#header-buffer 6 | */ 7 | export type VimHeader = { 8 | vim: string | undefined 9 | vimx: string | undefined 10 | id: string | undefined 11 | revision: string | undefined 12 | generator: string | undefined 13 | created: string | undefined 14 | schema: string | undefined 15 | } 16 | 17 | export async function requestHeader (bfast: BFast): Promise { 18 | const header = await bfast.getBuffer('header') 19 | const pairs = new TextDecoder('utf-8').decode(header).split('\n') 20 | const map = new Map(pairs.map((p) => p.split('=')).map((p) => [p[0], p[1]])) 21 | return { 22 | vim: map.get('vim'), 23 | vimx: map.get('vimx'), 24 | id: map.get('id'), 25 | revision: map.get('revision'), 26 | generator: map.get('generator'), 27 | created: map.get('created'), 28 | schema: map.get('schema') 29 | } 30 | } -------------------------------------------------------------------------------- /src/ts/src/vimLoader.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module vim-ts 3 | */ 4 | 5 | import { BFast } from "./bfast" 6 | 7 | export class VimLoader { 8 | static async loadFromBfast(bfast: BFast, ignoreStrings: boolean): Promise<[BFast | undefined, string[] | undefined]> { 9 | 10 | const [entity, strings] = await Promise.all([ 11 | 12 | VimLoader.requestEntities(bfast), 13 | ignoreStrings ? Promise.resolve(undefined) : VimLoader.requestStrings(bfast) 14 | ]) 15 | 16 | return [entity, strings] as [BFast, string[]] 17 | } 18 | 19 | private static async requestStrings (bfast: BFast) { 20 | const buffer = await bfast.getBuffer('strings') 21 | if (!buffer) { 22 | console.error('Could not get String Data from VIM file. Bim features will be disabled.') 23 | return 24 | } 25 | const strings = new TextDecoder('utf-8').decode(buffer).split('\0') 26 | return strings 27 | } 28 | 29 | private static async requestEntities (bfast: BFast) { 30 | const entities = await bfast.getBfast('entities') 31 | if (!entities) { 32 | console.error('Could not get String Data from VIM file. Bim features will be disabled.') 33 | } 34 | return entities 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/ts/tests/filter_0.txt: -------------------------------------------------------------------------------- 1 | {"DEFAULT_COLOR":{"0":1,"1":1,"2":1,"3":1},"instanceMeshes":{"0":-1},"instanceFlags":{"0":0},"instanceTransforms":{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":0,"13":0,"14":0,"15":1},"instanceNodes":{"0":0},"meshSubmeshes":{},"submeshIndexOffset":{},"submeshMaterial":{},"indices":{},"positions":{},"materialColors":{},"meshVertexOffsets":{},"meshInstances":[],"meshOpaqueCount":[]} -------------------------------------------------------------------------------- /src/ts/tests/filter_4000.txt: -------------------------------------------------------------------------------- 1 | {"DEFAULT_COLOR":{"0":1,"1":1,"2":1,"3":1},"instanceMeshes":{"0":-1},"instanceFlags":{"0":0},"instanceTransforms":{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":0,"13":0,"14":0,"15":1},"instanceNodes":{"0":4000},"meshSubmeshes":{},"submeshIndexOffset":{},"submeshMaterial":{},"indices":{},"positions":{},"materialColors":{},"meshVertexOffsets":{},"meshInstances":[],"meshOpaqueCount":[]} -------------------------------------------------------------------------------- /src/ts/tests/filter_8059.txt: -------------------------------------------------------------------------------- 1 | {"DEFAULT_COLOR":{"0":1,"1":1,"2":1,"3":1},"instanceMeshes":{"0":-1},"instanceFlags":{"0":0},"instanceTransforms":{"0":1,"1":0,"2":0,"3":0,"4":0,"5":1,"6":0,"7":0,"8":0,"9":0,"10":1,"11":0,"12":0,"13":0,"14":0,"15":1},"instanceNodes":{"0":8059},"meshSubmeshes":{},"submeshIndexOffset":{},"submeshMaterial":{},"indices":{},"positions":{},"materialColors":{},"meshVertexOffsets":{},"meshInstances":[],"meshOpaqueCount":[]} -------------------------------------------------------------------------------- /src/ts/tests/helpers.ts: -------------------------------------------------------------------------------- 1 | import * as fs from 'fs' 2 | export const testVimFilePath = `${__dirname}/../../../data/Wolford_Residence.r2023.om_v4.4.0.vim` 3 | 4 | 5 | export function loadFile(path: string) { 6 | return new Promise((resolve, reject) => { 7 | fs.readFile(path, (err, data) => { 8 | if (err) 9 | reject(err) 10 | else { 11 | var arrbuf = new ArrayBuffer(data.length) 12 | const view = new Uint8Array(arrbuf) 13 | for (var i = 0; i < data.length; i++) { 14 | view[i] = data[i] 15 | } 16 | 17 | resolve(arrbuf) 18 | } 19 | }) 20 | }) 21 | } 22 | -------------------------------------------------------------------------------- /src/ts/tests/vimHelpers.test.ts: -------------------------------------------------------------------------------- 1 | import { VimDocument } from '../src/objectModel' 2 | import { BFast } from '../src/bfast' 3 | import { loadFile, testVimFilePath } from './helpers' 4 | import * as VimHelpers from '../src/vimHelpers' 5 | import * as fs from 'fs'; 6 | 7 | const testFilePath = `${__dirname}/../tests/parameters_119.txt` 8 | 9 | describe('testing vimHelpers.ts getElementParameters', () => { 10 | test('getting element parameters', async () => { 11 | const arrayBuffer = await loadFile(testVimFilePath) 12 | 13 | const bfast = new BFast({buffer: arrayBuffer}) 14 | const doc = await VimDocument.createFromBfast(bfast, false) 15 | const parameters = await VimHelpers.getElementParameters(doc!, 119) 16 | 17 | //fs.writeFileSync(testFilePath, JSON.stringify(parameters)); 18 | 19 | const rawData = fs.readFileSync(testFilePath); 20 | const data = JSON.parse(rawData.toString()); 21 | expect(parameters).toEqual(data) 22 | 23 | }) 24 | }) -------------------------------------------------------------------------------- /src/ts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2020", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "outDir": "dist", 7 | "esModuleInterop": true, 8 | "types": ["jest", "node"] 9 | }, 10 | "exclude": [ 11 | "node_modules", 12 | "dist", 13 | "**/*.spec.ts" 14 | ], 15 | "include": [ 16 | "src/**/*" 17 | ], 18 | "files": [ 19 | "src/index.ts", 20 | ] 21 | } --------------------------------------------------------------------------------