X3DObject.GetBoundingBox

導入

v10.0 (2012)

詳細

X3DObject の可視バウンディングの最小および最大座標を戻します。入力変換が指定されている場合、バウンディングボックスの計算時に適用されます。指定されていない場合、オブジェクトのローカル座標空間にあるバウンディングボックスが戻されます。

バウンディングボックスが未定義の場合、最大座標よりも大きな最小座標が戻されます。この状況は、オブジェクトが非表示の場合、またはオブジェクトにジオメトリがない場合に発生します。

注: バウンディングボックスが未定義かどうかを判断する場合、テストが必要な座標は 1 つだけです。(最小X > 最大X)

スクリプト 構文

oArray = X3DObject.GetBoundingBox( [Transform], [Recursive] );

戻り値

6個の値(バウンディングボックスの最小X、Y、Z座標と最大X、Y、Z座標)を含む1DArray

パラメータ

パラメータ タイプ 詳細
変換 SITransformation バウンディングボックスの計算時に適用される変換
Recursive Boolean True の場合は子が含まれ、False の場合は X3DObject のみの入力用バウンディングボックスを戻します。

デフォルト値: False

1. JScript の例

/*
        Example using no input transform
*/
// Create and move (rotate and translate) a torus
NewScene( null, false ) ;
var oTorus = ActiveSceneRoot.AddGeometry( "Torus", "MeshSurface" ) ;
SelectObj( oTorus ) ;
Rotate(null, 45, 0, 0, siAbsolute, siPivot, siObj, siX, null, null, null, null, null, null, null, 0, null) ;
Translate(null, 3, 2, 1, siAbsolute, siPivot, siObj, siX, null, null, null, null, null, null, null, null, null, 0, null) ;
// Find the bounding box
var vba = new VBArray( oTorus.GetBoundingBox() ) ;
var jsa = vba.toArray() ;
// Report the (local) min and max
Application.LogMessage( "min:" + jsa[0] + ", " + jsa[1] + ", " + jsa[2] ) ;
Application.LogMessage( "max:" + jsa[3] + ", " + jsa[4] + ", " + jsa[5] ) ;

2. JScript の例

// Example using an input transform to preserve scaling
//
// Create and move (rotate and translate) a torus
NewScene( null, false ) ;
var oTorus = ActiveSceneRoot.AddGeometry( "Torus", "MeshSurface" ) ;
SelectObj( oTorus ) ;
Scale(null, 0.5, 0.5, 1, siAbsolute, siGlobal, siObj, siY, null, null, null, null, null, null, null, 0, null) ;
oTransform = oTorus.Kinematics.Local.Transform ;
// Find the bounding box
var vba = new VBArray( oTorus.GetBoundingBox(oTransform) ) ;
var jsa = vba.toArray() ;
// Report the min and max
Application.LogMessage( "min:" + jsa[0] + ", " + jsa[1] + ", " + jsa[2] ) ;
Application.LogMessage( "max:" + jsa[3] + ", " + jsa[4] + ", " + jsa[5] ) ;
// Build a cube that shows the bounding box
var oCube = ActiveSceneRoot.AddPrimitive("Cube") ;
oCube.length = 1 ;
oCube.PosX = (jsa[0]+jsa[3])/2 ;
oCube.PosY = (jsa[1]+jsa[4])/2 ;
oCube.PosZ = (jsa[2]+jsa[5])/2 ;
oCube.sclx = jsa[3]-jsa[0] ;
oCube.scly = jsa[4]-jsa[1] ;
oCube.sclz = jsa[5]-jsa[2] ;

関連項目

Geometry.GetBoundingBox Geometry.GetBoundingSphere Geometry.GetBoundingCapsule GetBBox