Jump to content

Material from scene to scene


Recommended Posts



Advice me, please.


How i can correctly use material from scene A to scene B?

I make clone of material, put material in scene.materials array, check paramets of material (its ok), material is assigned, but not render in other scene :(((



Link to comment
Share on other sites

Hi, Deltakosh!


I try reproduce in playground, but can't create one more canvas, scene, engine, etc. Sorry

// creating 2 canvas, 2 engine, 2 scenes (a and , loading each scene meshes and materials// next ...var tm;for (iMat in a.materials){	if (!!a.materials[iMat].clone){ // only StandardMaterial has clone()		tm=a.materials[iMat];		if (b.getMaterialByID(tm.id)==null){  // not replace old mat's			tm=tm.clone();			b.materials.push(tm);		}	}}// its not work. If out to console b.materials can see new materials,// but if assign any to mesh (myMesh.material=b.materials[anythingIndex]) // nothing changed in render view. 

Now i copy all properties from mat1 to mat2, for circumvent problem, but its so wild and horrible :huh:

Link to comment
Share on other sites

  • 2 weeks later...

Hi, Deltakosh!


Sorry, i can't ansewer at once.


ok so perhaps you can share a page that reproduces the error somewhere (Please link to www.babylonjs.com/babylon.max.js) ?


But, i have more strange results :)

Please, see in https://www.clickon.ru/demo/3d/

first: it seems clone() do not clone material ID

second: assigning cloned material moved object and not set propertyes (in this case red color of diffuseColor).


What I do not understand? :(


And one more moment - if i do anyMaterial.dispose(), he's do not removed from objects, and continue stay on mesh? How i can correctly dispose material?

Link to comment
Share on other sites

Ok gotcha: this could not work as the scene MUST have the same engine (and the same canvas) to share resources

Hmmm... in this case i must made big common canvas and set non intersect viewports of cameras for create two separete area with 3d-render, yes?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...