Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/objects/Line.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Line extends Object3D {

super.copy( source, recursive );

this.material = source.material;
this.material = Array.isArray( source.material ) ? source.material.slice() : source.material;
this.geometry = source.geometry;

return this;
Expand Down
2 changes: 1 addition & 1 deletion src/objects/Mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Mesh extends Object3D {

}

this.material = source.material;
this.material = Array.isArray( source.material ) ? source.material.slice() : source.material;
this.geometry = source.geometry;

return this;
Expand Down
2 changes: 1 addition & 1 deletion src/objects/Points.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Points extends Object3D {

super.copy( source, recursive );

this.material = source.material;
this.material = Array.isArray( source.material ) ? source.material.slice() : source.material;
this.geometry = source.geometry;

return this;
Expand Down
18 changes: 18 additions & 0 deletions test/unit/src/objects/Line.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { Line } from '../../../../src/objects/Line.js';

import { Object3D } from '../../../../src/core/Object3D.js';
import { Material } from '../../../../src/materials/Material.js';

export default QUnit.module( 'Objects', () => {

Expand Down Expand Up @@ -67,6 +68,23 @@ export default QUnit.module( 'Objects', () => {

} );

QUnit.test( 'copy/material', ( assert ) => {

// Material arrays are cloned
const mesh1 = new Line();
mesh1.material = [ new Material() ];

const copy1 = mesh1.clone();
assert.notStrictEqual( mesh1.material, copy1.material );

// Non arrays are not cloned
const mesh2 = new Line();
mesh1.material = new Material();
const copy2 = mesh2.clone();
assert.strictEqual( mesh2.material, copy2.material );

} );

QUnit.todo( 'computeLineDistances', ( assert ) => {

assert.ok( false, 'everything\'s gonna be alright' );
Expand Down
18 changes: 18 additions & 0 deletions test/unit/src/objects/Mesh.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { MeshBasicMaterial } from '../../../../src/materials/MeshBasicMaterial.j
import { Vector2 } from '../../../../src/math/Vector2.js';
import { Vector3 } from '../../../../src/math/Vector3.js';
import { DoubleSide } from '../../../../src/constants.js';
import { Material } from '../../../../src/materials/Material.js';

export default QUnit.module( 'Objects', () => {

Expand Down Expand Up @@ -73,6 +74,23 @@ export default QUnit.module( 'Objects', () => {

} );

QUnit.test( 'copy/material', ( assert ) => {

// Material arrays are cloned
const mesh1 = new Mesh();
mesh1.material = [ new Material() ];

const copy1 = mesh1.clone();
assert.notStrictEqual( mesh1.material, copy1.material );

// Non arrays are not cloned
const mesh2 = new Mesh();
mesh1.material = new Material();
const copy2 = mesh2.clone();
assert.strictEqual( mesh2.material, copy2.material );

} );

QUnit.todo( 'updateMorphTargets', ( assert ) => {

assert.ok( false, 'everything\'s gonna be alright' );
Expand Down
18 changes: 18 additions & 0 deletions test/unit/src/objects/Points.tests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* global QUnit */

import { Object3D } from '../../../../src/core/Object3D.js';
import { Material } from '../../../../src/materials/Material.js';
import { Points } from '../../../../src/objects/Points.js';

export default QUnit.module( 'Objects', () => {
Expand Down Expand Up @@ -66,6 +67,23 @@ export default QUnit.module( 'Objects', () => {

} );

QUnit.test( 'copy/material', ( assert ) => {

// Material arrays are cloned
const mesh1 = new Points();
mesh1.material = [ new Material() ];

const copy1 = mesh1.clone();
assert.notStrictEqual( mesh1.material, copy1.material );

// Non arrays are not cloned
const mesh2 = new Points();
mesh1.material = new Material();
const copy2 = mesh2.clone();
assert.strictEqual( mesh2.material, copy2.material );

} );

QUnit.todo( 'raycast', ( assert ) => {

assert.ok( false, 'everything\'s gonna be alright' );
Expand Down