mred icon indicating copy to clipboard operation
mred copied to clipboard

make, duplicate, destroy, modify a node from a script?

Open blairmacintyre opened this issue 6 years ago • 2 comments

We need the ability to manipulate the scene graph from behaviors.

Some (many) things can be done from scripts. But, @anselm's "garden of flowers" example is one that would be better served this way

  • create a flower object in the scene, with behaviors, perhaps a whole like hierarchy under in, and mark it as hidden
  • create an empty group, and add a behavior which takes that other flower node as a property
  • the script duplicates the flower many times, adding it as a child to itself, positioning it differently, perhaps adjusting properties on the various scripts (e.g., bee-spawn-frequency)

These nodes would last for the life of the player, in the scenes they are in, but would not be saved after play.

blairmacintyre avatar May 16 '19 09:05 blairmacintyre

This can be done already. Create a script property for the node you want to duplicate. Get it's ThreeJS object. Clone that N times in the start() method of the script. Add to a new Three.Group

joshmarinacci avatar May 19 '19 22:05 joshmarinacci

I know I can clone the threejs object. I'm talking about the graph object. With all it's scripts and so forth. Just cloning the visual nodes isn't enough.

blairmacintyre avatar May 19 '19 22:05 blairmacintyre