Skip to content

Commit

Permalink
Update for 0.7.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Sep 27, 2023
1 parent d808af3 commit 2db2177
Show file tree
Hide file tree
Showing 31 changed files with 24,622 additions and 20,144 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## [0.7.1](https://github.com/nicklockwood/Euclid/releases/tag/0.7.1) (2023-09-27)

- Added `Mesh.cubeMapped()` method
- Removed stray `print()` statement

## [0.7.0](https://github.com/nicklockwood/Euclid/releases/tag/0.7.0) (2023-09-23)

- Added `Mesh.icosahedron()` primitive
Expand Down
6 changes: 3 additions & 3 deletions Euclid.docc/ConstructingMeshes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ Euclid offers a number of helper methods to quickly create complex geometry.
The simplest way to create a ``Mesh`` is to start with an existing primitive, such as a cube or sphere.
The following primitive types are available in Euclid, and are defined as static constructor methods on ``Mesh``:

- ``Mesh/cube(center:size:faces:material:)-imdm`` - A cubic ``Mesh`` (or cuboid, if you specify different values for the width, height and/or depth).
- ``Mesh/cube(center:size:faces:wrapMode:material:)-8t5q8`` - A cubic ``Mesh`` (or cuboid, if you specify different values for the width, height and/or depth).
- ``Mesh/sphere(radius:slices:stacks:poleDetail:faces:wrapMode:material:)`` - A spherical `Mesh`.
- ``Mesh/cylinder(radius:height:slices:poleDetail:faces:wrapMode:material:)`` - A cylindrical `Mesh`.
- ``Mesh/cone(radius:height:slices:poleDetail:addDetailAtBottomPole:faces:wrapMode:material:)`` - A conical ``Mesh``.
- ``Mesh/cone(radius:height:slices:stacks:poleDetail:addDetailAtBottomPole:faces:wrapMode:material:)`` - A conical ``Mesh``.

All `Mesh` instances are made of flat polygons.
Since true curves cannot be represented using straight edges, the `sphere`, `cylinder` and `cone` primitives are approximations.
Expand Down Expand Up @@ -80,7 +80,7 @@ The following CSG operations are defined as methods on the ``Mesh`` type:
- ``Mesh/subtracting(_:isCancelled:)`` - Subtracts the volume of one `Mesh` from another.
- ``Mesh/symmetricDifference(_:isCancelled:)-swift.type.method`` - Produces a shape representing the non-overlapping parts of the input `Mesh`es (this is useful for rendering text glyphs).
- ``Mesh/union(_:isCancelled:)-swift.method`` - Combines two intersecting `Mesh`es, removing internal faces and leaving only the outer shell around both shapes (logical OR).
- ``Mesh/intersection(_:isCancelled:)`` - Returns a single ``Mesh`` representing the common volume of two intersecting ``Mesh``es (logical AND).
- ``Mesh/intersection(_:isCancelled:)-swift.method`` - Returns a single ``Mesh`` representing the common volume of two intersecting ``Mesh``es (logical AND).
- ``Mesh/stencil(_:isCancelled:)-swift.method`` - This effectively "paints" part of one ``Mesh`` with the material from another.

All CSG operations require ``Mesh``es that are "watertight", that is they have no holes in their surface.
Expand Down
5 changes: 3 additions & 2 deletions Euclid.docc/Extensions/Mesh.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
### Geometric Primitives

- ``Mesh/cone(radius:height:slices:stacks:poleDetail:addDetailAtBottomPole:faces:wrapMode:material:)``
- ``Mesh/cube(center:size:faces:material:)-7wdr2``
- ``Mesh/cube(center:size:faces:material:)-imdm``
- ``Mesh/cube(center:size:faces:wrapMode:material:)-8t5q8``
- ``Mesh/cube(center:size:faces:wrapMode:material:)-eado``
- ``Mesh/cylinder(radius:height:slices:poleDetail:faces:wrapMode:material:)``
- ``Mesh/sphere(radius:slices:stacks:poleDetail:faces:wrapMode:material:)``
- ``Mesh/icosahedron(radius:faces:wrapMode:material:)``
Expand Down Expand Up @@ -114,6 +114,7 @@
- ``Mesh/withTextureTransform(_:)``
- ``Mesh/sphereMapped()``
- ``Mesh/cylinderMapped()``
- ``Mesh/cubeMapped()``

### Merging Meshes

