Skip to content

Commit

Permalink
Snapshot build
Browse files Browse the repository at this point in the history
  • Loading branch information
xeolabs committed Jul 28, 2015
1 parent 402cebb commit af89f9a
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 63 deletions.
138 changes: 82 additions & 56 deletions api/latest/scenejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* A WebGL-based 3D scene graph from xeoLabs
* http://scenejs.org/
*
* Built on 2015-07-21
* Built on 2015-07-28
*
* MIT License
* Copyright 2015, Lindsay Kay
Expand Down Expand Up @@ -8267,7 +8267,7 @@ SceneJS_NodeFactory.prototype.putNode = function (node) {
this._engine.display.enable = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore;
};

})();;(function() {
})();;(function () {

/**
* The default state core singleton for {@link SceneJS.Flags} nodes
Expand All @@ -8277,34 +8277,35 @@ SceneJS_NodeFactory.prototype.putNode = function (node) {
stateId: SceneJS._baseStateId++,
type: "flags",

picking : true, // Picking enabled
clipping : true, // User-defined clipping enabled
enabled : true, // Node not culled from traversal
picking: true, // Picking enabled
clipping: true, // User-defined clipping enabled
enabled: true, // Node not culled from traversal
transparent: false, // Node transparent - works in conjunction with matarial alpha properties
backfaces: true, // Show backfaces
frontface: "ccw", // Default vertex winding for front face
reflective: true, // Reflects reflection node cubemap, if it exists, by default.
solid: false, // When true, renders backfaces without texture or shading, for a cheap solid cross-section effect
solidColor: [1.0, 1.0, 1.0], // Solid cap color
hash: "refl;;"
};

var coreStack = [];
var stackLen = 0;

SceneJS_events.addListener(
SceneJS_events.SCENE_COMPILING,
function(params) {
params.engine.display.flags = defaultCore;
stackLen = 0;
});
SceneJS_events.SCENE_COMPILING,
function (params) {
params.engine.display.flags = defaultCore;
stackLen = 0;
});

/**
* @class Scene graph node which sets rendering mode flags for its subgraph
* @extends SceneJS.Node
*/
SceneJS.Flags = SceneJS_NodeFactory.createNodeType("flags");

SceneJS.Flags.prototype._init = function(params) {
SceneJS.Flags.prototype._init = function (params) {

if (this._core.useCount == 1) { // This node is first to reference the state core, so sets it up

Expand All @@ -8316,13 +8317,14 @@ SceneJS_NodeFactory.prototype.putNode = function (node) {
this._core.frontface = "ccw"; // Default vertex winding for front face
this._core.reflective = true; // Reflects reflection node cubemap, if it exists, by default.
this._core.solid = false; // Renders backfaces without texture or shading, for a cheap solid cross-section effect
this._core.solidColor = [1.0, 1.0, 1.0 ]; // Solid cap color
if (params.flags) { // 'flags' property is actually optional in the node definition
this.setFlags(params.flags);
}
}
};

SceneJS.Flags.prototype.setFlags = function(flags) {
SceneJS.Flags.prototype.setFlags = function (flags) {

var core = this._core;

Expand Down Expand Up @@ -8358,50 +8360,48 @@ SceneJS_NodeFactory.prototype.putNode = function (node) {

if (flags.reflective != undefined) {
core.reflective = flags.reflective;
core.hash = core.reflective ? "refl" : "";
core.hash = (core.reflective ? "refl" : "") + (core.solid ? ";s" : ";;");
this._engine.branchDirty(this);
this._engine.display.imageDirty = true;
}

if (flags.solid != undefined) {
core.solid = flags.solid;
core.hash = core.reflective ? "refl" : "";
core.hash = (core.reflective ? "refl" : "") + (core.solid ? ";s" : ";;");
this._engine.branchDirty(this);
this._engine.display.imageDirty = true;
}

return this;
};

SceneJS.Flags.prototype.addFlags = function(flags) {
return this.setFlags(flags);
// var core = this._core;
// if (flags.picking != undefined) core.picking = flags.picking;
// if (flags.clipping != undefined) core.clipping = flags.clipping;
// if (flags.enabled != undefined) core.enabled = flags.enabled;
// if (flags.transparent != undefined) core.transparent = flags.transparent;
// if (flags.backfaces != undefined) core.backfaces = flags.backfaces;
// if (flags.frontface != undefined) core.frontface = flags.frontface;
// if (flags.backfaceLighting != undefined) core.backfaceLighting = flags.backfaceLighting;
// if (flags.backfaceTexturing != undefined) core.backfaceTexturing = flags.backfaceTexturing;
// return this;
if (flags.solidColor != undefined) {
var defaultSolidColor = defaultCore.solidColor;
var color = flags.solidColor;
core.solidColor = color ? [
color.r != undefined && color.r != null ? color.r : defaultSolidColor[0],
color.g != undefined && color.g != null ? color.g : defaultSolidColor[1],
color.b != undefined && color.b != null ? color.b : defaultSolidColor[2]
] : defaultCore.solidColor;
this._engine.display.imageDirty = true;
}

return this;
};

SceneJS.Flags.prototype.getFlags = function() {
SceneJS.Flags.prototype.getFlags = function () {
var core = this._core;
return {
picking : core.picking,
clipping : core.clipping,
enabled : core.enabled,
picking: core.picking,
clipping: core.clipping,
enabled: core.enabled,
transparent: core.transparent,
backfaces: core.backfaces,
frontface: core.frontface,
reflective: core.reflective,
solid: core.solid
solid: core.solid,
solidColor: core.solidColor
};
};

SceneJS.Flags.prototype.setPicking = function(picking) {
SceneJS.Flags.prototype.setPicking = function (picking) {
picking = !!picking;
if (this._core.picking != picking) {
this._core.picking = picking;
Expand All @@ -8410,11 +8410,11 @@ SceneJS_NodeFactory.prototype.putNode = function (node) {
return this;
};

SceneJS.Flags.prototype.getPicking = function() {
SceneJS.Flags.prototype.getPicking = function () {
return this._core.picking;
};

SceneJS.Flags.prototype.setClipping = function(clipping) {
SceneJS.Flags.prototype.setClipping = function (clipping) {
clipping = !!clipping;
if (this._core.clipping != clipping) {
this._core.clipping = clipping;
Expand All @@ -8423,11 +8423,11 @@ SceneJS_NodeFactory.prototype.putNode = function (node) {
return this;
};

SceneJS.Flags.prototype.getClipping = function() {
SceneJS.Flags.prototype.getClipping = function () {
return this._core.clipping;
};

SceneJS.Flags.prototype.setEnabled = function(enabled) {
SceneJS.Flags.prototype.setEnabled = function (enabled) {
enabled = !!enabled;
if (this._core.enabled != enabled) {
this._core.enabled = enabled;
Expand All @@ -8436,11 +8436,11 @@ SceneJS_NodeFactory.prototype.putNode = function (node) {
return this;
};

SceneJS.Flags.prototype.getEnabled = function() {
SceneJS.Flags.prototype.getEnabled = function () {
return this._core.enabled;
};

SceneJS.Flags.prototype.setTransparent = function(transparent) {
SceneJS.Flags.prototype.setTransparent = function (transparent) {
transparent = !!transparent;
if (this._core.transparent != transparent) {
this._core.transparent = transparent;
Expand All @@ -8449,11 +8449,11 @@ SceneJS_NodeFactory.prototype.putNode = function (node) {
return this;
};

SceneJS.Flags.prototype.getTransparent = function() {
SceneJS.Flags.prototype.getTransparent = function () {
return this._core.transparent;
};

SceneJS.Flags.prototype.setBackfaces = function(backfaces) {
SceneJS.Flags.prototype.setBackfaces = function (backfaces) {
backfaces = !!backfaces;
if (this._core.backfaces != backfaces) {
this._core.backfaces = backfaces;
Expand All @@ -8462,23 +8462,23 @@ SceneJS_NodeFactory.prototype.putNode = function (node) {
return this;
};

SceneJS.Flags.prototype.getBackfaces = function() {
SceneJS.Flags.prototype.getBackfaces = function () {
return this._core.backfaces;
};

SceneJS.Flags.prototype.setFrontface = function(frontface) {
SceneJS.Flags.prototype.setFrontface = function (frontface) {
if (this._core.frontface != frontface) {
this._core.frontface = frontface;
this._engine.display.imageDirty = true;
}
return this;
};

SceneJS.Flags.prototype.getFrontface = function() {
SceneJS.Flags.prototype.getFrontface = function () {
return this._core.frontface;
};

SceneJS.Flags.prototype.setReflective = function(reflective) {
SceneJS.Flags.prototype.setReflective = function (reflective) {
reflective = !!reflective;
if (this._core.reflective != reflective) {
this._core.reflective = reflective;
Expand All @@ -8489,11 +8489,11 @@ SceneJS_NodeFactory.prototype.putNode = function (node) {
return this;
};

SceneJS.Flags.prototype.getReflective = function() {
SceneJS.Flags.prototype.getReflective = function () {
return this._core.reflective;
};

SceneJS.Flags.prototype.setSolid = function(solid) {
SceneJS.Flags.prototype.setSolid = function (solid) {
solid = !!solid;
if (this._core.solid != solid) {
this._core.solid = solid;
Expand All @@ -8504,12 +8504,30 @@ SceneJS_NodeFactory.prototype.putNode = function (node) {
return this;
};

SceneJS.Flags.prototype.getSolid = function() {
SceneJS.Flags.prototype.getSolid = function () {
return this._core.solid;
};


SceneJS.Flags.prototype._compile = function(ctx) {
SceneJS.Flags.prototype.setSolidColor = function (color) {
var defaultSolidColor = defaultCore.solidColor;
this._core.solidColor = color ? [
color.r != undefined && color.r != null ? color.r : defaultSolidColor[0],
color.g != undefined && color.g != null ? color.g : defaultSolidColor[1],
color.b != undefined && color.b != null ? color.b : defaultSolidColor[2]
] : defaultCore.solidColor;
this._engine.display.imageDirty = true;
return this;
};

SceneJS.Flags.prototype.getSolidColor = function () {
return {
r: this._core.solidColor[0],
g: this._core.solidColor[1],
b: this._core.solidColor[2]
};
};

SceneJS.Flags.prototype._compile = function (ctx) {
this._engine.display.flags = coreStack[stackLen++] = this._core;
this._compileNodes(ctx);
this._engine.display.flags = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore;
Expand Down Expand Up @@ -16566,6 +16584,9 @@ var SceneJS_ProgramSourceFactory = new (function () {
if (states.geometry.colorBuf) {
src.push("SCENEJS_vColor = SCENEJS_aVertexColor;");
}

src.push("gl_PointSize = 3.0;");

src.push("}");

return src;
Expand Down Expand Up @@ -16665,9 +16686,9 @@ var SceneJS_ProgramSourceFactory = new (function () {
// True when lighting
src.push("uniform bool SCENEJS_uClipping;");

// True when interior surfaces of solid cross-sections
// are to be rendered without texture and shading
src.push("uniform bool SCENEJS_uSolid;");
if (solid) {
src.push("uniform vec3 SCENEJS_uSolidColor;");
}

// Added in v4.0 to support depth targets
src.push("uniform bool SCENEJS_uDepthMode;");
Expand Down Expand Up @@ -16787,7 +16808,7 @@ var SceneJS_ProgramSourceFactory = new (function () {
if (solid) {

src.push(" if (gl_FrontFacing == false) {");
src.push(" gl_FragColor = vec4(0.5, 0.5, 0.5, 1.0);");
src.push(" gl_FragColor = vec4(SCENEJS_uSolidColor.xyz, 1.0);");
src.push(" return;");
src.push(" }");
}
Expand Down Expand Up @@ -17875,6 +17896,7 @@ SceneJS_ChunkFactory.createChunkType({

this._uClippingDraw = draw.getUniform("SCENEJS_uClipping");
this._uSolidDraw = draw.getUniform("SCENEJS_uSolid");
this._uSolidColorDraw = draw.getUniform("SCENEJS_uSolidColor");

var pick = this.program.pick;

Expand Down Expand Up @@ -17945,6 +17967,10 @@ SceneJS_ChunkFactory.createChunkType({
if (this._uSolidDraw) {
this._uSolidDraw.setValue(this.core.solid);
}

if (this._uSolidColorDraw) {
this._uSolidColorDraw.setValue(this.core.solidColor);
}
}
}
});
Expand Down
Loading

0 comments on commit af89f9a

Please sign in to comment.