ObjectCloner Issue:

I am trying to use this to clone objects and then be able to control their transforms after they’re created with the originals transforms.

const oc = new BABYLONX.ObjectCloner([cube1, cube2], icoSphere, demo.scene);

But this doesn’t seem to work. I tried getting rid of the “BABYLONX” and it still doesn’t work.

What’s up with this? or is it me?

You need to create first cube1, cube2 and icosphere, and, if you need, change demo.scene to the scene.
(demo.scene variable comes from the helper as here - https://playground.babylonjs.com/#1BKTOH#10 )

Example with ObjectCloner and RandomEffector - https://playground.babylonjs.com/#1NYYEQ#13
Another example - https://playground.babylonjs.com/#JWETXJ#1
Cloner example with extended UI - https://playground.babylonjs.com/#1WRUHY#2

2 Likes

Yeah, it’s awesome….but I am getting an error on this “BABYLONX”.

You need to import this module - Extensions/ClonerSystem/src/babylonx.cloner.ts at master · BabylonJS/Extensions · GitHub

As example, the Playground loads the latest from here:

I did try that and it threw errors for those two top references. I tried finding those and couldn’t find those files anywhere.

Do you use VS Code?
The file is there - https://rawcdn.githack.com/BabylonJS/Extensions/f43ab677b4bca0a6ab77132d3f785be300382760/ClonerSystem/src/babylonx.cloner.js
One may open it in the browser, so there should not be any problems to import what you need.

Yes, I am using VSCode. I did that, and it wouldn’t work I am guessing because it couldn’t resolve these references.

///<reference path=“…/lib/babylon.d.ts” />
///<reference path=”…/lib/babylon.marbleProceduralTexture.d.ts” />

I used NVM to install node. There i snot a lib directory in my babylon directory.

Seems the problem is deeper than I thought :slight_smile:

I thought I would be able to just get rid of the “BABYLONX.” like some of the code has the “BABYLON.” and it usually just works. this is the first time I have seen this X one……But also, I am not using the demo scene…I need this functionality for clones….for them to inherent the originals scaling.

The references being used are for the demo scenes textures……I will just comment that stuff out and see if it will work.

Basically you need the Cloner class and all relevant classes.
You need to import some necessary BABYLON imports to have it work in Node environment.
Then just import the Cloner class as usual class.

This is just the name of Babylon extension (which is not exist and maintained in the main code repo).

Why is this not included?..…I can’t even load it. I stripped out the demo scene stuff so it should work.

Extension repo contains some incredible extensions and resources to Babylon.js, contributions from the amazing community surrounding this platform. While not a part of the main engine, and therefore not maintained by the core Babylon.js development team, the contents of this section contain some incredible technology that you can use to extend your Babylon.js experience even further.

1 Like

Yes I am seeing that…especially with this cloning function. I need it.

How can I get this loaded….I need this in an actual project and do not know how to get this out of the demo scene.

I am using this to load the file just like the demo scene does, and I commented out all the demo scene functions.

CreateScene(): Scene
{
var url = "/src/babylonx.cloner.js”;
var s = document.createElement("script”);
var att = document.createAttribute("async”);
s.setAttributeNode(att);
s.src = url; document.body.appendChild(s);

Is this how I need to load the file?

Seems like the one of the possible methods.
I’ll see what I can do at night :slight_smile:

1 Like

Here is the draft (but working) file which is possible to import, as example

import {
    Cloner,
    RadialCloner,
    ObjectCloner,
    MatrixCloner,
    LinearCloner,
    RandomEffector,
} from "../externals/cloner";

Then use as in the Cloner docs.
Since not all variables are properly typed you may need to use some workarounds as

        const rc = new RadialCloner([sphere, box] as any, scene, {
            count: 12,
            radius: 12,
        });

I think this extension needs a complete rework. Will have a look further :slight_smile:

1 Like

Better version is here

2 Likes

Thank you. I really appreciate your help.

1 Like