提交 ddda5973 编写于 作者: W WestLangley

UVsDebug: support BufferGeometry

上级 8c5a94e3
......@@ -6,9 +6,7 @@
* geometries UV mapping
*
* Sample usage:
* document.body.appendChild(
* THREE.UVsDebug(
* new THREE.SphereGeometry(10,10,10,10));
* document.body.appendChild( THREE.UVsDebug( new THREE.SphereGeometry( 10, 10, 10, 10 ) );
*
*/
......@@ -16,7 +14,7 @@ THREE.UVsDebug = function( geometry, size ) {
// handles wrapping of uv.x > 1 only
var abc = 'abcd';
var abc = 'abc';
var uv, u, ax, ay;
var i, il, j, jl;
......@@ -25,8 +23,10 @@ THREE.UVsDebug = function( geometry, size ) {
var a = new THREE.Vector2();
var b = new THREE.Vector2();
var faces = geometry.faces;
var uvs = geometry.faceVertexUvs[ 0 ];
var geo = ( geometry instanceof THREE.BufferGeometry ) ? new THREE.Geometry().fromBufferGeometry( geometry ) : geometry;
var faces = geo.faces;
var uvs = geo.faceVertexUvs[ 0 ];
var canvas = document.createElement( 'canvas' );
var width = size || 1024; // power of 2 required for wrapping
......
......@@ -4,26 +4,39 @@
<meta charset=utf-8 />
<title>three.js - uv mapping tests</title>
</head>
<body>
<script src="../build/three.min.js"></script>
<script src="js/utils/UVsDebug.js"></script>
<script>
/*
* This is to help debug UVs problems in geometry,
* as well as allow a new user to visualize what UVs are about.
*/
function test(name, geometry) {
var d = document.createElement('div');
var d = document.createElement( 'div' );
d.innerHTML = '<br><br>' + name + '<br>';
d.appendChild(THREE.UVsDebug(geometry));
document.body.appendChild(d);
d.appendChild( THREE.UVsDebug( geometry ) );
document.body.appendChild( d );
}
test('new THREE.PlaneGeometry( 100, 100, 4, 4 )', new THREE.PlaneGeometry( 100, 100, 4, 4 ));
test('new THREE.PlaneBufferGeometry( 100, 100, 4, 4 )', new THREE.PlaneBufferGeometry( 100, 100, 4, 4 ));
test('new THREE.SphereGeometry( 75, 12, 6 )', new THREE.SphereGeometry( 75, 12, 6 ));
test('new THREE.IcosahedronGeometry( 30, 1 )', new THREE.IcosahedronGeometry( 30, 1 ));
test('new THREE.OctahedronGeometry( 30, 2 )', new THREE.OctahedronGeometry( 30, 2 ));
test('new THREE.CylinderGeometry( 25, 75, 100, 10, 5 )', new THREE.CylinderGeometry( 25, 75, 100, 10, 5 ));
......@@ -38,10 +51,14 @@
}
test('new THREE.LatheGeometry( points, 8 )', new THREE.LatheGeometry( points, 8 ));
test('new THREE.TorusGeometry( 50, 20, 8, 8 )', new THREE.TorusGeometry( 50, 20, 8, 8 ));
test('new THREE.TorusKnotGeometry( 50, 10, 12, 6 )', new THREE.TorusKnotGeometry( 50, 10, 12, 6 ));
</script>
</body>
</html>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册