Why am I getting this error?
WebGL: INVALID_VALUE: uniform1iv: no array
WebGL: too many errors, no more errors will be reported to the console for this context.
This is the code that is generating the error from playcanvas-stable.min.js
if (a.autoRender || a.renderNextFrame)
a.render(),
a.renderNextFrame = !1;// Specifically this line
I am exporting a project which contains several simple entities called apple_entity or orange_entity for example which have a physical material or a phong applied to it called apple_material and I then run this on my local server with my own UI I am building with Vue.
When I use the code below to load either a high/low poly 3d apple model and apply the material to it I get the above error message and sometimes the model will load and other times it will not. I am exporting the 3d json model from PlayCanvas and creating the material using the online GUI so I would have hoped that this would work reliably but it is not.
The following works in some scenarios but in others i get the above error or the diffuse texture does not load correctly.
var modelName = "apple";
(function loadModel(){
// (1)Load 3d model
var URL = "./files/assets/models/"+modelName+".json";
var modelAsset = new pc.Asset(modelName, "model", {
url: URL
});
pc.app.assets.load( modelAsset );
modelAsset.ready(function(){
pc.app.assets.add(modelAsset);
// Create the entity called apple
var appleEntity = new pc.Entity(modelName);
appleEntity.addComponent('model');
appleEntity.model.asset = modelAsset;
pc.app.root.addChild(appleEntity);
transferMaterial();
};
}());
function transferMaterial(){
// (2) Copy the material from a simple plane that already exists in the playcanvas scene called apple_placeholder
var localModel = pc.app.root.findByName(modelName);
// This placeHolderMaterial is created with the online Playcanvas gui as a plane with the material that I want to use attached to it
var placeHolderMaterial = pc.app.root.findByName(modelName+"_placeholder");
// Then simply transfer the material into the "apple"
localModel.model.meshInstances[0].material = placeHolderMaterial.model.meshInstances[0].material;
localModel.model.meshInstances[0].material.update();
loadTexture();
}
function loadTexture(){
// (3) Add diffuse texture
var imageDiffuse = new Image();
var texture = new pc.Texture();
// When texture has loaded
imageDiffuse.onload = function () {
var localModel = pc.app.root.findByName(modelName);
localModel.model.meshInstances[0].material.diffuseMap = texture;
localModel.model.meshInstances[0].material.update();
};
//imageDiffuse.crossOrigin = "anonymous";
texture.setSource(imageDiffuse);
imageDiffuse.src = "./files/assets/models/"+modelName+"-diffuse-low.jpg";
}
Does anyone know how to reliably:
- Load a 3d.json model into playcanvas scene
- Copy a material from an object that already exists in the playcanvas space and use it on the newly created 3d.json object.
- Apply a diffuse texture to this material.