Expand Down
27 changes: 13 additions & 14 deletions Euclid.docc/RenderingMeshes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ Display the 3D shapes you created with meshes.
## Overview

After creating some 3D shapes, you probably want to actually *display* them.

Most of the Euclid library is completely self-contained, with no dependencies on any particular rendering technology or framework.
However, when running on iOS or macOS you can take advantage of Euclid's built-in SceneKit integration.
This is demonstrated in the Example app included with the project.
However, when running on iOS or macOS you can take advantage of Euclid's built-in SceneKit and RealityKit integration. This is demonstrated in the Example app included with the project.

SceneKit is Apple's high-level 3D engine, which can use either OpenGL or Metal for rendering on supported devices.
Euclid provides extensions for creating an `SCNGeometry` from a ``Mesh``, as well as converting Euclid ``Vector`` and ``Rotation`` types to `SCNVector` and `SCNQuaternion` respectively.
SceneKit is a high-level Apple 3D framework that can use either OpenGL or Metal for rendering on supported devices. Euclid provides extensions for creating an `SCNGeometry` from a ``Mesh``, as well as converting Euclid ``Vector`` and ``Rotation`` types to `SCNVector` and `SCNQuaternion` respectively.

The SceneKit integration makes it easy to display Euclid geometry on-screen, and to integrate with ARKit, etc.
You can also use SceneKit to export Euclid-generated ``Mesh`` in standard 3D model formats such as DAE, STL or OBJ.

RealityKit is a newer Apple framework mainly intended for VR/AR purposes. It is slightly lower-level than SceneKit, and missing some high-level functionality such as camera control, but is equally-well supported by Euclid.

### Materials

Interesting geometry is one thing, but to really bring a shape to life it needs colors and textures.
Expand All @@ -24,30 +25,28 @@ Every ``Polygon`` has a ``Polygon/material-swift.property`` property that can be
All primitives and builder methods accept a `material` parameter which will apply that material to every polygon in the resultant ``Mesh``.
When you later combine meshes using CSG operations, the original materials from the `Mesh` that contributed to each part of the resultant shape are preserved.

Before a material can be used with SceneKit, you need to convert the Euclid material to an `SCNMaterial`.
If the material is already an `SCNMaterial` instance it will be used directly.
If the material is a ``Color``, a `UI/NSColor` or `UI/NSImage` it will be converted to an `SCNMaterial` automatically.
Before a material can be used with SceneKit, you need to convert the Euclid material to an `SCNMaterial`. If the material is already an `SCNMaterial` instance it will be used directly. If the material is a ``Color``, a `CG/UI/NSColor` or `CG/UI/NSImage` it will be converted to an `SCNMaterial` automatically.

For all other material types, you will need to do this conversion yourself.
You can convert materials using the optional closure argument for Euclid's `SCNGeometry` constructor, which receives the Euclid material as an input and returns an `SCNMaterial`.
For all other material types, you will need to do this conversion yourself. You can convert materials using the optional closure argument for Euclid's `SCNGeometry` constructor, which receives the Euclid material as an input and returns an `SCNMaterial`. An equivalent closure exists for Euclid's RealityKit `ModelEntity` constructor.

When serializing Euclid geometry using `Codable`, only specific material types can be supported.
Currently, material serialization works for `String`s, `Int`s, `Color` and any class that conforms to `NSCoding` (which includes many UIKit, AppKit and SceneKit types, such as `UI/NSColor`, `UI/NSImage` and `SCNMaterial`).

### Colors

Euclid currently has no support for setting colors on a per-vertex basis, but you can apply colors to a ``Mesh`` or ``Polygon`` using the material property.
Euclid supports applying colors to a ``Mesh`` or ``Polygon`` using the material property, but you can also set colors individually for each vertex, which will be interpolated to create smooth gradients.

The material property is of type `AnyHashable` which basically means it can be anything you want.
You can set the `material` to an instance of Euclid's ``Color``, or you can use a `UIColor` or `NSColor` instead if you prefer.
The material property is of type `AnyHashable` which basically means it can be anything you want. You can set the `material` to an instance of Euclid's ``Color``, or you can use a `CGColor`, `UIColor` or `NSColor` instead if you prefer.

This approach is demonstrated in the Example app included in the project.

### Textures

