Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Object3D.js #30341

Closed
wants to merge 2 commits into from
Closed
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
33 changes: 33 additions & 0 deletions src/core/Object3D.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import { Layers } from './Layers.js';
import { Matrix3 } from '../math/Matrix3.js';
import { generateUUID } from '../math/MathUtils.js';
import { BufferAttribute } from './BufferAttribute.js';
import { BufferGeometry} from './BufferGeometry.js';

Check failure on line 10 in src/core/Object3D.js

View workflow job for this annotation

GitHub Actions / Lint testing

A space is required before '}'

let _object3DId = 0;

Expand Down Expand Up @@ -962,13 +964,44 @@

}


clone( recursive ) {

return new this.constructor().copy( this, recursive );

}

copy( source, recursive = true ) {

Check failure on line 975 in src/core/Object3D.js

View workflow job for this annotation

GitHub Actions / Lint testing

Trailing spaces not allowed

Check failure on line 976 in src/core/Object3D.js

View workflow job for this annotation

GitHub Actions / Lint testing

Trailing spaces not allowed
if( recursivie ){

Check failure on line 977 in src/core/Object3D.js

View workflow job for this annotation

GitHub Actions / Lint testing

Expected space(s) after "if"

Check warning on line 977 in src/core/Object3D.js

View workflow job for this annotation

GitHub Actions / Lint testing

'recursivie' is not defined

Check failure on line 977 in src/core/Object3D.js

View workflow job for this annotation

GitHub Actions / Lint testing

Missing space before opening brace

// Copy VALUES, not just references to the source Attribute array
// This fixes e.g. 'cumulative rotations' etc, for clones which would
// apply transformations to their predecessors, otherwise

let originalGeometry = source.geometry;

Check failure on line 983 in src/core/Object3D.js

View workflow job for this annotation

GitHub Actions / Lint testing

'originalGeometry' is never reassigned. Use 'const' instead
let newGeometry = new BufferGeometry();

Check failure on line 984 in src/core/Object3D.js

View workflow job for this annotation

GitHub Actions / Lint testing

'newGeometry' is never reassigned. Use 'const' instead

// create new containers for attributes
Object.keys(originalGeometry.attributes).forEach((key, idx) => {

Check failure on line 987 in src/core/Object3D.js

View workflow job for this annotation

GitHub Actions / Lint testing

There must be a space after this paren

Check failure on line 987 in src/core/Object3D.js

View workflow job for this annotation

GitHub Actions / Lint testing

There must be a space before this paren

Check failure on line 987 in src/core/Object3D.js

View workflow job for this annotation

GitHub Actions / Lint testing

There must be a space after this paren

Check warning on line 987 in src/core/Object3D.js

View workflow job for this annotation

GitHub Actions / Lint testing

'idx' is defined but never used

// get, use the correct 'typed array', dimension it
var arrayType = (''+originalGeometry.attributes[key].array.constructor).split(' ')[1].split('(')[0];
newGeometry.attributes[key] = new BufferAttribute(new window[arrayType](
originalGeometry.attributes[key].array.length),
originalGeometry.attributes[key].itemSize,
originalGeometry.attributes[key].normalized )

// ...and copy values into them
originalGeometry.attributes[key].array.forEach((v, i) => {
newGeometry.attributes[key].array[i] = originalGeometry.attributes[key].array[i];
});
})

Check notice

Code scanning / CodeQL

Semicolon insertion Note

Avoid automated semicolon insertion (96% of all statements in
the enclosing function
have an explicit semicolon).

this.source.geometry = newGeometry;
}


this.name = source.name;

Expand Down
Loading