Search the Community

Showing results for tags 'clone'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Coding and Game Design
  • Frameworks
    • Phaser
    • Pixi.js
    • Babylon.js
    • Panda.js
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 32 results

  1. I've successfully cloned a mesh and its skeleton with this code: this.mesh = Assets.avatar.clone(JSON.idx); this.mesh.skeleton = Assets.avatar.skeleton.clone(JSON.idx); I then run an animation like this: this.mesh.skeleton.beginAnimation("Idle",true,1); This works well on Windows browsers. I can have 10 people moving about with their own separate animations. Some running, some walking and some idle. However, this doesn't work on iPhone and iPad. If I animate one of the meshes then all of them will activate the same animation. If one is running then ALL of them will be running. Its as if they are all referencing the same animation. Does anyone know how I can get this to work on iPhone?
  2. Hello, When cloning a material - say, a BABYLON.StandardMaterial -, everything is fine except for renderTargetTexture. PG: material.clone() function calls renderTargetTexture.clone() function. But renderTargetTexture.clone() function creates a new empty RenderTargetTexture with the same properties. Btw, I'm sure that adding "scene.customRenderTargetTextures.push()" at the end of the clone function would resolve this issue. But I don't think that people want to create a new RTT each time they clone a material (it would kill the app, especially on iOS devices). Not sure about which behaviour adopt here, any idea ? Thanks !
  3. I'm trying to make a menu like option to where the user can drag a sprite on screen and make a clone out of it leaving the other sprite on it's original location. This is what I have up untill now. var box = game.add.sprite(100, 200, 'box', 0); box.anchor.set(0); box.inputEnabled = true;, this, 0, box); function clone(obj){ var clone = game.add.sprite(obj.x, obj.y, obj.key, obj.frame); clone.inputEnabled = true; clone.input.enableDrag(true); } Only down side is I have to click twice on the sprite in order for there to be a copy of it which kind of takes away the whole purpose of a copy on drag function. Any help would be greatly appreciated. (I'm quite new to Phaser and js so I'm sorry for any obvious mistakes beforehand) Thanks in advance!
  4. I try to optimize one of my scene and to do so I adapt my code to use createInstance instead of clone. But as a result my scene (fps) is slower with createInstance than with clone when it should be the opposite right? To sum up my code, here is the steps I follow : - import mesh - clone mesh and add material (because one mesh can have 2 different materials) - create instance mesh - add in the scene At the third step, I get a better fps when I use clone instead of createinstance. Do you have an idea? Thanks!
  5. Is there a way to clone an imported mesh to use it in a different scene? I try to change the _scene parameter of the mesh like that : this.mesh._scene = newscene; but I got an error. It seems like I must import all my meshes twice in both of my scenes. Unfortunetly it will increase the loading time. Looking for suggestions! Thanks
  6. When i recreate texture or material, clone/dispose created more one texture (clone logic incorrect material.texture.clone() and material._texture.clone()) example this is very important for dynamic scene, please fix source ** I tryed run in this latest version and saw what recreate correctry, but i not undersend how... and other -- i see what canvas2D will be not suported in future? I see GUI, this is very cool feature, but GIU can't do many tasks... Tell me whether it is possible to work with canvas2d in babylon.js 3.0, or will the support be returned in the future?
  7. Hi, I have question about creating meshes based on one prototype. I have multiple meshes, that have same geometry but should have different material (color), idea was to create prototype mesh in 3d max, add bump map and export it. Than I found that Mesh class have source mesh, so I passed my prototype mesh into mesh constructor: PG So far everything was working I could create new meshes and change material for them. But problems started when I tried to create instances from new meshes as all instances where moved to same position: PG But if I make clones from meshes they work: PG Was it designed to be used like that, or I am overusing system Maybe there is better way to achieve same result? prototype -> different meshes -> instances. @Deltakosh some ideas there?
  8. Hi, I want to clone meshes that I load with the obj loader. The problem seems to be that the material is assigned somewhat later, so when I clone the mesh directly in the callback from the SceneLoader.ImportMesh function, it has no material. If I make another clone from the very same instance some time later, it has material. For example this would lead to no material in the clone: BABYLON.SceneLoader.ImportMesh("", this.serverUrl, encodeURIComponent(fileName + ".obj"), this.scene, (mesh) => { meshContainer = mesh.clone(name, undefined, false); resolve(meshContainer); } while this would: BABYLON.SceneLoader.ImportMesh("", this.serverUrl, encodeURIComponent(fileName + ".obj"), this.scene, (mesh) => { setTimeout(() => { meshContainer = mesh.clone(name, undefined, false); resolve(meshContainer); }, 100); } (It is wrapped inside a Promise) Is this an expected behaviour? Is it possible to get the callback when everything is loaded completely? Many thanks, Cheers, janx
  9. Hi, after loading incremental scene file on load finish I cloned one of mesh BABYLON.SceneLoader.Load("", scenePath, this.engine, (scene) => { scene.meshes.forEach((mesh) => { if( === "m1") { mesh.clone("m2", mesh.parent, false, false); mesh.clone("m3", mesh.parent, false, false); } }); }); Probably it was not designed to work like that but every thing works as expected but I get console errors _this._delayLoadingFunction is not a function inside: Mesh.prototype._queueLoad = function (mesh, scene) { var _this = this; scene._addPendingData(mesh); var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1); BABYLON.Tools.LoadFile(this.delayLoadingFile, function (data) { if (data instanceof ArrayBuffer) { _this._delayLoadingFunction(data, _this); } else { _this._delayLoadingFunction(JSON.parse(data), _this); } _this.instances.forEach(function (instance) { instance._syncSubMeshes(); }); _this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_LOADED; scene._removePendingData(_this); }, function () { }, scene.database, getBinaryData); return this; };
  10. Simple Cloner System (SCS)

    Hi all, I've implemented a basic-functionality of a cloner system and I'd like to hear your opinions and design/concept-suggestions for further develepment and finishing my work (if you're interested at all). I decided to use a working title "SCS" for "Simple Cloning System" and here are the core features and concepts : Cloners: given one or several meshes, either clones or instances will distributed in a specific manner. If more than one mesh is provided, the meshes are distributed alternatively. Additionally, cloners can be nested, so it is possible to clone cloners. Each cloner can have several Effectors (in particular order) to influence the Scale/Position/Rotation parameter of a clone (or cloner). A sensitivity parameter controls this influence for a cloner. Following Objects are designated: RadialCloner: radial distribution where following parameters are recognized: count, radius, offset, startangle, endangle, Effector-sensitivity for Position, Scale and Rotation, alignment-flag, orientation. LinearCloner: linear distribution where following parameters are recognized:count, offset, growth, Effector-sensitivity for Position, Scale and Rotation. An interpolation-mode-flag determines, if the clone -parameters (Scale/Position/Rotation) are interpreted as "step" or "end"-values. MatrixCloner: coming soon (clones will be distributed in 3D space) PlanarCloner: coming soon (clones will be distributed in 2D space) ObjectCloner: coming soon (clones will be distributed in relation to the internals of a given mesh (vertices, edges, triangles ...) RandomEffector: influences Scale/Position/Rotation of a clone with repeatable random values, controlled with an overall "strength" parameter. Not quite finished, but basically working. FormulaEffector: coming soon, influences Scale/Position/Rotation via text thought to control from outside (html-page). StepEffector, TimeEcffector, DelayEffector and much more ??? So, enough for the moment, you can see and play with some scenes: LinearCloner,RadialCloner,RandomEffector radial-linear-radial-cloner linear-radial-linear-cloner PS: I need some advise if I should upload the sources to github if you're interested. Should I upload it to my own github space or to BABYLONX ? If the latter, do I have to send a pull request? Sources are written in typescript
  11. Hey! I will just link the relevant code and then ask the question (ignore the material parameter, is from an older build still have to get rid of it): function GenerateRandomObject(scene, material){ var nekej = BABYLON.Mesh.CreateBox("box1", 1, scene); nekej.position = new BABYLON.Vector3(getRandom(8, 90, true), 0.5, 90); nekej.rotation.y = getRandom(0, 360, true); nekej.isVisible = false; BABYLON.SceneLoader.ImportMesh("", "_resources/", "Drevo2.babylon", scene, function (newMeshes, particleSystems) { newMeshes[0].parent = nekej; }); return nekej; } So this is the way I create every new instance of a background object. This happens about 0.5 - 2 times every second for this type of object. More with others that I create with similar functions just different imported meshes. So my question is if there is a better way to import/use an imported mesh so i would not need to import the same mesh over and over again every single time i create a new object with that mesh. Thank you very much for any answers you might provide, with best regards, Satiana
  12. hi, I tried to create instances of meshes, basically cloned my loaded meshes and then create instances of that clones, but run into issue. some instances created fine but others throws in console "[.CommandBufferContext.Offscreen-MainThread-0x12d4118a0a00]GL ERROR :GL_INVALID_OPERATION : glDrawElementsInstancedANGLE: attempt to access out of range vertices in attribute 2" during render. I also created small demo . looks like this errors occurs only when some of the instances out of screen, maybe I forget something or this approach can't be used, but didn't found in docs any restrictions about using clones and instances. so what is the right approach to solve this? using Chrome Version 51.0.2704.103 (64-bit)
  13. Hello, hello, good day to you sirs and mams, I'm a newb, i'm a newb. I'll try and keep it simple and straight forward, at a minimum my playground is (simple and straight forward). when I search for pivot, three options seem to come up, along with confusion: 1. the setPivotMatrix method 2. create a mesh where you want your pivot point to be and parent to it 3. world this or that and setting world so, i've experimented with OPTION 1, setPivotMatrix, and i can't find the connection between this and a pivot point, I assume this is a mathematicians version of pivot as opposed to a physicists pivot, if someone could please describe in a sentence what setPivotMatrix is, it would be greatly appreciated. On the other hand if it could be shown in a simple playground that this has something to do with a "pivot" that to would be greatly appreciated. Before you say that's easy and show me a sphere rotating around another sphere where the pivot is the one rotating please read: from wikipedia: "Pivot may refer to: Pivot, the point of rotation in a lever system More generally, the center point of any rotational system Pivot joint, a kind of joint between bones in the body Pivot turn, a dance move" for OPTION 2 parenting it works great with a single mesh you want to rotate around a point, but will it work with clones and rotating each clone another Math.PI/6? here is my playground: OPTION 3 is beyond me thank you for looking reading thinking, maybe even writing have a lovely day, or if night, then sweet dreams
  14. When trying to achieve a task involving matrices I found I did not get the expected results on my mesh. Exploring further and checking out values using using the console I found I was getting integers not floating point values when displaying individual elements of a matrix. This is the same in Firefox and Chrome. If it is not some sort of console error then the use of individual elements for calculations within BJS could not be right (but BJS works?). Here is a PG example that shows what I mean After the matrix is computed the first four elements of the matrix are displayed, but always show as 1, 0, 0, 0 The matrix is displaced and the values in this matrix are floats as you would expect. However cloning the matrix (and matrix.clone() accesses individual matrix elements) and displaying the clone results in displaying the clone as the identity matrix. I have tries BJS2.3 and BJS2.4 and the results are the same. Everything I have read on Float32Array seems to suggest that accessing individual elements of such a matrix using array notation, eg [ ] should work An image of such a set of results is shown below. What is happening?
  15. I have a model loaded from a .babylon file, which consists of several meshes, a matching skeleton with animations is also loaded from that same file. I'd like to create a clone of the whole model (meshes + skeleton), and be able to animate each clone separately. I iterate over the meshes with a simple FOR loop and clone them, so far everything works as expected. I clone the skeleton, however when I try to animate the clone using scene.beginAnimation(skeleton...) neither the cloned meshes nor the original meshes are animated. When I try to animate the original skeleton, the original meshes are animated successfully. Since my skeleton cloning is completely separate from the meshes cloning, I guess it makes sense, as they don't have references of each other. 1) Is there a way to pass the skeleton which meshes it should be attached to after cloning? (or the other way around - pass the cloned skeleton to the cloned meshes) Alternatively - Is there some way to clone the meshes and skeleton in a way that keeps the newly cloned meshes synced to the newly cloned skeleton? 2) Is it even necessary to clone the skeletons if I want different clones of the same model to be animated separately? 3) Does a skeleton have a function similar to mesh.createInstance()? For instance, if I call mesh.createInstance(), should I still call skeleton.clone() or does skeleton have a function similar to createInstance() for improved performance?
  16. Hi! I'm trying to create various units for different players, each player can have multiple units, all from the same model. Because materials can't be per instance, only per mesh (WebGL limitation if I know correctly), I create a clone of a model for each player, change the material and afterwards I'm doing instancing from those clones. My problem is, that when I do this everything disappears (first it flickers and completely blank scene afterwards). Everything is visible again if bounding boxes are turned back on, but instances from clones aren't shown, only bounding boxes are at correct locations (attached first image). What am I doing wrong that this happens or is a bug? A minimal example on plunkr: EDIT: Example uses BJS version 2.2, but 2.3 suffers for the same problem. EDIT2: Added second image that renders exactly the same scene, the only difference is checked option for bounding boxed in debug layer.
  17. Hello please help me to draw lines between spheres @aWeirdo you had a pretty good particel system knowledge, your fireball pg was impressive.
  18. So in my scene I have several meshes I want to export exactly as they are. My idea was to clone all of them, baking using bakeCurrentTransformIntoVertices() and later Serialize them The problem I'm facing is that when I apply bake function to the clones, originals are affected: No baking clone: Baking: Am I missing a parameter? Is there any other way to achieve the same effect?
  19. Hello, I have the following error when I try to clone an object. Uncaught TypeError: Cannot set property 'references' of null What can I do? Why does this happen? Best regards Kevin
  20. I try to clone the same mesh, but for some reason, the mesh is cloned once. How to clone the same mesh many? var loader = new BABYLON.AssetsManager(scene); dom1mesh = loader.addMeshTask('dom1', "", "/static/game/dom1/", "dom2.babylon"); mesh = new BABYLON.Mesh.CreateSphere(name, 8, 2, scene); mesh.position = new BABYLON.Vector3( 5, 1, 5); dom1mesh.onSuccess = function (task) { var nm = task.loadedMeshes[0]; nm.position = new BABYLON.Vector3(10, 1, 10); nm.parent = mesh; }; mesh1 = BABYLON.Mesh.CreateSphere(name, 8, 2, scene); mesh1.position = new BABYLON.Vector3( 15, 1, 15); dom1mesh.onSuccess = function (task) { var nm = task.loadedMeshes[0].clone('2'); nm.parent = mesh1; }; mesh2 = BABYLON.Mesh.CreateSphere(name, 8, 2, scene); mesh2.position = new BABYLON.Vector3( 25, 1, 25); dom1mesh.onSuccess = function (task) { var nm = task.loadedMeshes[0].clone('3'); nm.parent = mesh2; }; mesh3 = BABYLON.Mesh.CreateSphere(name, 8, 2, scene); mesh3.position = new BABYLON.Vector3( 35, 1, 35); dom1mesh.onSuccess = function (task) { var nm = task.loadedMeshes[0].clone('4'); nm.parent = mesh3; };
  21. hello ... I am trying to take a 'snapshot' of a babylon3d scene ... in other words: I am trying to clone a babylonjs canvas when a user presses a button, and then append the new <canvas> to the <body> .. Sometimes it works, but other times it does not. However, if I use a simple canvas (ie. by using fillRect), the cloning/appending always works as expected. I have set up a test on plunker to demonstrate my problem:plunker demo ... press the button over and over again to see how sporadic it behaves when there is a babylon scene. NOTE: You can toggle between the plain canvas and the babylon canvas from within the _jquery(document).ready(...) handler . thanks, Shannon
  22. Hello, I'm trying to animate clones of an object but with a delay between animation. You can find a test here : But as you can see, the delay between animation is not constant, after the first loop, all animation are not sync, how can i keep the same delay after all the loop ? Maybe it's not the right way of doing this, can someone help me with this ? In this configuration I can keep the delay between animation but some of them never end : Thanks !
  23. I want to clone the already loaded model and inserted into another location on the map. At the end of the time. var loader = new BABYLON.AssetsManager(scene);var taskMesh = loader.addMeshTask('t3', "", "game/t3/", "t.babylon");taskMesh.onSuccess = function (task) { task.loadedMeshes[0].position = new BABYLON.Vector3(0, 0, 0); task.loadedMeshes[0].parent = camera;};I have not found. Maybe something like this? taskMesh.loadedMeshes[0].clone();
  24. Hello, If I export a scene containing nested instances of the same mesh/object (a tree of objects linked by a parent/child relashionship), and that I load the scene in BabylonJS, mesh positions are altered. Cases that works: - If I make every objects "single user", then it works fine. - If objects are duplicated but not nested, it works too. In the attachment, a Blender test scene with several layers : - the first is a tree made of duplicated copies (data is not shared between instances). - the second is a tree made of duplicated linked instances (same data shared by several object). - the third one is just a linked duplicate of the same object. The tested version of BabylonJS is 2.2.
  25. This is a followup from a previous post where i was trying to clone a mesh and serialize the scene. It turned out that when i clone and serialize a mesh they seem to attach themselves somehow to each other. So here i clone a mesh, and move just the clone: Works great! the clone moves seperate to the mesh. Now i serialize the scene and save it to a file. When i load that scene, i can't move just the clone by itself anymore. They appear to be attached. The two meshes on top of each other, this can be confirmed in the debug layer. Does anyone have any suggestions on how to fix this? how to perhaps separate them? or even what is going on so i can try to understand it? Currently all i can see is that both cloned meshes have the same ID. But they both have the same ID when i first clone it and it works great. But after i load it not so lucky. Any ideas?