We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Object Copies?

Home Forums Programming Object Copies?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #1715

    I am working on a scene in which a single object can be instantiated one to many times (1…n).

    I would prefer not to model all possible instances of the object into my original Blender scene and show or hide them. I would rather have a single copy of the object and duplicate it as needed at runtime. This might be more manageable. I think that I could achieve this with the API’s Mesh.clone() method, but before I go and implement this, has anyone attempted something like this before? Please let me know.


    Jeremy Wernick

    Will Welker

    I haven’t heard of anybody doing that yet. That kind of feature is probably on the list. Instancing with Puzzle blocks would be cool.


    Yes, I guess this is the right way to go

    Chief 3D Verger | LinkedIn | Twitter


    I was able to get the object cloning to work. I will share my solution to this problem here for anyone who needs this technique.

    The goal was to create copies of objects at runtime. I needed this because my scenes are assembled from many objects and the quantities of each type object are not known ahead of time. The quantities can be large.

    I wrote a small function that uses the Object3D.clone() method from the API. The function takes two arguments. The srcObjectName is the name of the object to be cloned. The name is assigned in Blender. The targetObjectName is the name of the object to which we will snap the clone. Again, the name is assigned in Blender. The function requests a non-recursive copy. I think that this means clones will share meshes and materials (I may be wrong). Lastly, the function returns the clone. This is important because we need to keep track of the clones. In my example, I place all of the clones in an array so that I may programmatically destroy them later. The clones will not be callable from the puzzles.

        function cloneObject(srcObjectName, targetObjectName) {
            var srcObject = v3dApp.scene.getObjectByName(srcObjectName);
            //Create a shallow copy
            var cloneObject = srcObject.clone(false);
            var targetObject = v3dApp.scene.getObjectByName(targetObjectName);
            //Place the copy
            cloneObject.position.x = targetObject.position.x;
            cloneObject.position.y = targetObject.position.y;
            cloneObject.position.z = targetObject.position.z;
            cloneObject.rotation.x = targetObject.rotation.x;
            cloneObject.rotation.y = targetObject.rotation.y;
            cloneObject.rotation.z = targetObject.rotation.z;
            return cloneObject;

    If you look at the Blender screenshot, you will see that the chessboard is covered with an array of empties. I use these empties as my snapping targets. I found that using the arrows type empty is useful to set the snap orientation.

    Here is a link to the example on the Soft8soft CDN,


    Jeremy Wernick

    Will Welker

    Wow, very nice!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.