Insert3D 1.0.0

Insert3D 1.0.0

Viktor Makarskyy 维护。



Insert3D 1.0.0

Insert3D 是将 3D 模型嵌入您的 iOS 应用中最简单、最快的方式。它将 SceneKit 和 Model I/O 合并成一个简单的库,供想在用户中获得独特体验的创意 iOS 开发者使用。🚀使用 Insert3D,您可以快速、轻松地将 3D 模型嵌入您的 iOS 应用中。它集成了 SceneKit 和 Model I/O,为希望为用户提供独特体验的 iOS 开发者提供了一个简单易用的库。

安装

使用 CocoaPods。将依赖添加到您的 Podfile 中,然后运行 pod install

pod 'Insert3D'

快速入门

  1. 导入库
import Insert3D
  1. 下载并添加示例 OBJ 模型(example-model.zip

  2. 复制并粘贴到 viewDidLoad

var viewer = Insert3DViewer() 
	viewer.width = 380 
	viewer.height = 380

var model = Insert3DModel()
	model.mesh = "model/Nachos.obj"
	model.material = "model/NachosMaterial.jpg"

view.Insert3D(viewerSetup: viewer, modelSetup: model)

使用

创建 Insert3DViewer()Insert3DModel() 的实例,并指定参数,然后将这些实例传递给主 view.Insert3D() 函数以完成设置并显示查看器。

Command + R 运行

查看器

Insert3DViewer() 的实例设置包含模型的中央节点的 SCNView 子视图的尺寸和位置。

// Values can be progromatically set and adjusted at any time 
var viewer = Insert3DViewer() 
viewer.width = 380 // Width 
viewer.height = 380 // Height 
viewer.x = 20 // X position of the top left corner
viewer.y = 200 // Y position of the top left corner

viewer.background = UIColor.white // Specify background of viewer. White by default 

// Show the model! 
view.Insert3D(viewerSetup: viewer, modelSetup: model) // modelSetup is also required

尺寸

使用屏幕相对位置表示尺寸可以通过将它们转换为 Int 来表示(详情见此处描述)。

默认值宽度 = 200,高度 = 200,x = 0,y = 0。

背景

背景支持 Any,为使用提供了很大灵活性。

模型

Insert3DModel() 实例让 Insert3D 了解您想使用的模型,以及如何配置它在查看器中的设置。

// Values can be progromatically set and adjusted at any time.
var model = Insert3DModel()
model.mesh = "my3DFilePath" // Currently supports OBJ
model.texture = "myTexturePath" // Supports image files already mapped to the model

model.autoRotate = true // Set true by default. Rotates on the horizontal axis
model.rotationSpeed = 9 // Model makes one full rotation every 9 seconds

model.fixed = false // Set false by deafault. Should the model be movable/rotatable by a user?

// Show the model!
view.Insert3D(viewerSetup: viewer, modelSetup: model) // viewerSetup is also required

注意:您可以为模型应用无限多的自定义设置,这里包括基本的设置。考虑通过贡献来扩展此仓库的功能。

贡献

  1. 分支( https://github.com/Viktoo/Insert3D/fork )。
  2. 创建您的新特性分支(git checkout -b my-new-feature)。
  3. 提交您的更改(git commit -am '添加一些特性')。
  4. 将更改推送到分支(git push origin my-new-feature)。
  5. 创建新的拉取请求。

许可证

本项目遵循BSD 2-Clause "简化版" 许可协议发布