LoginSignup
2
0

More than 5 years have passed since last update.

SceneKitでビルボードを使用する (iOS、WatchOS3)

Last updated at Posted at 2016-12-15

SceneKitでビルボードを使用する場合
板ポリゴンを常にカメラに向けたい場合がある。

主に
・簡易的なパーティクルを表示させたい
・テキストをキャラの上に表示させて常にカメラの向きにテキストを向けさせたい

これらの用途をすぐに思い浮かぶことができます。
SceneKitの情報特にビルボードの情報がほぼ見当たらなかったので
情報を公開します。

xxxxxx.m
//板ポリの作成
SCNPlane *plane = [SCNPlane planeWithWidth:6 height:6];
plane.firstMaterial.diffuse.contents = [UIColor redColor];
SCNNode *planeNode = [SCNNode node];
planeNode.geometry = plane;
planeNode.position = SCNVector3Make(0, 4, 0);
[scene.rootNode addChildNode:planeNode];

//ビルボードの設定    
SCNBillboardConstraint *billboard = [SCNBillboardConstraint billboardConstraint];
planeNode.constraints = @[billboard];

余談:
SCNLookAtConstraint というのもある。
これは、あるノードに向きを向けるものでビルボードとは異なるので注意

xxxxxx.m
SCNLookAtConstraint *constraint = [SCNLookAtConstraint lookAtConstraintWithTarget:* 向きを向けたいSCNNode *];
SCNBillboardConstraint *billboard = [SCNBillboardConstraint billboardConstraint];
planeNode.constraints = @[constraint /*,billboard*/];
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0