提交 5603241c 编写于 作者: M Mr.doob

WebGLObject: Moved code to BufferGeometry.

上级 50a327d1
......@@ -110,7 +110,7 @@ THREE.BufferGeometry.prototype = {
},
fromObject: function ( object ) {
setFromObject: function ( object ) {
var geometry = object.geometry;
var material = object.material;
......@@ -140,6 +140,46 @@ THREE.BufferGeometry.prototype = {
},
updateFromObject: function ( object ) {
var geometry = object.geometry;
if ( object instanceof THREE.PointCloud || object instanceof THREE.Line ) {
if ( geometry.verticesNeedUpdate === true ) {
var attribute = this.attributes.position;
if ( attribute !== undefined ) {
attribute.copyVector3sArray( geometry.vertices );
attribute.needsUpdate = true;
}
geometry.verticesNeedUpdate = false;
}
if ( geometry.colorsNeedUpdate === true ) {
var attribute = this.attributes.color;
if ( attribute !== undefined ) {
attribute.copyColorsArray( geometry.colors );
attribute.needsUpdate = true;
}
geometry.colorsNeedUpdate = false;
}
}
},
fromGeometry: function ( geometry, settings ) {
settings = settings || { 'vertexColors': THREE.NoColors };
......
......@@ -129,7 +129,7 @@ THREE.WebGLObjects = function ( gl, info ) {
} else {
var bufferGeometry = new THREE.BufferGeometry().fromObject( object );
var bufferGeometry = new THREE.BufferGeometry().setFromObject( object );
geometries[ geometry.id ] = bufferGeometry;
console.log( 'THREE.WebGLObjects: Converting...', object, bufferGeometry );
......@@ -174,45 +174,10 @@ THREE.WebGLObjects = function ( gl, info ) {
var geometry = object.geometry;
if ( geometry instanceof THREE.Geometry ) {
if ( object.geometry instanceof THREE.Geometry ) {
var bufferGeometry = geometries[ geometry.id ];
if ( object instanceof THREE.PointCloud || object instanceof THREE.Line ) {
if ( geometry.verticesNeedUpdate === true ) {
var attribute = bufferGeometry.attributes.position;
if ( attribute !== undefined ) {
attribute.copyVector3sArray( geometry.vertices );
attribute.needsUpdate = true;
}
geometry.verticesNeedUpdate = false;
}
if ( geometry.colorsNeedUpdate === true ) {
var attribute = bufferGeometry.attributes.color;
if ( attribute !== undefined ) {
attribute.copyColorsArray( geometry.colors );
attribute.needsUpdate = true;
}
geometry.colorsNeedUpdate = false;
}
}
geometry = bufferGeometry;
geometry = geometries[ geometry.id ];
geometry.updateFromObject( object );
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册