Skip to content

Instantly share code, notes, and snippets.

View deltakosh's full-sized avatar

David Catuhe deltakosh

  • Microsoft
  • Seattle
View GitHub Profile
// Capture the first pointer down
// And if we start on the potato we block camera control
var potatoHasControl;
scene.onPointerDown = (evt, pickResult) => {
if (!pickResult.hit) {
return;
}
if (pickResult.pickedMesh !== potato) {
return;
// Capture the first pointer down
// And if we start on the potato we block camera control
var potatoHasControl;
scene.onPointerDown = (evt, pickResult) => {
if (!pickResult.hit) {
return;
}
if (pickResult.pickedMesh !== potato) {
return;
// Create an heightmap
var heightmap = new BABYLON.DynamicTexture("heightmap", {width:1024, height:1024}, scene);
heightmap.update();
var context = heightmap.getContext();
// Plug the heightmap in the node material
var textureBlocks = matCap.getTextureBlocks().filter(b => b.name === "HeightMap");
if (textureBlocks && textureBlocks.length) {
textureBlocks[0].texture = heightmap;
var createScene = async function () {
var scene = new BABYLON.Scene(engine);
// Let's create our potato
var potato = BABYLON.MeshBuilder.CreateSphere("potato",
{ diameterX: 0.8, diameterY: 0.9, diameterZ: 0.8 },
scene);
// Create a potato(ish) material
var matCap = await BABYLON.NodeMaterial.ParseFromSnippetAsync("WSJ3VZ")
var createScene = function () {
var scene = new BABYLON.Scene(engine);
// Let's create our potato
var potato = BABYLON.MeshBuilder.CreateSphere("potato",
{ diameterX: 0.8, diameterY: 0.9, diameterZ: 0.8 },
scene);
// Environment
class Particle {
private _alpha: number | undefined;
private _beta: number | undefined;
public get alpha(): number {
if (this._alpha === undefined) {
this._alpha = Math.random() > 0.5 ? 2 : 3;
}
return this._alpha;
}
class Particle {
public alpha: number;
public beta: number;
}
@deltakosh
deltakosh / nodeMaterial.js
Created July 1, 2019 23:06
Babylon.js Node Material example
// Create the material
var nodeMaterial = new BABYLON.NodeMaterial("node", scene, { emitComments: true });
// Vertex
// First we need the position of the vertex
var positionInput = new BABYLON.InputBlock("position");
positionInput.setAsAttribute("position");
// Then we need to compute the world version of it using the World matrix
var worldInput = new BABYLON.InputBlock("world");
@deltakosh
deltakosh / gist:e02f94ddda010f8bc9b8
Created February 11, 2016 18:02
Verifying that +deltakosh is my blockchain ID. https://onename.com/deltakosh
Verifying that +deltakosh is my blockchain ID. https://onename.com/deltakosh