Skip to content

Instantly share code, notes, and snippets.

@SableRaf
Last active November 20, 2020 20:27
Show Gist options
  • Save SableRaf/9a732ff1a075787c2094b724ac170b6e to your computer and use it in GitHub Desktop.
Save SableRaf/9a732ff1a075787c2094b724ac170b6e to your computer and use it in GitHub Desktop.
Possible Unhandled Promise Rejection: Error: Exception in HostFunction: Wrong object reference. Expected: native object reference
const Materials = require('Materials');
const Textures = require('Textures');
const Shaders = require('Shaders');
const Time = require('Time');
const Reactive = require('Reactive');
const {log} = require('Diagnostics');
async function main()
{
const material0 = await Materials.findFirst('material0').catch(err => log(err));
const cameraTexture0 = await Textures.findFirst('cameraTexture0').catch(err => log(err));
const uvs = Shaders.vertexAttribute({"variableName" : Shaders.vertexAttribute.TEX_COORDS});
const ct = Reactive.mul(Time.ms,0.001);
const curve = Reactive.abs(Reactive.sin(ct));
log('this prints');
const color = Shaders.textureSampler(cameraTexture0, uvs);
log('this does not print');
const modulationColor = Reactive.pack4(curve,0,0,1);
const finalColor = Reactive.mul(color, modulationColor);
material0.setTextureSlot('DIFFUSE', finalColor);
};
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment