Skip to content

Commit

Permalink
More rendering effects and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
xeolabs committed Sep 16, 2014
1 parent 5779cd1 commit eca528a
Show file tree
Hide file tree
Showing 864 changed files with 24,570 additions and 57,142 deletions.
6 changes: 3 additions & 3 deletions about.html
Original file line number Diff line number Diff line change
Expand Up @@ -299,19 +299,19 @@ <h3>6. Custom Scene Node Types</h3>
z: 5.0,

nodes: [{
type: "prims/box"
type: "geometry/box"
}]
}, {
type: "translate",
y: 1.0,
z: 5.0,

nodes: [{
type: "prims/box"
type: "geometry/box"
}]
}]
}, {
type: "prims/teapot"
type: "geometry/teapot"
}]
}]
});</pre>
Expand Down
4 changes: 2 additions & 2 deletions api/latest/firstExample.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
nodes:[

// Teapot primitive, implemented by plugin at
// http://scenejs.org/api/latest/plugins/node/prims/teapot.js
// http://scenejs.org/api/latest/plugins/node/geometry/teapot.js
{
type:"prims/teapot"
type:"geometry/teapot"
}
]
}
Expand Down
34 changes: 22 additions & 12 deletions api/latest/plugins/node/cameras/orbit.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
*/
SceneJS.Types.addType("cameras/orbit", {

construct:function (params) {
construct: function (params) {

var lookat = this.addNode({
type:"lookAt",
type: "lookAt",

// A plugin node type is responsible for attaching specified
// child nodes within itself
nodes:params.nodes
nodes: params.nodes
});

var yaw = params.yaw || 0;
Expand All @@ -40,17 +40,24 @@ SceneJS.Types.addType("cameras/orbit", {
var lastX;
var lastY;
var dragging = false;
var lookatDirty = false;

var eye = params.eye || { x:0, y:0, z:0 };
var look = params.look || { x:0, y:0, z:0};
var eye = params.eye || { x: 0, y: 0, z: 0 };
var look = params.look || { x: 0, y: 0, z: 0};

lookat.set({
eye:{ x:eye.x, y:eye.y, z:-zoom },
look:{ x:look.x, y:look.y, z:look.z },
up:{ x:0, y:1, z:0 }
eye: { x: eye.x, y: eye.y, z: -zoom },
look: { x: look.x, y: look.y, z: look.z },
up: { x: 0, y: 1, z: 0 }
});

update();
// this._tick = this.getScene().on("tick",
// function () {
// if (lookatDirty) {
// update();
// lookatDirty = false;
// }
// });

var canvas = this.getScene().getCanvas();

Expand Down Expand Up @@ -157,16 +164,19 @@ SceneJS.Types.addType("cameras/orbit", {
var eye3 = SceneJS_math_transformPoint3(pitchMat, eye);
eye3 = SceneJS_math_transformPoint3(yawMat, eye3);

lookat.setEye({x:eye3[0], y:eye3[1], z:eye3[2] });
lookat.setEye({x: eye3[0], y: eye3[1], z: eye3[2] });
}

update();
},

setLook: function(l) {
setLook: function (l) {


},

destruct:function () {
destruct: function () {
this.getScene().off(this.tick);
// TODO: remove mouse handlers
}
});
105 changes: 60 additions & 45 deletions api/latest/plugins/node/cameras/pickFlyOrbit.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ require([
style.background = "#AAFFAA";
style.opacity = "0.8";
style["border-radius"] = "3px";
style["z-index"] = 100000;
style["-moz-border-radius"] = "3px";
style["box-shadow"] = "3px 3px 3px #444444";
style.left = "0";
Expand All @@ -55,18 +56,18 @@ require([
return {

// Shows label, but only if text has been set
setShown:function (shown) {
setShown: function (shown) {
style.display = shown && text ? "" : "none";
},

// Sets canvas position of label
setPos:function (pos) {
setPos: function (pos) {
style.left = "" + pos.x + "px";
style.top = "" + pos.y + "px";
},

// Sets text in label
setText:function (t) {
setText: function (t) {
text = t;
div.innerHTML = "<span>" + text + "</span>";
}
Expand All @@ -75,19 +76,21 @@ require([

SceneJS.Types.addType("cameras/pickFlyOrbit", {

construct:function (params) {
construct: function (params) {

var self = this;

var lookat = this.addNode({
type:"lookAt",
type: "lookAt",

nodes:[
nodes: [
{
type:"name",
name:"noname",
type: "name",
name: "noname",

// A plugin node type is responsible for attaching specified
// child nodes within itself
nodes:params.nodes
nodes: params.nodes
}
]
});
Expand All @@ -104,44 +107,44 @@ require([

// Sphere position, with a ID so we can update this node:
indicatorPos = lookat.addNode({
type:"translate",
id:"__spherePOI"
type: "translate",
id: "__spherePOI"
});

indicatorVis = indicatorPos.addNode({
type:"flags",
flags:{
enabled:false,
transparent:true,
specular:true,
diffuse:false
type: "flags",
flags: {
enabled: false,
transparent: true,
specular: true,
diffuse: false
}
});

var cursorSize = params.cursorSize || 1;

indicatorSize = indicatorVis.addNode({
type:"scale",
id:"__sphereSize",
x:cursorSize,
y:cursorSize,
z:cursorSize,
nodes:[
type: "scale",
id: "__sphereSize",
x: cursorSize,
y: cursorSize,
z: cursorSize,
nodes: [
{
type:"material",
color:{ r:0.4, g:1.0, b:0.4 },
specularColor:{ r:1.0, g:1.0, b:1.0 },
emit:0.2,
nodes:[
type: "material",
color: { r: 0.4, g: 1.0, b: 0.4 },
specularColor: { r: 1.0, g: 1.0, b: 1.0 },
emit: 0.2,
nodes: [
{
type:"style",
lineWidth:2,
nodes:[
type: "style",
lineWidth: 2,
nodes: [

// Sphere primitive implemented by plugin at
// http://scenejs.org/api/latest/plugins/node/prims/sphere.js
// http://scenejs.org/api/latest/plugins/node/geometry/sphere.js
{
type:"prims/sphere"
type: "geometry/sphere"
}
]
}
Expand All @@ -158,16 +161,18 @@ require([
});
}

var eye = params.eye || { x:0, y:0, z:0 };
var look = params.look || { x:0, y:0, z:0};
var eye = params.eye || { x: 0, y: 0, z: 0 };
var look = params.look || { x: 0, y: 0, z: 0};
var zoom = params.zoom || 100;
var zoomSensitivity = params.zoomSensitivity || 1.0;

lookat.set({
eye:{ x:eye.x, y:eye.y, z:eye.z},
look:{ x:look.x, y:look.y, z:look.z },
up:{ x:0, y:1, z:0 }
});
var lookatArgs = {
eye: { x: eye.x, y: eye.y, z: eye.z},
look: { x: look.x, y: look.y, z: look.z },
up: { x: 0, y: 1, z: 0 }
};
lookat.set(lookatArgs);
this.publish("updated", lookatArgs);

var canvas = this.getScene().getCanvas();

Expand Down Expand Up @@ -276,7 +281,7 @@ require([
}

function pick(canvasX, canvasY) {
scene.pick(canvasX, canvasY, { rayPick:true });
scene.pick(canvasX, canvasY, { rayPick: true });
}

var scene = this.getScene();
Expand All @@ -295,7 +300,7 @@ require([

if (indicatorVis) {
indicatorVis.setEnabled(true);
indicatorPos.setXYZ({x:endPivot[0], y:endPivot[1], z:endPivot[2] });
indicatorPos.setXYZ({x: endPivot[0], y: endPivot[1], z: endPivot[2] });
label.setShown(true);
}

Expand Down Expand Up @@ -372,8 +377,18 @@ require([
glmat.vec3.transformMat4(eye3, eye, mat);

// Update view transform
lookat.setLook({x:look[0], y:look[1], z:look[2] });
lookat.setEye({x:look[0] - eye3[0], y:look[1] - eye3[1], z:look[2] - eye3[2] });
lookat.setLook({x: look[0], y: look[1], z: look[2] });
lookat.setEye({x: look[0] - eye3[0], y: look[1] - eye3[1], z: look[2] - eye3[2] });

var lookatArgs = {
eye: {x: look[0], y: look[1], z: look[2] },
look: {x: look[0] - eye3[0], y: look[1] - eye3[1], z: look[2] - eye3[2] }
};

// lookat.setLook(lookatArgs.look);
// lookat.setEye(lookatArgs.eye);

self.publish("updated", lookatArgs);

// Rotate complete
orbiting = false;
Expand All @@ -388,7 +403,7 @@ require([
});
},

destruct:function () {
destruct: function () {
// TODO: remove mouse handlers
}
});
Expand Down
2 changes: 1 addition & 1 deletion api/latest/plugins/node/canvas/capture.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ require([
SceneJS.Types.addType("canvas/capture", {

construct:function (params) {
this._format = params.format ? supportedFormat(params.format) : "jpeg";
this._format = params.format ? this._supportedFormat(params.format) : "jpeg";
this._width = params.width;
this._height = params.height;
},
Expand Down
36 changes: 0 additions & 36 deletions api/latest/plugins/node/effects/crt.js

This file was deleted.

Loading

0 comments on commit eca528a

Please sign in to comment.