Perfect, I can now see the Json Model data in the Browser. This is just prefect.
Now I’m trying to figure out how to restore an existing coded workflow.
Essentially, I’ve got the code that is expecting that the model is loaded in specific hierarchy.
example:
Root\table\leg1
Keep in mind that at design time only the structure exists…no model data is loaded until runtime, but the code is attempting to load material data (i.e. the materials exists, but are not on the model.
So I have attempted this:
// Create a new Basic material
var material = new pc.BasicMaterial();
// Set the material to have a texture map that is multiplied by a red color
material.color.set(1, 0, 0);
// Notify the material that it has been modified
material.update();
ground.model.material = material;
but when the code executes:
var x = floor.model.model.meshInstances[0];
The first [model] is not null, but the second [model] one is.
Remember, I am not trying to update the root
this.app.root.addChild(Glass_ModelEntity);
No, this good, but I want to update the design time structure;
//Code Start
object.attributes.add(“Ground_ModelJsonAsset”, {type: “asset”});
var Ground_ModelAsset = new pc.Asset(“Ground_ModelJsonAsset”, ‘model’, {url: this.Ground_ModelJsonAsset.file.url});
this.app.assets.add(Ground_ModelAsset);
var Ground_ModelEntity = new pc.Entity();
Ground_ModelEntity.addComponent(“model”, {type: ‘asset’,asset: Ground_ModelAsset});
var ground = this.app.root.findByPath(“Root/ground”);
ground.addComponent(Ground.type, Ground_ModelAsset); //**Is this right?
/*******************************************************/
With the above technique, I get warnings, but no errors:
addComponent: Entity already has model component
and nothing shows up in the scene.
What I am hoping to do at this point is:
- Get the material that was created at design time (call it ground_MAT)
- Assign it to to the Ground object that has had the Json object added as a Model.
I think we are almost there… just need a bit of help.
Many thanks again.
Finally, with the predefined design time structure, if I ensure that it has a Model and then call addComponent, it does not fail, but the console states that the Entity already has a model.
If I remove the Model from the Entity (in design mode) and then run the code, I then get the following:
Error: Invalid model type: model