在 SceneKit 中的平面上重复纹理 [英] Repeating a texture over a plane in SceneKit

查看:69
本文介绍了在 SceneKit 中的平面上重复纹理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 32x32 .png 图像,我想在 SCNPlane 上重复该图像.我得到的代码(见下文)导致图像被拉伸以适应平面的大小,而不是重复.

I have a 32x32 .png image that I want to repeat over a SCNPlane. The code I've got (See below) results in the image being stretched to fit the size of the plane, rather than repeated.

代码:

let planeGeo = SCNPlane(width: 15, height: 15)

let imageMaterial = SCNMaterial()
imageMaterial.diffuse.contents = UIImage(named: "art.scnassets/grid.png")

planeGeo.firstMaterial = imageMaterial

let plane = SCNNode(geometry: planeGeo)

plane.geometry?.firstMaterial?.diffuse.wrapS = SCNWrapMode.repeat
plane.geometry?.firstMaterial?.diffuse.wrapT = SCNWrapMode.repeat

推荐答案

我修复了它.好像图像被放大了.如果我执行 imageMaterial.diffuse.contentsTransform = SCNMatrix4MakeScale(32, 32, 0),图像会重复.

I fixed it. It seems like the image was zoomed in. If I do imageMaterial.diffuse.contentsTransform = SCNMatrix4MakeScale(32, 32, 0), the image repeats.

这篇关于在 SceneKit 中的平面上重复纹理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