Euclid automatically adds 2D texture coordinates to the vertices of a ``Mesh`` created using primitives or builder methods.
There is limited control over how those coordinates are specified at the moment, but they allow for simple spherical and cylindrical texture wrapping.
There is limited control over how those coordinates are specified at the moment, but they allow for simple cylindrical or spherical texture wrapping.

You can also scale, rotate or translate the texture coordinates for a ``Mesh`` by using - ``Mesh/withTextureTransform(_:)``, or remap the texture coordinates completely by using the ``Mesh/sphereMapped()``, ``Mesh/cylinderMapped()`` and ``Mesh/cubeMapped()`` methods. This can be useful for wrapping composite objects that you've created using CSG functions, where the texture coordinates may end up scrambled.

To apply a texture image to a ``Mesh``, store a `UIImage` or `NSImage` as the material property and it will be converted to an `SCNMaterial` automatically.

If you want to do something more complex, such as applying both a color *and* texture to the same ``Mesh``, or maybe including a normal map or some other material properties, you could create a custom material type to store all the properties you care about, or even assign an `SCNMaterial` directly as the material for your Euclid geometry.
If you want to do something more complex, such as applying both a color *and* texture to the same ``Mesh``, or maybe including a normal map or some other material properties, you could create a custom material type to store all the properties you care about, or even assign an `SCNMaterial` or RealityKit `Material` directly.
4 changes: 2 additions & 2 deletions Euclid.podspec.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Euclid",
"version": "0.7.0",
"version": "0.7.1",
"license": {
"type": "MIT",
"file": "LICENSE.md"
Expand All @@ -10,7 +10,7 @@
"authors": "Nick Lockwood",
"source": {
"git": "https://github.com/nicklockwood/Euclid.git",
"tag": "0.7.0"
"tag": "0.7.1"
},
"source_files": "Sources",
"requires_arc": true,
Expand Down
4 changes: 2 additions & 2 deletions Euclid.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@
"@executable_path/../Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 0.7.0;
MARKETING_VERSION = 0.7.1;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14";
OTHER_SWIFT_FLAGS = "-Xfrontend -warn-long-expression-type-checking=75";
Expand Down Expand Up @@ -823,7 +823,7 @@
"@executable_path/../Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 0.7.0;
MARKETING_VERSION = 0.7.1;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14";
OTHER_SWIFT_FLAGS = "-Xfrontend -warn-long-expression-type-checking=75";
Expand Down
1 change: 1 addition & 0 deletions all_identifiers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ doc://com.charcoaldesign.Euclid/documentation/Euclid/Mesh/convexHull(of:material
doc://com.charcoaldesign.Euclid/documentation/Euclid/Mesh/convexHull(of:material:)-91swk
doc://com.charcoaldesign.Euclid/documentation/Euclid/Mesh/cube(center:size:faces:wrapMode:material:)-8t5q8
doc://com.charcoaldesign.Euclid/documentation/Euclid/Mesh/cube(center:size:faces:wrapMode:material:)-eado
doc://com.charcoaldesign.Euclid/documentation/Euclid/Mesh/cubeMapped()
doc://com.charcoaldesign.Euclid/documentation/Euclid/Mesh/cylinder(radius:height:slices:poleDetail:faces:wrapMode:material:)
doc://com.charcoaldesign.Euclid/documentation/Euclid/Mesh/cylinderMapped()
doc://com.charcoaldesign.Euclid/documentation/Euclid/Mesh/detessellate()
Expand Down
1 change: 1 addition & 0 deletions all_symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@
- ``doc://com.charcoaldesign.Euclid/documentation/Euclid/Mesh/convexHull(of:material:)-91swk``
- ``doc://com.charcoaldesign.Euclid/documentation/Euclid/Mesh/cube(center:size:faces:wrapMode:material:)-8t5q8``
- ``doc://com.charcoaldesign.Euclid/documentation/Euclid/Mesh/cube(center:size:faces:wrapMode:material:)-eado``
- ``doc://com.charcoaldesign.Euclid/documentation/Euclid/Mesh/cubeMapped()``
- ``doc://com.charcoaldesign.Euclid/documentation/Euclid/Mesh/cylinder(radius:height:slices:poleDetail:faces:wrapMode:material:)``
- ``doc://com.charcoaldesign.Euclid/documentation/Euclid/Mesh/cylinderMapped()``
- ``doc://com.charcoaldesign.Euclid/documentation/Euclid/Mesh/detessellate()``
Expand Down
Loading

0 comments on commit 2db2177

Please sign in to comment.