未验证 提交 a24fe06a 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #13921 from takahirox/BufferGeometryUserData

Add userData to BufferGeometry
......@@ -185,6 +185,12 @@
Optional name for this bufferGeometry instance. Default is an empty string.
</p>
<h3>[property:Object userData]</h3>
<p>
An object that can be used to store custom data about the BufferGeometry. It should not hold
references to functions as these will not be cloned.
</p>
<h3>[property:String uuid]</h3>
<p>
[link:http://en.wikipedia.org/wiki/Universally_unique_identifier UUID] of this object instance.
......
......@@ -38,6 +38,8 @@ function BufferGeometry() {
this.drawRange = { start: 0, count: Infinity };
this.userData = {};
}
BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {
......@@ -928,6 +930,7 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
data.uuid = this.uuid;
data.type = this.type;
if ( this.name !== '' ) data.name = this.name;
if ( Object.keys( this.userData ).length > 0 ) data.userData = this.userData;
if ( this.parameters !== undefined ) {
......@@ -1121,6 +1124,10 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
this.drawRange.start = source.drawRange.start;
this.drawRange.count = source.drawRange.count;
// user data
this.userData = source.userData;
return this;
},
......
......@@ -400,6 +400,7 @@ Object.assign( ObjectLoader.prototype, {
geometry.uuid = data.uuid;
if ( data.name !== undefined ) geometry.name = data.name;
if ( geometry.isBufferGeometry === true && data.userData !== undefined ) geometry.userData = data.userData;
geometries[ data.uuid ] = geometry;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册