Skip to content

Instantly share code, notes, and snippets.

View xeolabs's full-sized avatar
🏋️‍♂️
Developing http://xeokit.io

xeolabs xeolabs

🏋️‍♂️
Developing http://xeokit.io
View GitHub Profile
var node = SceneJs.node();
var scene = SceneJs.graph(
SceneJs.node(node, node)
);
var graph = SceneJs.graph(
SceneJs.node({
childListeners: {
'alpha': {
fn: function(nodeContext, event) {
// Event 'alpha' has bubbled up and is handled here again at step 3.
alert('Event name ' + event.name + ' handled with params '
var graph = SceneJs.graph(
SceneJs.node({
preVisit:function(nodeContext) {
// Events 'alpha' and 'beta' are fired from here at Step 1.
nodeContext.fireParentEvent('alpha', {
foo: 'foo value',
var graph = SceneJs.graph(
SceneJs.node({
preVisit: function(nodeContext) {
var graphContext = nodeContext.getGraphContext();
graphContext.counter++;
}
})
);
var graphContext = { counter: 0 };
var graph = SceneJs.graph(
SceneJs.node({
preVisit: function(nodeContext) {
// Parent node gets graph context from node context
// and sets something on it for child
var graphContext = nodeContext.getGraphContext();
graphContext.foo = 'Hi, child nodes!';
var config = {
preVisit: function() {
// Do something
}
};
var myNode1 = new SceneJs.node(config);
config.preVisit = function() { // Don't do this!!
}
with (SceneJs) {
var scene = graph(
canvas({ canvasId: 'mycanvas' },
shaders.simpleShader(
lights({ lights: [{ pos: { x: 60.0, y: 60.0, z: -100.0 } } ]},
// Installation of a backend for the 'simple-shader' SceneJS shader node
SceneJs.Backend.installNodeBackend(SceneJs.shaderBackend({
nodeType: 'simple-shader',
vertexShaders: [
'attribute vec3 Vertex; ' +
'attribute vec3 Normal; ' +
// Example SceneJS scene definition - renders the venerable OpenGL teapot
with (SceneJs) {
var scene = graph({}, // node always has a config object
renderer({ canvasId: 'mycanvas'},
shader({ type: 'simple-shader' },
lights({
// Installation of the SceneJS viewport node backend
SceneJs.backends.installBackend(
new (function() {
this.type = 'viewport';
var ctx;
this.install = function(_ctx) {