未验证 提交 75a5d82d 编写于 作者: M Michael Herzog 提交者: GitHub

Merge pull request #18164 from Mugen87/dev29

GLTFLoader: Make .computeBounds() more robust.
...@@ -2291,12 +2291,23 @@ THREE.GLTFLoader = ( function () { ...@@ -2291,12 +2291,23 @@ THREE.GLTFLoader = ( function () {
if ( attributes.POSITION !== undefined ) { if ( attributes.POSITION !== undefined ) {
var accessor = parser.json.accessors[ attributes.POSITION ]; var accessor = parser.json.accessors[ attributes.POSITION ];
var min = accessor.min; var min = accessor.min;
var max = accessor.max; var max = accessor.max;
box.set( // glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement.
new THREE.Vector3( min[ 0 ], min[ 1 ], min[ 2 ] ),
new THREE.Vector3( max[ 0 ], max[ 1 ], max[ 2 ] ) ); if ( min !== undefined && max !== undefined ) {
box.set(
new THREE.Vector3( min[ 0 ], min[ 1 ], min[ 2 ] ),
new THREE.Vector3( max[ 0 ], max[ 1 ], max[ 2 ] ) );
} else {
return;
}
} else { } else {
...@@ -2320,12 +2331,18 @@ THREE.GLTFLoader = ( function () { ...@@ -2320,12 +2331,18 @@ THREE.GLTFLoader = ( function () {
var min = accessor.min; var min = accessor.min;
var max = accessor.max; var max = accessor.max;
// we need to get max of absolute components because target weight is [-1,1] // glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement.
vector.setX( Math.max( Math.abs( min[ 0 ] ), Math.abs( max[ 0 ] ) ) );
vector.setY( Math.max( Math.abs( min[ 1 ] ), Math.abs( max[ 1 ] ) ) ); if ( min !== undefined && max !== undefined ) {
vector.setZ( Math.max( Math.abs( min[ 2 ] ), Math.abs( max[ 2 ] ) ) );
box.expandByVector( vector ); // we need to get max of absolute components because target weight is [-1,1]
vector.setX( Math.max( Math.abs( min[ 0 ] ), Math.abs( max[ 0 ] ) ) );
vector.setY( Math.max( Math.abs( min[ 1 ] ), Math.abs( max[ 1 ] ) ) );
vector.setZ( Math.max( Math.abs( min[ 2 ] ), Math.abs( max[ 2 ] ) ) );
box.expandByVector( vector );
}
} }
......
...@@ -2358,12 +2358,23 @@ var GLTFLoader = ( function () { ...@@ -2358,12 +2358,23 @@ var GLTFLoader = ( function () {
if ( attributes.POSITION !== undefined ) { if ( attributes.POSITION !== undefined ) {
var accessor = parser.json.accessors[ attributes.POSITION ]; var accessor = parser.json.accessors[ attributes.POSITION ];
var min = accessor.min; var min = accessor.min;
var max = accessor.max; var max = accessor.max;
box.set( // glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement.
new Vector3( min[ 0 ], min[ 1 ], min[ 2 ] ),
new Vector3( max[ 0 ], max[ 1 ], max[ 2 ] ) ); if ( min !== undefined && max !== undefined ) {
box.set(
new Vector3( min[ 0 ], min[ 1 ], min[ 2 ] ),
new Vector3( max[ 0 ], max[ 1 ], max[ 2 ] ) );
} else {
return;
}
} else { } else {
...@@ -2387,12 +2398,18 @@ var GLTFLoader = ( function () { ...@@ -2387,12 +2398,18 @@ var GLTFLoader = ( function () {
var min = accessor.min; var min = accessor.min;
var max = accessor.max; var max = accessor.max;
// we need to get max of absolute components because target weight is [-1,1] // glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement.
vector.setX( Math.max( Math.abs( min[ 0 ] ), Math.abs( max[ 0 ] ) ) );
vector.setY( Math.max( Math.abs( min[ 1 ] ), Math.abs( max[ 1 ] ) ) ); if ( min !== undefined && max !== undefined ) {
vector.setZ( Math.max( Math.abs( min[ 2 ] ), Math.abs( max[ 2 ] ) ) );
box.expandByVector( vector ); // we need to get max of absolute components because target weight is [-1,1]
vector.setX( Math.max( Math.abs( min[ 0 ] ), Math.abs( max[ 0 ] ) ) );
vector.setY( Math.max( Math.abs( min[ 1 ] ), Math.abs( max[ 1 ] ) ) );
vector.setZ( Math.max( Math.abs( min[ 2 ] ), Math.abs( max[ 2 ] ) ) );
box.expandByVector( vector );
}
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册