From d6515a7ac886dba69714f130468bfde75366a3a5 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Mon, 8 Mar 2021 12:55:12 +0000 Subject: [PATCH] GridHelper: Removed colorCenterLine --- docs/api/en/helpers/GridHelper.html | 5 ++--- src/helpers/GridHelper.js | 21 ++++----------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/docs/api/en/helpers/GridHelper.html b/docs/api/en/helpers/GridHelper.html index 4d347692d3..73d109f786 100644 --- a/docs/api/en/helpers/GridHelper.html +++ b/docs/api/en/helpers/GridHelper.html @@ -30,12 +30,11 @@

Constructor

-

[name]( [param:number size], [param:Number divisions], [param:Color colorCenterLine], [param:Color colorGrid] )

+

[name]( [param:number size], [param:Number divisions], [param:Color color] )

size -- The size of the grid. Default is 10.
divisions -- The number of divisions across the grid. Default is 10.
- colorCenterLine -- The color of the centerline. This can be a [page:Color], a hexadecimal value and an CSS-Color name. Default is 0x444444
- colorGrid -- The color of the lines of the grid. This can be a [page:Color], a hexadecimal value and an CSS-Color name. Default is 0x888888 + color -- The color of the lines of the grid. This can be a [page:Color], a hexadecimal value and an CSS-Color name. Default is 0x888888

Creates a new [name] of size 'size' and divided into 'divisions' segments per side. Colors are optional. diff --git a/src/helpers/GridHelper.js b/src/helpers/GridHelper.js index 6ade28a79e..642f48788d 100644 --- a/src/helpers/GridHelper.js +++ b/src/helpers/GridHelper.js @@ -2,40 +2,27 @@ import { LineSegments } from '../objects/LineSegments.js'; import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; import { Float32BufferAttribute } from '../core/BufferAttribute.js'; import { BufferGeometry } from '../core/BufferGeometry.js'; -import { Color } from '../math/Color.js'; class GridHelper extends LineSegments { - constructor( size = 10, divisions = 10, color1 = 0x444444, color2 = 0x888888 ) { + constructor( size = 10, divisions = 10, color = 0x444444 ) { - color1 = new Color( color1 ); - color2 = new Color( color2 ); - - const center = divisions / 2; const step = size / divisions; const halfSize = size / 2; - const vertices = [], colors = []; + const vertices = []; - for ( let i = 0, j = 0, k = - halfSize; i <= divisions; i ++, k += step ) { + for ( let i = 0, k = - halfSize; i <= divisions; i ++, k += step ) { vertices.push( - halfSize, 0, k, halfSize, 0, k ); vertices.push( k, 0, - halfSize, k, 0, halfSize ); - const color = i === center ? color1 : color2; - - color.toArray( colors, j ); j += 3; - color.toArray( colors, j ); j += 3; - color.toArray( colors, j ); j += 3; - color.toArray( colors, j ); j += 3; - } const geometry = new BufferGeometry(); geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); - geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); - const material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } ); + const material = new LineBasicMaterial( { color: color, toneMapped: false } ); super( geometry, material ); -- GitLab