LoginSignup
2
1

More than 5 years have passed since last update.

CubismJsComponents(Cubism 3 SDK)でメッシュのクリック検出

Posted at

動機

CubismJsComponentsでSDK 2.1のhitTest()みたいなことをしたかった。

結論

containsPoint()を使う。

クリック座標が特定のメッシュ上かどうか

appはPIXI.Application(), modelはPIXI.modelBuilder()で読み込んだもの。

const meshName = {クリックを検出したいメッシュ名}

app.view.addEventListener('click',(e)=>{
  const clickPoint = new PIXI.Point(e.clientX, e.clientY)
  if(model.getModelMeshById(meshName).containsPoint(ClickPoint)){
    console.log("メッシュ上にある!")
  } else {
    console.log("メッシュ上にない!")
  }
})

もっといい方法があれば教えてくださいm(_ _)m

2
1
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
1