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

Merge pull request #19135 from WestLangley/dev_instanced_buffer_geo

InstancedBufferGeometry.maxInstancedCount => .instanceCount
......@@ -24,9 +24,9 @@
<h2>Properties</h2>
<p>See [page:BufferGeometry] for inherited properties.</p>
<h3>[property:Number maxInstancedCount]</h3>
<h3>[property:Number instanceCount]</h3>
<p>
Default is *undefined*.
Default is *Infinity*.
</p>
<h2>Methods</h2>
......
......@@ -24,9 +24,9 @@
<h2>属性</h2>
<p>继承属性详见 [page:BufferGeometry]。</p>
<h3>[property:Number maxInstancedCount]</h3>
<h3>[property:Number instanceCount]</h3>
<p>
默认值是 *undefined*。
默认值是 *Infinity*。
</p>
<h2>方法</h2>
......
......@@ -145,7 +145,7 @@
}
var geometry = new THREE.InstancedBufferGeometry();
geometry.maxInstancedCount = instances; // set so its initalized for dat.GUI, will be set in first draw otherwise
geometry.instanceCount = instances; // set so its initalized for dat.GUI, will be set in first draw otherwise
geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );
......@@ -191,7 +191,7 @@
//
var gui = new GUI( { width: 350 } );
gui.add( geometry, 'maxInstancedCount', 0, instances );
gui.add( geometry, 'instanceCount', 0, instances );
//
......
......@@ -26,6 +26,7 @@ import {
BufferAttribute
} from './core/BufferAttribute.js';
import { BufferGeometry } from './core/BufferGeometry.js';
import { InstancedBufferGeometry } from './core/InstancedBufferGeometry.js';
import { InterleavedBuffer } from './core/InterleavedBuffer.js';
import { Face3 } from './core/Face3.js';
import { Geometry } from './core/Geometry.js';
......@@ -1371,6 +1372,25 @@ Object.defineProperties( BufferGeometry.prototype, {
} );
Object.defineProperties( InstancedBufferGeometry.prototype, {
maxInstancedCount: {
get: function () {
console.warn( 'THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount.' );
return this.instanceCount;
},
set: function ( value ) {
console.warn( 'THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount.' );
this.instanceCount = value;
}
}
} );
Object.defineProperties( Raycaster.prototype, {
linePrecision: {
......
......@@ -8,7 +8,7 @@ export class InstancedBufferGeometry extends BufferGeometry {
constructor();
groups: { start: number; count: number; instances: number }[];
maxInstancedCount: number;
instanceCount: number;
addGroup( start: number, count: number, instances: number ): void;
......
......@@ -9,7 +9,7 @@ function InstancedBufferGeometry() {
BufferGeometry.call( this );
this.type = 'InstancedBufferGeometry';
this.maxInstancedCount = undefined;
this.instanceCount = Infinity;
}
......@@ -23,7 +23,7 @@ InstancedBufferGeometry.prototype = Object.assign( Object.create( BufferGeometry
BufferGeometry.prototype.copy.call( this, source );
this.maxInstancedCount = source.maxInstancedCount;
this.instanceCount = source.instanceCount;
return this;
......@@ -39,7 +39,7 @@ InstancedBufferGeometry.prototype = Object.assign( Object.create( BufferGeometry
var data = BufferGeometry.prototype.toJSON.call( this );
data.maxInstancedCount = this.maxInstancedCount;
data.instanceCount = this.instanceCount;
data.isInstancedBufferGeometry = true;
......
......@@ -875,7 +875,9 @@ function WebGLRenderer( parameters ) {
} else if ( geometry.isInstancedBufferGeometry ) {
renderer.renderInstances( geometry, drawStart, drawCount, geometry.maxInstancedCount );
var instanceCount = Math.min( geometry.instanceCount, geometry._maxInstanceCount );
renderer.renderInstances( geometry, drawStart, drawCount, instanceCount );
} else {
......@@ -934,9 +936,9 @@ function WebGLRenderer( parameters ) {
state.enableAttributeAndDivisor( programAttribute, data.meshPerAttribute );
if ( geometry.maxInstancedCount === undefined ) {
if ( geometry._maxInstanceCount === undefined ) {
geometry.maxInstancedCount = data.meshPerAttribute * data.count;
geometry._maxInstanceCount = data.meshPerAttribute * data.count;
}
......@@ -955,9 +957,9 @@ function WebGLRenderer( parameters ) {
state.enableAttributeAndDivisor( programAttribute, geometryAttribute.meshPerAttribute );
if ( geometry.maxInstancedCount === undefined ) {
if ( geometry._maxInstanceCount === undefined ) {
geometry.maxInstancedCount = geometryAttribute.meshPerAttribute * geometryAttribute.count;
geometry._maxInstanceCount = geometryAttribute.meshPerAttribute * geometryAttribute.count;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册