:
帯電体:定位置またはアニメーションオブジェクト。他のオブジェクトは が静的なボディに衝突する可能性がありますが、静的なボディ自体は重力や衝突の影響を受けません です。
スタティックボディは衝突の影響を受けません。
動的ではない場合は、目盛りの位置と音量を追跡し、衝突しているかどうかを確認することをお勧めします(プリミティブオブジェクトの場合は簡単にする必要があります)。
2つの球(s(x1、y1、z1)とs2(x2、y2、z2))を使用している場合、シーン内のマスターコンポーネントを、 2ポイントformula:
tick:function(){
if(Math.sqrt(Math.pow((x1-x2),2) + Math.pow((y1-y2),2) + Math.pow((z1-z2),2)))<(sRadius+s2Radius)){
//do stuff when spheres collide
}
}
私が見たものからは、three.jsは独自の交差方法を持っている、あなたがそれらをhere(メソッド:intersect()
、intersectsBox()
、など...)を見つけることができます。 three.jsオブジェクトにアクセスするには、el.object3D
リファレンスを入手してください。
交差オブジェクトは次のように定義される:
{ distance, point, face, faceIndex, indices, object }
distance – distance between the origin of the ray and the intersection
point – point of intersection, in world coordinates
face – intersected face
faceIndex – index of the intersected face
indices – indices of vertices comprising the intersected face
object – the intersected object
three.js documentationで説明したように。
他のプリミティブの交差点については、あなたが思うにアルゴリズムが非常に非効率的であるため、交差点のアルゴリズムを研究する必要があります。
このコンポーネントをビルドする方法を教えてもらえますか?ありがとうございます..... – user287332
@ user287332が更新されました。それは大丈夫ですか、さらに詳しい情報が必要ですか? –
あなたの答えを正しい方向に入れてくれてありがとう....私はコンポーネントのチックでこれを使用しています:function(){firstBB = new THREE.Box3().setFromObject(matchingElements [i] .object3D); \t \t \t \t secondBB = new THREE.Box3().setFromObject(this.el.object3D); \t \t \t \t var collision = firstBB。intersectsBox(secondBB); \t \t \t \t \t \t \t \t 場合(衝突){ \t \t \t \t \t this.el.emit( '衝突'、{値:2、EL:this.el})。 – user287332