基于之前的问题:Outline object (normal scale + stencil mask) three.js
我正在尝试为threejs创建一个材质着色器,以仅渲染轮廓,而不是同时渲染对象。这应该是正确的参考还是有更直接的方式来做到这一点?
答案 0 :(得分:0)
目前,我能找到的最直接的解决方案来自:https://stemkoski.github.io/Three.js/Outline.html,在其材质中使用@IBOutlet weak var scrollView: UIScrollView!
override func viewDidLoad() {
super.viewDidLoad()
let story = UIStoryboard(name: "Main", bundle: nil)
let vc1 = story.instantiateViewController(withIdentifier: "AViewController")
let vc2 = story.instantiateViewController(withIdentifier: "BViewController")
vc1.view.backgroundColor = UIColor.green
vc2.view.backgroundColor = UIColor.red
addContentView([vc1, vc2])
}
func addContentView(_ viewControllers: [UIViewController]) {
var previousController: UIViewController? = nil
viewControllers.forEach {
addChildViewController($0)
$0.view.translatesAutoresizingMaskIntoConstraints = false
scrollView.addSubview($0.view)
$0.view.widthAnchor.constraint(equalTo: scrollView.widthAnchor).isActive = true
$0.view.heightAnchor.constraint(equalTo: scrollView.heightAnchor).isActive = true
if let trailing = previousController?.view.trailingAnchor {
$0.view.leadingAnchor.constraint(equalTo: trailing).isActive = true
} else {
$0.view.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor).isActive = true
}
$0.view.topAnchor.constraint(equalTo: scrollView.topAnchor).isActive = true
$0.view.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor).isActive = true
didMove(toParentViewController: self)
previousController = $0
}
previousController?.view.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor).isActive = true
}
param进行略微缩放的行进立方体。