Skip to content

Can't add multiple objects using THREE.Scene.prototype.add #162

@dli7319

Description

@dli7319

A custom override on THREE.Scene.prototype.add breaks the engine's native ability to add multiple objects in a single call. When scene.add(object1, object2) is used, only the first object is added to the scene, and the rest are ignored.

Cause

The override function's signature accepts only a single argument (function(object)), so it discards any additional arguments passed to it before calling the original scene.add method.

Proposed Fix

Update the override to use rest parameters (...objects) to capture all arguments into an array. Then, iterate over the array for any custom logic and use originalAdd.apply(this, ...objects) to pass all objects to the original method.
Or alternatively, follow three.js' object.add to call add on each argument: https://github.com/mrdoob/three.js/blob/54ac263593c81b669ca9a089491ddd9e240427d2/src/core/Object3D.js#L720

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions