… namely by its handling of Layer.id and/or other methods that I know of.
I have for instance done this:
utils.loadGlbContainerFromUrl (this.glbAssetUrl, null, this.glbAssetUrl.name, function (err, asset) {
/** @type {pc.Entity} */
var renderRootEntity = asset.resource.instantiateRenderEntity();
// self.entity.addChild(renderRootEntity);
// Get all the render components that have been created in the hierarchy
/** @type {pc.RenderComponent[]} */
/* var renders = renderRootEntity.findComponents('render');
var layerIds = [];
var i;
// Get the list of layer ids
for (i = 0; i < self.layerNames.length; ++i) {
var layer = self.app.scene.layers.getLayerByName(self.layerNames[i]);
if (layer !== null) {
layerIds.push(layer.id);
}
}
*/
self.entity.addComponent('model', {
asset: asset.resource.model
});
At the Refraction.js I am trying to access the glb-models layer at node-level amongst other things.
But no matter what; it seems like the “Sphere”-material restrains from reacting.
What are you trying to do? Mesh instances don’t have a layer property, nor materials have.
Model and render components can have one or more layers assigned to them. As a result they will automatically insert their referenced mesh instances to that layer.
For example you can add one or more layers when creating this model component like this:
const layerId = self.app.scene.layers.getLayerByName('My Layer');
self.entity.addComponent('model', {
asset: asset.resource.model
layers: [layerId] // here you can reference layers by their id
});
Turning off depth write doesn’t mean the scene will look different. In their case, it was to avoid the issue where multiple transparent meshes were rendering in an undesired order.
In your case, you don’t really have that problem so it’s going to look the same
I’ve forked the project and removed a bunch of code that didn’t do anything to try to make some sense of this.
The error you get here about binding the color buffer is because you are trying to render target buffer in the same layer that it’s being rendered (ie an infinite loop). I’m not sure what you are aiming for here but the render target cannot be used on the same layers that’s being rendered to it.