Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Sandbox updates, shader syntax patch, sample formatting and doctype c…

…leanup
  • Loading branch information...
commit b84ce56913e7447a29e9a7ba403ba5e495c97a50 1 parent dfa04e0
@cjcliffe authored
Showing with 13,665 additions and 13,888 deletions.
  1. +14 −14 CubicVR_Core.fs
  2. +0 −1  lib/codemirror/codemirror.css
  3. +38 −21 lib/codemirror/codemirror.js
  4. +1 −2  lib/codemirror/mode_css.js
  5. +0 −1  lib/codemirror/mode_htmlmixed.js
  6. +59 −13 lib/codemirror/mode_javascript.js
  7. +0 −1  lib/codemirror/mode_xml.js
  8. +145 −146 samples/basic/basic_primitives.html
  9. +47 −51 samples/basic/cube.html
  10. +85 −88 samples/basic/cube_multimaterial.html
  11. +55 −55 samples/basic/cube_scene.html
  12. +55 −58 samples/basic/cube_viewcontrol.html
  13. +126 −129 samples/basic/landscape.html
  14. +72 −73 samples/basic/lathe_torus.html
  15. +105 −108 samples/basic/material_instances.html
  16. +183 −186 samples/basic/material_uvoffset.html
  17. +184 −187 samples/basic/materials.html
  18. +69 −73 samples/basic/sphere_map.html
  19. +215 −218 samples/camera/multi_camera.html
  20. +352 −355 samples/camera/renderscenetexture.html
  21. +54 −57 samples/collada/collada_duck.html
  22. +55 −48 samples/collada/sketchup.html
  23. +62 −65 samples/collada/wall_smash.html
  24. +63 −66 samples/collada/wall_smash_cam_attach.html
  25. +68 −71 samples/collada/wall_smash_stringload.html
  26. +55 −58 samples/cubicvrxml/cubicvr_mesh.html
  27. +54 −57 samples/cubicvrxml/cubicvr_mesh_json.html
  28. +64 −67 samples/cubicvrxml/procedural_mesh.html
  29. +100 −103 samples/custom_shader/basic_test.html
  30. +243 −246 samples/custom_shader/noise.html
  31. +68 −71 samples/definitions/definitions.html
  32. +48 −51 samples/definitions/definitions_scene.html
  33. +47 −50 samples/definitions/definitions_scene_xml.html
  34. +66 −69 samples/definitions/definitions_xml.html
  35. +52 −52 samples/events/event_tick.html
  36. +394 −400 samples/fps_demo/level1.html
  37. +75 −75 samples/gml/GMLDraw2D.html
  38. +75 −75 samples/gml/GMLDraw3D.html
  39. +455 −455 samples/gpu_fluid/alpha_blocker_test.html
  40. +467 −467 samples/gpu_fluid/wavepool_blockers.html
  41. +47 −14 samples/index.css
  42. +58 −62 samples/index.html
  43. +23 −23 samples/instancing/index.html
  44. +45 −45 samples/layout/layout_test.html
  45. +98 −100 samples/mesh_build/cube_arrays.html
  46. +82 −85 samples/motion/cube_animate.html
  47. +208 −211 samples/moz_joystick/fps_control_test.html
  48. +23 −23 samples/octree/light_test.html
  49. +39 −40 samples/octree/octree.html
  50. +41 −41 samples/octree/octree_destroy.html
  51. +96 −96 samples/pdf/index-dnd.html
  52. +75 −75 samples/pdf/index.html
  53. +177 −180 samples/pdf/pdf_gallery.html
  54. +273 −282 samples/physics/physics_compound.html
  55. +425 −433 samples/physics/physics_fps_grapple.html
  56. +515 −543 samples/physics/physics_grapple_convexhull.html
  57. +481 −490 samples/physics/physics_grapple_event.html
  58. +337 −346 samples/physics/physics_heightfield.html
  59. +128 −145 samples/physics/physics_mesh.html
  60. +135 −143 samples/physics/physics_mesh_static.html
  61. +264 −273 samples/physics/physics_multishape.html
  62. +338 −347 samples/physics/physics_pickable.html
  63. +255 −264 samples/physics/physics_stress.html
  64. +114 −122 samples/physics/physics_test.html
  65. +310 −315 samples/physics/physics_vehicle.html
  66. +501 −510 samples/physics/physics_vehicle_heightfield.html
  67. +506 −511 samples/physics/physics_vehicle_truck_heightfield.html
  68. +314 −323 samples/physics/physics_zerog.html
  69. +435 −440 samples/physics/physics_zerog_tether.html
  70. +26 −27 samples/pickables/pickables.html
  71. +142 −144 samples/pickables/pickables2.html
  72. +64 −64 samples/pickables/project_unproject.html
  73. +174 −178 samples/pointMode/pointMode.html
  74. +148 −150 samples/pointMode/pointModeSubdivide.html
  75. +76 −99 samples/point_sprite/ParticleEmitter.html
  76. +86 −92 samples/point_sprite/ParticleWaterfall.html
  77. +265 −266 samples/polygon/tessellate.html
  78. +171 −175 samples/post_process/bloom.html
  79. +147 −150 samples/shadows/alphamap_shadows.html
  80. +143 −146 samples/shadows/alphamap_shadows_attach.html
  81. +149 −152 samples/shadows/alphamap_shadows_projector.html
  82. +158 −161 samples/shadows/arealight.html
  83. +33 −33 samples/skybox/skybox.html
  84. +94 −97 samples/subdivision/beveled_cube.html
  85. +122 −126 samples/subdivision/catmull-clark.html
  86. +85 −88 samples/subdivision/remove_internals.html
  87. +77 −80 samples/subdivision/wall_smash.html
  88. +3 −3 samples/text/text.html
  89. +28 −28 samples/timer/MainLoop.html
  90. +21 −21 samples/timer/TimerTest.html
  91. +151 −151 samples/vbo_dynamic/wave_pool.html
  92. +107 −107 samples/vbo_dynamic/wobbly_cube.html
  93. +183 −184 samples/vbo_morph/vbo_morph.html
  94. +192 −193 samples/vbo_morph/vbo_morph_offset.html
  95. +60 −61 samples/vehicle/vehicle.html
  96. +46 −46 samples/vehicle_physics_demo/stunt_track1.html
  97. +1 −1  samples/video/video.html
Sorry, we could not display the entire diff because it was too big.
View
28 CubicVR_Core.fs
@@ -409,25 +409,25 @@ vec4 cubicvr_lighting(vec4 color_in, vec3 n, vec2 texCoord) {
// this seems to get around a shader crash ...
if (shadowCoord.s > 0.000&&shadowCoord.s < 1.000 && shadowCoord.t > 0.000 && shadowCoord.t < 1.000) if (i == 0) { shadow = getShadowVal(lightShadowMap[0],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z);}
#if LIGHT_COUNT>1
- else if (i == 1) { shadow = getShadowVal(lightShadowMap[1],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
+ if (i == 1) { shadow = getShadowVal(lightShadowMap[1],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
#endif
#if LIGHT_COUNT>2
- else if (i == 2) { shadow = getShadowVal(lightShadowMap[2],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
+ if (i == 2) { shadow = getShadowVal(lightShadowMap[2],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
#endif
#if LIGHT_COUNT>3
- else if (i == 3) { shadow = getShadowVal(lightShadowMap[3],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
+ if (i == 3) { shadow = getShadowVal(lightShadowMap[3],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
#endif
#if LIGHT_COUNT>4
- else if (i == 4) { shadow = getShadowVal(lightShadowMap[4],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
+ if (i == 4) { shadow = getShadowVal(lightShadowMap[4],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
#endif
#if LIGHT_COUNT>5
- else if (i == 5) { shadow = getShadowVal(lightShadowMap[5],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
+ if (i == 5) { shadow = getShadowVal(lightShadowMap[5],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
#endif
#if LIGHT_COUNT>6
- else if (i == 6) { shadow = getShadowVal(lightShadowMap[6],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
+ if (i == 6) { shadow = getShadowVal(lightShadowMap[6],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
#endif
#if LIGHT_COUNT>7
- else if (i == 7) { shadow = getShadowVal(lightShadowMap[7],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
+ if (i == 7) { shadow = getShadowVal(lightShadowMap[7],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
#endif
accum += shadow * lightIntensity[i] * materialDiffuse * lightDiffuse[i] * NdotL;
@@ -515,25 +515,25 @@ vec4 cubicvr_lighting(vec4 color_in, vec3 n, vec2 texCoord) {
// this seems to get around a shader crash ...
if (shadowCoord.s >= 0.000&&shadowCoord.s <= 1.000 && shadowCoord.t >= 0.000 && shadowCoord.t <= 1.000) if (i == 0) { shadow = getShadowVal(lightShadowMap[0],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z);}
#if LIGHT_COUNT>1
- else if (i == 1) { shadow = getShadowVal(lightShadowMap[1],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
+ if (i == 1) { shadow = getShadowVal(lightShadowMap[1],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
#endif
#if LIGHT_COUNT>2
- else if (i == 2) { shadow = getShadowVal(lightShadowMap[2],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
+ if (i == 2) { shadow = getShadowVal(lightShadowMap[2],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
#endif
#if LIGHT_COUNT>3
- else if (i == 3) { shadow = getShadowVal(lightShadowMap[3],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
+ if (i == 3) { shadow = getShadowVal(lightShadowMap[3],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
#endif
#if LIGHT_COUNT>4
- else if (i == 4) { shadow = getShadowVal(lightShadowMap[4],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
+ if (i == 4) { shadow = getShadowVal(lightShadowMap[4],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
#endif
#if LIGHT_COUNT>5
- else if (i == 5) { shadow = getShadowVal(lightShadowMap[5],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
+ if (i == 5) { shadow = getShadowVal(lightShadowMap[5],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
#endif
#if LIGHT_COUNT>6
- else if (i == 6) { shadow = getShadowVal(lightShadowMap[6],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
+ if (i == 6) { shadow = getShadowVal(lightShadowMap[6],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
#endif
#if LIGHT_COUNT>7
- else if (i == 7) { shadow = getShadowVal(lightShadowMap[7],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
+ if (i == 7) { shadow = getShadowVal(lightShadowMap[7],shadowCoord,lightProjectionOut[i].w,lightDepthClip[i].z); }
#endif
att = att * shadow;
View
1  lib/codemirror/codemirror.css
@@ -172,4 +172,3 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
}
}
-
View
59 lib/codemirror/codemirror.js
@@ -1,3 +1,5 @@
+// CodeMirror version 2.35
+//
// All functions that need access to the editor's state live inside
// the CodeMirror function. Below that, at the bottom of the file,
// some utilities are defined.
@@ -1418,7 +1420,7 @@ window.CodeMirror = (function() {
var startChar = line.charAt(start);
var check = isWordChar(startChar) ? isWordChar :
/\s/.test(startChar) ? function(ch) {return /\s/.test(ch);} :
- function(ch) {return !/\s/.test(ch) && !isWordChar(ch);};
+ function(ch) {return !/\s/.test(ch) && isWordChar(ch);};
while (start > 0 && check(line.charAt(start - 1))) --start;
while (end < line.length && check(line.charAt(end))) ++end;
}
@@ -1508,18 +1510,17 @@ window.CodeMirror = (function() {
function TextMarker(type, style) { this.lines = []; this.type = type; if (style) this.style = style; }
TextMarker.prototype.clear = operation(function() {
- var min = Infinity, max = -Infinity;
+ var min, max;
for (var i = 0; i < this.lines.length; ++i) {
var line = this.lines[i];
- var span = getMarkedSpanFor(line.markedSpans, this, true);
- if (span.from != null || span.to != null) {
- var lineN = lineNo(line);
- min = Math.min(min, lineN); max = Math.max(max, lineN);
- }
+ var span = getMarkedSpanFor(line.markedSpans, this);
+ if (span.from != null) min = lineNo(line);
+ if (span.to != null) max = lineNo(line);
+ line.markedSpans = removeMarkedSpan(line.markedSpans, span);
}
- if (min != Infinity)
- changes.push({from: min, to: max + 1});
+ if (min != null) changes.push({from: min, to: max + 1});
this.lines.length = 0;
+ this.explicitlyCleared = true;
});
TextMarker.prototype.find = function() {
var from, to;
@@ -1546,7 +1547,7 @@ window.CodeMirror = (function() {
var span = {from: curLine == from.line ? from.ch : null,
to: curLine == to.line ? to.ch : null,
marker: marker};
- (line.markedSpans || (line.markedSpans = [])).push(span);
+ line.markedSpans = (line.markedSpans || []).concat([span]);
marker.lines.push(line);
++curLine;
});
@@ -1557,8 +1558,9 @@ window.CodeMirror = (function() {
function setBookmark(pos) {
pos = clipPos(pos);
var marker = new TextMarker("bookmark"), line = getLine(pos.line);
+ history.addChange(pos.line, 1, [newHL(line.text, line.markedSpans)], true);
var span = {from: pos.ch, to: pos.ch, marker: marker};
- (line.markedSpans || (line.markedSpans = [])).push(span);
+ line.markedSpans = (line.markedSpans || []).concat([span]);
marker.lines.push(line);
return marker;
}
@@ -1979,6 +1981,7 @@ window.CodeMirror = (function() {
if (extensions.propertyIsEnumerable(ext) &&
!instance.propertyIsEnumerable(ext))
instance[ext] = extensions[ext];
+ for (var i = 0; i < initHooks.length; ++i) initHooks[i](instance);
return instance;
} // (end of function CodeMirror)
@@ -2076,6 +2079,9 @@ window.CodeMirror = (function() {
extensions[name] = func;
};
+ var initHooks = [];
+ CodeMirror.defineInitHook = function(f) {initHooks.push(f);};
+
var modeExtensions = CodeMirror.modeExtensions = {};
CodeMirror.extendMode = function(mode, properties) {
var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
@@ -2355,16 +2361,20 @@ window.CodeMirror = (function() {
this.from = from; this.to = to; this.marker = marker;
}
- function getMarkedSpanFor(spans, marker, del) {
+ function getMarkedSpanFor(spans, marker) {
if (spans) for (var i = 0; i < spans.length; ++i) {
var span = spans[i];
- if (span.marker == marker) {
- if (del) spans.splice(i, 1);
- return span;
- }
+ if (span.marker == marker) return span;
}
}
+ function removeMarkedSpan(spans, span) {
+ var r;
+ for (var i = 0; i < spans.length; ++i)
+ if (spans[i] != span) (r || (r = [])).push(spans[i]);
+ return r;
+ }
+
function markedSpansBefore(old, startCh, endCh) {
if (old) for (var i = 0, nw; i < old.length; ++i) {
var span = old[i], marker = span.marker;
@@ -2448,7 +2458,15 @@ window.CodeMirror = (function() {
// hl stands for history-line, a data structure that can be either a
// string (line without markers) or a {text, markedSpans} object.
function hlText(val) { return typeof val == "string" ? val : val.text; }
- function hlSpans(val) { return typeof val == "string" ? null : val.markedSpans; }
+ function hlSpans(val) {
+ if (typeof val == "string") return null;
+ var spans = val.markedSpans, out = null;
+ for (var i = 0; i < spans.length; ++i) {
+ if (spans[i].marker.explicitlyCleared) { if (!out) out = spans.slice(0, i); }
+ else if (out) out.push(spans[i]);
+ }
+ return !out ? spans : out.length ? out : null;
+ }
function newHL(text, spans) { return spans ? {text: text, markedSpans: spans} : text; }
function detachMarkedSpans(line) {
@@ -2878,7 +2896,7 @@ window.CodeMirror = (function() {
var time = +new Date, cur = lst(this.done), last = cur && lst(cur);
var dtime = time - this.time;
- if (this.compound && cur && !this.closed) {
+ if (cur && !this.closed && this.compound) {
cur.push({start: start, added: added, old: old});
} else if (dtime > 400 || !last || this.closed ||
last.start > start + old.length || last.start + last.added < start) {
@@ -3085,7 +3103,7 @@ window.CodeMirror = (function() {
return -1;
}
function isWordChar(ch) {
- return /\w/.test(ch) || ch.toUpperCase() != ch.toLowerCase();
+ return /\w/.test(ch) || ch.toUpperCase() != ch.toLowerCase() || /[\u4E00-\u9FA5]/.test(ch);
}
// See if "".split is the broken IE version, if so, provide an
@@ -3141,8 +3159,7 @@ window.CodeMirror = (function() {
for (var i = 1; i <= 12; i++) keyNames[i + 111] = keyNames[i + 63235] = "F" + i;
})();
- CodeMirror.version = "2.34 +";
+ CodeMirror.version = "2.35";
return CodeMirror;
})();
-
View
3  lib/codemirror/mode_css.js
@@ -228,7 +228,7 @@ CodeMirror.defineMode("css", function(config) {
else if (/[,+>*\/]/.test(ch)) {
return ret(null, "select-op");
}
- else if (ch == "." && stream.match(/^\w+/)) {
+ else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
return ret("qualifier", type);
}
else if (ch == ":") {
@@ -446,4 +446,3 @@ CodeMirror.defineMode("css", function(config) {
});
CodeMirror.defineMIME("text/css", "css");
-
View
1  lib/codemirror/mode_htmlmixed.js
@@ -82,4 +82,3 @@ CodeMirror.defineMode("htmlmixed", function(config) {
}, "xml", "javascript", "css");
CodeMirror.defineMIME("text/html", "htmlmixed");
-
View
72 lib/codemirror/mode_javascript.js
@@ -1,6 +1,9 @@
+// TODO actually recognize syntax of TypeScript constructs
+
CodeMirror.defineMode("javascript", function(config, parserConfig) {
var indentUnit = config.indentUnit;
var jsonMode = parserConfig.json;
+ var isTS = parserConfig.typescript;
// Tokenizer
@@ -8,7 +11,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
function kw(type) {return {type: type, style: "keyword"};}
var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
var operator = kw("operator"), atom = {type: "atom", style: "atom"};
- return {
+
+ var jsKeywords = {
"if": A, "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
"return": C, "break": C, "continue": C, "new": C, "delete": C, "throw": C,
"var": kw("var"), "const": kw("var"), "let": kw("var"),
@@ -17,6 +21,35 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
"in": operator, "typeof": operator, "instanceof": operator,
"true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom
};
+
+ // Extend the 'normal' keywords with the TypeScript language extensions
+ if (isTS) {
+ var type = {type: "variable", style: "variable-3"};
+ var tsKeywords = {
+ // object-like things
+ "interface": kw("interface"),
+ "class": kw("class"),
+ "extends": kw("extends"),
+ "constructor": kw("constructor"),
+
+ // scope modifiers
+ "public": kw("public"),
+ "private": kw("private"),
+ "protected": kw("protected"),
+ "static": kw("static"),
+
+ "super": kw("super"),
+
+ // types
+ "string": type, "number": type, "bool": type, "any": type
+ };
+
+ for (var attr in tsKeywords) {
+ jsKeywords[attr] = tsKeywords[attr];
+ }
+ }
+
+ return jsKeywords;
}();
var isOperatorChar = /[+\-*&%=<>!?|]/;
@@ -66,7 +99,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
stream.skipToEnd();
return ret("comment", "comment");
}
- else if (state.reAllowed) {
+ else if (state.lastType == "operator" || state.lastType == "keyword c" ||
+ /^[\[{}\(,;:]$/.test(state.lastType)) {
nextUntilUnescaped(stream, "/");
stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla
return ret("regexp", "string-2");
@@ -87,7 +121,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
else {
stream.eatWhile(/[\w\$_]/);
var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
- return (known && state.kwAllowed) ? ret(known.type, known.style, word) :
+ return (known && state.lastType != ".") ? ret(known.type, known.style, word) :
ret("variable", "variable", word);
}
}
@@ -275,9 +309,20 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
if (type == "}") return cont();
return pass(statement, block);
}
+ function maybetype(type) {
+ if (type == ":") return cont(typedef);
+ return pass();
+ }
+ function typedef(type) {
+ if (type == "variable"){cx.marked = "variable-3"; return cont();}
+ return pass();
+ }
function vardef1(type, value) {
- if (type == "variable"){register(value); return cont(vardef2);}
- return cont();
+ if (type == "variable") {
+ register(value);
+ return isTS ? cont(maybetype, vardef2) : cont(vardef2);
+ }
+ return pass();
}
function vardef2(type, value) {
if (value == "=") return cont(expression, vardef2);
@@ -306,7 +351,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
if (type == "(") return cont(pushlex(")"), pushcontext, commasep(funarg, ")"), poplex, statement, popcontext);
}
function funarg(type, value) {
- if (type == "variable") {register(value); return cont();}
+ if (type == "variable") {register(value); return isTS ? cont(maybetype) : cont();}
}
// Interface
@@ -315,8 +360,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
startState: function(basecolumn) {
return {
tokenize: jsTokenBase,
- reAllowed: true,
- kwAllowed: true,
+ lastType: null,
cc: [],
lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
localVars: parserConfig.localVars,
@@ -334,8 +378,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
if (stream.eatSpace()) return null;
var style = state.tokenize(stream, state);
if (type == "comment") return style;
- state.reAllowed = !!(type == "operator" || type == "keyword c" || type.match(/^[\[{}\(,;:]$/));
- state.kwAllowed = type != '.';
+ state.lastType = type;
return parseJS(state, style, type, content, stream);
},
@@ -345,9 +388,11 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
var type = lexical.type, closing = firstChar == type;
- if (type == "vardef") return lexical.indented + 4;
+ if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? 4 : 0);
else if (type == "form" && firstChar == "{") return lexical.indented;
- else if (type == "stat" || type == "form") return lexical.indented + indentUnit;
+ else if (type == "form") return lexical.indented + indentUnit;
+ else if (type == "stat")
+ return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? indentUnit : 0);
else if (lexical.info == "switch" && !closing)
return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
else if (lexical.align) return lexical.column + (closing ? 0 : 1);
@@ -360,4 +405,5 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
CodeMirror.defineMIME("text/javascript", "javascript");
CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
-
+CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
+CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
View
1  lib/codemirror/mode_xml.js
@@ -316,4 +316,3 @@ CodeMirror.defineMIME("text/xml", "xml");
CodeMirror.defineMIME("application/xml", "xml");
if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
-
View
291 samples/basic/basic_primitives.html
@@ -1,147 +1,146 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<!DOCTYPE html>
<html>
-
- <head>
- <title>
- CubicVR.js: Basic Primitives /w Scene and MouseViewController
- </title>
- <script src="../../CubicVR.js" type="text/javascript">
- </script>
- <script type='text/javascript'>
- function webGLStart(gl, canvas) {
- // New scene with our canvas dimensions and default camera with FOV 80
- var scene = new CubicVR.Scene(canvas.width, canvas.height, 80);
-
- // Create a material for the mesh
- var material1 = new CubicVR.Material({
- textures: {
- color: "../images/2576-diffuse.jpg"
- }
- });
-
- var material2 = new CubicVR.Material({
- textures: {
- color: "../images/2062-diffuse.jpg"
- }
- });
-
- var material3 = new CubicVR.Material({
- textures: {
- color: "../images/6583-diffuse.jpg"
- }
- });
-
- var uvplanar = {
- projectionMode: "planar",
- projectionAxis: "y",
- scale: [0.5, 0.5, 0.5]
- };
-
- var uvplane = {
- projectionMode: "planar",
- projectionAxis: "z",
- scale: [0.5, 0.5, 0.5]
- };
-
- var uvcubic = {
- projectionMode: "cubic",
- scale: [0.5, 0.5, 0.5]
- };
-
- var torusMesh = new CubicVR.Mesh({
- primitive: {
- type: "torus",
- innerRadius: 0.5,
- outerRadius: 0.75,
- lat: 24,
- lon: 24,
- material: material1,
- uvmapper: uvplanar,
- },
- compile: true
- });
-
- var planeMesh = new CubicVR.Mesh({
- primitive: {
- type: "plane",
- size: 1.0,
- material: material2,
- uvmapper: uvplane
- },
- compile: true
- });
-
- var boxMesh = new CubicVR.Mesh({
- primitive: {
- type: "box",
- size: 1.0,
- material: material3,
- uvmapper: uvcubic
- },
- compile: true
- });
-
- var sphereMesh = new CubicVR.Mesh({
- primitive: {
- type: "sphere",
- radius: 0.5,
- lat: 24,
- lon: 24,
- material: material3,
- uvmapper: uvcubic
- },
- compile: true
- });
-
- var coneMesh = new CubicVR.Mesh({
- primitive: {
- type: "cone",
- base: 1.0,
- material: material2,
- uvmapper: uvcubic
- },
- compile: true
- });
-
- var cylinderMesh = new CubicVR.Mesh({
- primitive: {
- type: "cylinder",
- radius: 0.5,
- height: 1.0,
- lon: 24,
- material: material1,
- uvmapper: uvcubic
- },
- compile: true
- });
-
-
- // Add SceneObjects
- scene.bindSceneObject(new CubicVR.SceneObject({mesh:torusMesh, position:[-1.5,0,-1]}));
- scene.bindSceneObject(new CubicVR.SceneObject({mesh:planeMesh, position:[0,0,-1]}));
- scene.bindSceneObject(new CubicVR.SceneObject({mesh:boxMesh, position:[1.5,0,-1]}));
- scene.bindSceneObject(new CubicVR.SceneObject({mesh:sphereMesh, position:[-1.5,0,1]}));
- scene.bindSceneObject(new CubicVR.SceneObject({mesh:coneMesh, position:[0,0,1]}));
- scene.bindSceneObject(new CubicVR.SceneObject({mesh:cylinderMesh, position:[1.5,0,1]}));
-
- // set initial camera position and target
- scene.camera.position = [0, 2, 2];
- scene.camera.target = [0, 0, 0];
-
- // Add our scene to the window resize list
- CubicVR.addResizeable(scene);
-
- // Start our main drawing loop, it provides a timer and the gl context as parameters
- CubicVR.MainLoop(function(timer, gl) {
- scene.render();
- });
-
- // initialize a mouse view controller
- mvc = new CubicVR.MouseViewController(canvas, scene.camera);
- }
- </script>
- </head>
-
- <body onLoad="CubicVR.start('auto',webGLStart);"></body>
-
-</html>
+ <head>
+ <title>
+ CubicVR.js: Basic Primitives /w Scene and MouseViewController
+ </title>
+ <script src="../../CubicVR.js" type="text/javascript">
+ </script>
+ <script type='text/javascript'>
+ function webGLStart(gl, canvas) {
+ // New scene with our canvas dimensions and default camera with FOV 80
+ var scene = new CubicVR.Scene(canvas.width, canvas.height, 80);
+
+ // Create a material for the mesh
+ var material1 = new CubicVR.Material({
+ textures: {
+ color: "../images/2576-diffuse.jpg"
+ }
+ });
+
+ var material2 = new CubicVR.Material({
+ textures: {
+ color: "../images/2062-diffuse.jpg"
+ }
+ });
+
+ var material3 = new CubicVR.Material({
+ textures: {
+ color: "../images/6583-diffuse.jpg"
+ }
+ });
+
+ var uvplanar = {
+ projectionMode: "planar",
+ projectionAxis: "y",
+ scale: [0.5, 0.5, 0.5]
+ };
+
+ var uvplane = {
+ projectionMode: "planar",
+ projectionAxis: "z",
+ scale: [0.5, 0.5, 0.5]
+ };
+
+ var uvcubic = {
+ projectionMode: "cubic",
+ scale: [0.5, 0.5, 0.5]
+ };
+
+ var torusMesh = new CubicVR.Mesh({
+ primitive: {
+ type: "torus",
+ innerRadius: 0.5,
+ outerRadius: 0.75,
+ lat: 24,
+ lon: 24,
+ material: material1,
+ uvmapper: uvplanar,
+ },
+ compile: true
+ });
+
+ var planeMesh = new CubicVR.Mesh({
+ primitive: {
+ type: "plane",
+ size: 1.0,
+ material: material2,
+ uvmapper: uvplane
+ },
+ compile: true
+ });
+
+ var boxMesh = new CubicVR.Mesh({
+ primitive: {
+ type: "box",
+ size: 1.0,
+ material: material3,
+ uvmapper: uvcubic
+ },
+ compile: true
+ });
+
+ var sphereMesh = new CubicVR.Mesh({
+ primitive: {
+ type: "sphere",
+ radius: 0.5,
+ lat: 24,
+ lon: 24,
+ material: material3,
+ uvmapper: uvcubic
+ },
+ compile: true
+ });
+
+ var coneMesh = new CubicVR.Mesh({
+ primitive: {
+ type: "cone",
+ base: 1.0,
+ material: material2,
+ uvmapper: uvcubic
+ },
+ compile: true
+ });
+
+ var cylinderMesh = new CubicVR.Mesh({
+ primitive: {
+ type: "cylinder",
+ radius: 0.5,
+ height: 1.0,
+ lon: 24,
+ material: material1,
+ uvmapper: uvcubic
+ },
+ compile: true
+ });
+
+
+ // Add SceneObjects
+ scene.bindSceneObject(new CubicVR.SceneObject({mesh:torusMesh, position:[-1.5,0,-1]}));
+ scene.bindSceneObject(new CubicVR.SceneObject({mesh:planeMesh, position:[0,0,-1]}));
+ scene.bindSceneObject(new CubicVR.SceneObject({mesh:boxMesh, position:[1.5,0,-1]}));
+ scene.bindSceneObject(new CubicVR.SceneObject({mesh:sphereMesh, position:[-1.5,0,1]}));
+ scene.bindSceneObject(new CubicVR.SceneObject({mesh:coneMesh, position:[0,0,1]}));
+ scene.bindSceneObject(new CubicVR.SceneObject({mesh:cylinderMesh, position:[1.5,0,1]}));
+
+ // set initial camera position and target
+ scene.camera.position = [0, 2, 2];
+ scene.camera.target = [0, 0, 0];
+
+ // Add our scene to the window resize list
+ CubicVR.addResizeable(scene);
+
+ // Start our main drawing loop, it provides a timer and the gl context as parameters
+ CubicVR.MainLoop(function(timer, gl) {
+ scene.render();
+ });
+
+ // initialize a mouse view controller
+ mvc = new CubicVR.MouseViewController(canvas, scene.camera);
+ }
+ </script>
+ </head>
+
+ <body onLoad="CubicVR.start('auto',webGLStart);"></body>
+
+</html>
View
98 samples/basic/cube.html
@@ -1,52 +1,48 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
-<html>
-
- <head>
- <title>
- CubicVR.js: Basic Textured Cube
- </title>
- <script src="../../CubicVR.js" type="text/javascript">
- </script>
- <script type='text/javascript'>
- function webGLStart(gl,canvas) {
- // Create a camera, position at 1,1,1 and target at 0,0,0
- var camera = new CubicVR.Camera(canvas.width,canvas.height,60);
- camera.position = [1,1,1];
- camera.lookat([0,0,0]);
-
- // Create a material for the mesh
- var boxMaterial = new CubicVR.Material({
- textures: {
- color: "../images/6583-diffuse.jpg"
- }
- });
-
- // Add a box to mesh, size 1.0, apply material and UV parameters
- var boxMesh = new CubicVR.Mesh({
- primitive: {
- type: "box",
- size: 1.0,
- material: boxMaterial,
- uvmapper: {
- projectionMode: "cubic",
- scale: [1, 1, 1]
- }
- },
- compile: true
- });
-
- // Add our camera to the window resize list
- CubicVR.addResizeable(camera);
-
- // Start our main drawing loop, it provides a timer and the gl context as parameters
- CubicVR.MainLoop(function(timer, gl) {
- // Render our object using the camera, pass identity matrix to represent no transform
- CubicVR.renderObject(boxMesh, camera, CubicVR.IdentityMatrix);
- });
+<!DOCTYPE html>
+ <head>
+ <title>
+ CubicVR.js: Basic Textured Cube
+ </title>
+ <script src="../../CubicVR.js" type="text/javascript">
+ </script>
+ <script type='text/javascript'>
+ function webGLStart(gl,canvas) {
+ // Create a camera, position at 1,1,1 and target at 0,0,0
+ var camera = new CubicVR.Camera(canvas.width,canvas.height,60);
+ camera.position = [1,1,1];
+ camera.lookat([0,0,0]);
+
+ // Create a material for the mesh
+ var boxMaterial = new CubicVR.Material({
+ textures: {
+ color: "../images/6583-diffuse.jpg"
+ }
+ });
+
+ // Add a box to mesh, size 1.0, apply material and UV parameters
+ var boxMesh = new CubicVR.Mesh({
+ primitive: {
+ type: "box",
+ size: 1.0,
+ material: boxMaterial,
+ uvmapper: {
+ projectionMode: "cubic",
+ scale: [1, 1, 1]
}
- </script>
- </head>
-
- <body onLoad="CubicVR.start('auto',webGLStart);"></body>
-
-</html>
+ },
+ compile: true
+ });
+
+ // Add our camera to the window resize list
+ CubicVR.addResizeable(camera);
+
+ // Start our main drawing loop, it provides a timer and the gl context as parameters
+ CubicVR.MainLoop(function(timer, gl) {
+ // Render our object using the camera, pass identity matrix to represent no transform
+ CubicVR.renderObject(boxMesh, camera, CubicVR.IdentityMatrix);
+ });
+ }
+ </script>
+ </head>
+ <body onLoad="CubicVR.start('auto',webGLStart);"></body>
+</html>
View
173 samples/basic/cube_multimaterial.html
@@ -1,91 +1,88 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
-
- <head>
- <title>
- CubicVR.js: Basic Texured Cube /w Scene
- </title>
- <script src="../../CubicVR.js" type="text/javascript">
- </script>
- <script type='text/javascript'>
- function webGLStart(gl,canvas) {
- // Create a material for the mesh
- var boxMaterial1 = new CubicVR.Material({
- textures: { color: "../images/6583-diffuse.jpg" }
- });
-
- var boxMaterial2 = new CubicVR.Material({
- textures: { color: "../images/1422-diffuse.jpg" }
- });
-
- var boxMaterial3 = new CubicVR.Material({
- textures: { color: "../images/2282-diffuse.jpg" }
- });
-
- var boxMaterial4 = new CubicVR.Material({
- textures: { color: "../images/2576-diffuse.jpg" }
- });
-
- var boxMaterial5 = new CubicVR.Material({
- textures: { color: "../images/4734-diffuse.jpg" }
- });
-
- var boxMaterial6 = new CubicVR.Material({
- textures: { color: "../images/grass.jpg" }
- });
-
- // Add a box to mesh, size 1.0, apply base material and UV mapper
- var boxMesh = new CubicVR.Mesh({
- primitive: {
- type: "box",
- size: 1.0,
- material: boxMaterial1,
- uvmapper: {
- projectionMode: "cubic",
- scale: [1, 1, 1]
- }
- }
- });
-
- // before it's triangulated, the box is composed of 6 quads, we can assign a material to each
- boxMesh.setFaceMaterial(boxMaterial1,0);
- boxMesh.setFaceMaterial(boxMaterial2,1);
- boxMesh.setFaceMaterial(boxMaterial3,2);
- boxMesh.setFaceMaterial(boxMaterial4,3);
- boxMesh.setFaceMaterial(boxMaterial5,4);
- boxMesh.setFaceMaterial(boxMaterial6,5);
-
- // triangulate and buffer object to GPU, remove unused data
- boxMesh.prepare();
-
- // New scene with our canvas dimensions and default camera with FOV 80
- var scene = new CubicVR.Scene(canvas.width, canvas.height, 80);
-
- // SceneObject container for the mesh
- var boxObject = new CubicVR.SceneObject(boxMesh);
-
- // Add SceneObject containing the mesh to the scene
- scene.bind(boxObject);
-
- // set initial camera position and target
- scene.camera.position = [1, 1, 1];
- scene.camera.target = [0, 0, 0];
-
-
- // Add our scene to the window resize list
- CubicVR.addResizeable(scene);
-
- // Start our main drawing loop, it provides a timer and the gl context as parameters
- CubicVR.MainLoop(function(timer, gl) {
- scene.render();
- });
-
- // initialize a mouse view controller
- mvc = new CubicVR.MouseViewController(canvas, scene.camera);
+ <head>
+ <title>
+ CubicVR.js: Basic Texured Cube /w Scene
+ </title>
+ <script src="../../CubicVR.js" type="text/javascript">
+ </script>
+ <script type='text/javascript'>
+ function webGLStart(gl,canvas) {
+ // Create a material for the mesh
+ var boxMaterial1 = new CubicVR.Material({
+ textures: { color: "../images/6583-diffuse.jpg" }
+ });
+
+ var boxMaterial2 = new CubicVR.Material({
+ textures: { color: "../images/1422-diffuse.jpg" }
+ });
+
+ var boxMaterial3 = new CubicVR.Material({
+ textures: { color: "../images/2282-diffuse.jpg" }
+ });
+
+ var boxMaterial4 = new CubicVR.Material({
+ textures: { color: "../images/2576-diffuse.jpg" }
+ });
+
+ var boxMaterial5 = new CubicVR.Material({
+ textures: { color: "../images/4734-diffuse.jpg" }
+ });
+
+ var boxMaterial6 = new CubicVR.Material({
+ textures: { color: "../images/grass.jpg" }
+ });
+
+ // Add a box to mesh, size 1.0, apply base material and UV mapper
+ var boxMesh = new CubicVR.Mesh({
+ primitive: {
+ type: "box",
+ size: 1.0,
+ material: boxMaterial1,
+ uvmapper: {
+ projectionMode: "cubic",
+ scale: [1, 1, 1]
}
- </script>
- </head>
-
- <body onLoad="CubicVR.start('auto',webGLStart);"></body>
-
-</html>
+ }
+ });
+
+ // before it's triangulated, the box is composed of 6 quads, we can assign a material to each
+ boxMesh.setFaceMaterial(boxMaterial1,0);
+ boxMesh.setFaceMaterial(boxMaterial2,1);
+ boxMesh.setFaceMaterial(boxMaterial3,2);
+ boxMesh.setFaceMaterial(boxMaterial4,3);
+ boxMesh.setFaceMaterial(boxMaterial5,4);
+ boxMesh.setFaceMaterial(boxMaterial6,5);
+
+ // triangulate and buffer object to GPU, remove unused data
+ boxMesh.prepare();
+
+ // New scene with our canvas dimensions and default camera with FOV 80
+ var scene = new CubicVR.Scene(canvas.width, canvas.height, 80);
+
+ // SceneObject container for the mesh
+ var boxObject = new CubicVR.SceneObject(boxMesh);
+
+ // Add SceneObject containing the mesh to the scene
+ scene.bind(boxObject);
+
+ // set initial camera position and target
+ scene.camera.position = [1, 1, 1];
+ scene.camera.target = [0, 0, 0];
+
+
+ // Add our scene to the window resize list
+ CubicVR.addResizeable(scene);
+
+ // Start our main drawing loop, it provides a timer and the gl context as parameters
+ CubicVR.MainLoop(function(timer, gl) {
+ scene.render();
+ });
+
+ // initialize a mouse view controller
+ mvc = new CubicVR.MouseViewController(canvas, scene.camera);
+ }
+ </script>
+ </head>
+ <body onLoad="CubicVR.start('auto',webGLStart);"></body>
+</html>
View
110 samples/basic/cube_scene.html
@@ -1,57 +1,57 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<!DOCTYPE html>
<html>
-
- <head>
- <title>
- CubicVR.js: Basic Texured Cube /w Scene
- </title>
- <script src="../../CubicVR.js" type="text/javascript">
- </script>
- <script type='text/javascript'>
- function webGLStart(gl,canvas) {
- // Add a box to mesh, size 1.0, apply material and UV parameters
- var boxMesh = new CubicVR.Mesh({
- primitive: {
- type: "box",
- size: 1.0,
- material: {
- textures: {
- color: "../images/6583-diffuse.jpg"
- }
- },
- uv: {
- projectionMode: "cubic",
- scale: [1, 1, 1]
- }
- },
- compile: true
- });
-
- // New scene with our canvas dimensions and default camera with FOV 80
- var scene = new CubicVR.Scene(canvas.width, canvas.height, 80);
-
- // SceneObject container for the mesh
- var boxObject = new CubicVR.SceneObject(boxMesh);
-
- // Add SceneObject containing the mesh to the scene
- scene.bind(boxObject);
-
- // set initial camera position and target
- scene.camera.position = [1, 1, 1];
- scene.camera.target = [0, 0, 0];
-
-
- // Add our scene to the window resize list
- CubicVR.addResizeable(scene);
-
- // Start our main drawing loop, it provides a timer and the gl context as parameters
- CubicVR.MainLoop(function(timer, gl) {
- scene.render();
- });
+
+ <head>
+ <title>
+ CubicVR.js: Basic Texured Cube /w Scene
+ </title>
+ <script src="../../CubicVR.js" type="text/javascript">
+ </script>
+ <script type='text/javascript'>
+ function webGLStart(gl,canvas) {
+ // Add a box to mesh, size 1.0, apply material and UV parameters
+ var boxMesh = new CubicVR.Mesh({
+ primitive: {
+ type: "box",
+ size: 1.0,
+ material: {
+ textures: {
+ color: "../images/6583-diffuse.jpg"
+ }
+ },
+ uv: {
+ projectionMode: "cubic",
+ scale: [1, 1, 1]
}
- </script>
- </head>
-
- <body onLoad="CubicVR.start('auto',webGLStart);"></body>
-
-</html>
+ },
+ compile: true
+ });
+
+ // New scene with our canvas dimensions and default camera with FOV 80
+ var scene = new CubicVR.Scene(canvas.width, canvas.height, 80);
+
+ // SceneObject container for the mesh
+ var boxObject = new CubicVR.SceneObject(boxMesh);
+
+ // Add SceneObject containing the mesh to the scene
+ scene.bind(boxObject);
+
+ // set initial camera position and target
+ scene.camera.position = [1, 1, 1];
+ scene.camera.target = [0, 0, 0];
+
+
+ // Add our scene to the window resize list
+ CubicVR.addResizeable(scene);
+
+ // Start our main drawing loop, it provides a timer and the gl context as parameters
+ CubicVR.MainLoop(function(timer, gl) {
+ scene.render();
+ });
+ }
+ </script>
+ </head>
+
+ <body onLoad="CubicVR.start('auto',webGLStart);"></body>
+
+</html>
View
113 samples/basic/cube_viewcontrol.html
@@ -1,60 +1,57 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<!DOCTYPE html>
<html>
-
- <head>
- <title>
- CubicVR.js: Basic Texured Cube /w Scene and MouseViewController
- </title>
- <script src="../../CubicVR.js" type="text/javascript">
- </script>
- <script type='text/javascript'>
- function webGLStart(gl,canvas) {
- // Add a box to mesh, size 1.0, apply material and UV parameters
- var boxMesh = new CubicVR.Mesh({
- primitive: {
- type: "box",
- size: 1.0,
- material: {
- textures: {
- color: "../images/6583-diffuse.jpg",
- bump: "../images/6583-bump.jpg"
- }
- },
- uv: {
- projectionMode: "cubic",
- scale: [1, 1, 1]
- }
- },
- compile: true
- });
-
- // New scene with our canvas dimensions and default camera with FOV 80
- var scene = new CubicVR.Scene(canvas.width, canvas.height, 80);
-
- // SceneObject container for the mesh
- var boxObject = new CubicVR.SceneObject(boxMesh);
-
- // Add SceneObject containing the mesh to the scene
- scene.bind(boxObject);
-
- // set initial camera position and target
- scene.camera.position = [1, 1, 1];
- scene.camera.target = [0, 0, 0];
-
- // Add our scene to the window resize list
- CubicVR.addResizeable(scene);
-
- // Start our main drawing loop, it provides a timer and the gl context as parameters
- CubicVR.MainLoop(function(timer, gl) {
- scene.render();
- });
-
- // initialize a mouse view controller
- mvc = new CubicVR.MouseViewController(canvas, scene.camera);
+ <head>
+ <title>
+ CubicVR.js: Basic Texured Cube /w Scene and MouseViewController
+ </title>
+ <script src="../../CubicVR.js" type="text/javascript">
+ </script>
+ <script type='text/javascript'>
+ function webGLStart(gl,canvas) {
+ // Add a box to mesh, size 1.0, apply material and UV parameters
+ var boxMesh = new CubicVR.Mesh({
+ primitive: {
+ type: "box",
+ size: 1.0,
+ material: {
+ textures: {
+ color: "../images/6583-diffuse.jpg",
+ bump: "../images/6583-bump.jpg"
+ }
+ },
+ uv: {
+ projectionMode: "cubic",
+ scale: [1, 1, 1]
}
- </script>
- </head>
-
- <body onLoad="CubicVR.start('auto',webGLStart);"></body>
-
-</html>
+ },
+ compile: true
+ });
+
+ // New scene with our canvas dimensions and default camera with FOV 80
+ var scene = new CubicVR.Scene(canvas.width, canvas.height, 80);
+
+ // SceneObject container for the mesh
+ var boxObject = new CubicVR.SceneObject(boxMesh);
+
+ // Add SceneObject containing the mesh to the scene
+ scene.bind(boxObject);
+
+ // set initial camera position and target
+ scene.camera.position = [1, 1, 1];
+ scene.camera.target = [0, 0, 0];
+
+ // Add our scene to the window resize list
+ CubicVR.addResizeable(scene);
+
+ // Start our main drawing loop, it provides a timer and the gl context as parameters
+ CubicVR.MainLoop(function(timer, gl) {
+ scene.render();
+ });
+
+ // initialize a mouse view controller
+ mvc = new CubicVR.MouseViewController(canvas, scene.camera);
+ }
+ </script>
+ </head>
+ <body onLoad="CubicVR.start('auto',webGLStart);"></body>
+</html>
View
255 samples/basic/landscape.html
@@ -1,130 +1,127 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<!DOCTYPE html>
<html>
-
- <head>
- <title>
- CubicVR.js: Basic Landscape with oriented cubes
- </title>
- <script src="../../CubicVR.js" type="text/javascript">
- </script>
- <script type='text/javascript'>
- // Note: this example's landscape setup code will be deprecated soon in favor of
- // an object constructor and proper SceneObject container, it stands as an example
- // of using the landscape's orient and height functions
- function webGLStart(gl,canvas) {
- // Add a box to mesh, size 1.0, apply material and UV parameters
- var boxMesh = new CubicVR.Mesh({
- primitive: {
- type: "box",
- size: 1.0,
- material: {
- textures: {
- color: "../images/6583-diffuse.jpg"
- }
- },
- uvmapper: {
- projectionMode: "cubic",
- scale: [1, 1, 1]
- }
- },
- compile:true
- });
-
- // Generate a grass material for the landscape
- var landscapeMaterial = new CubicVR.Material({
- textures: {
- color: "../images/grass.jpg"
- }
- });
-
- // Generate a planar UVMapper for the landscape material.
- var landscapeUV = new CubicVR.UVMapper({
- projectionMode: "planar",
- projectionAxis: "y",
- scale: [1, 1, 1]
- });
-
- // Generate a size 400 landscape with 92 divisions in the X and Z axis, apply landscapeMaterial to faces.
- var landscape = new CubicVR.Landscape(200,92,92,landscapeMaterial);
-
- landscape.mapGen(function(x,z) {
- return 2.0*Math.sin(x/4.0)+2.0*Math.cos(z/5.0)-4.0;
- });
-
- // Apply the UVMapper coordinates to the landscape
- landscapeUV.apply(landscape.getMesh(),landscapeMaterial);
-
- // Compile the heightfield mesh and prepare it for rendering, pass false to keep mesh data for landscape mapping
- landscape.getMesh().prepare(false);
-
-
- // New scene with our canvas dimensions and default camera with FOV 80
- var scene = new CubicVR.Scene(canvas.width, canvas.height, 80);
-
- // Bind the landscape to the scene
- scene.bindSceneObject(landscape);
-
- // set initial camera position and target
- scene.camera.position = [10, 10, 10];
- scene.camera.target = [0, 0, 0];
-
- // Add a point light
- var light = new CubicVR.Light({
- type:"point",
- position: [0,20,0],
- distance: 100
- });
-
- scene.bind(light);
-
-
- // generate some boxes for the landscape
- var boxes = [];
- var num_boxes = 64;
-
- for (var i = 0; i < num_boxes; i++) {
- // SceneObject container for the mesh
- boxes[i] = new CubicVR.SceneObject(boxMesh);
- // Add SceneObject containing the mesh to the scene
- boxes[i].scale=[1+Math.random()*4.0,1+Math.random()*4.0,1+Math.random()*4.0];
- scene.bind(boxes[i]);
- }
-
- // Add our scene to the window resize list
- CubicVR.addResizeable(scene);
-
- // Start our main drawing loop, it provides a timer and the gl context as parameters
- CubicVR.MainLoop(function(timer, gl) {
-
- // input seed for box positions
- var t = 1000+timer.getSeconds()/100.0;
-
- for (i = 0; i < num_boxes; i++) {
-
- var boxObject = boxes[i];
-
- // use a simple deterministic position for each box
- boxObject.position[0] = 50*Math.sin(t*(1.5+(0.33*i)));
- boxObject.position[2] = 50*Math.cos(t*(2.1+(0.29*i)));
-
- // query the orientation for the current box X/Z position and X/Z scale
- var orientval = landscape.orient(boxObject.position[0],boxObject.position[2],boxObject.scale[0],boxObject.scale[2],0);
- // use the results to set the orientation
- boxObject.position = orientval[0];
- boxObject.rotation = orientval[1];
- // push the box out of the ground so it rests on it's base (1/2 height)
- boxObject.position[1] += boxObject.scale[1]/2.0;
- }
-
- scene.render();
- });
-
- // initialize a mouse view controller
- var mvc = new CubicVR.MouseViewController(canvas, scene.camera);
- }
- </script>
- </head>
-
- <body onLoad="CubicVR.start('auto',webGLStart);"></body>
-
-</html>
+ <head>
+ <title>
+ CubicVR.js: Basic Landscape with oriented cubes
+ </title>
+ <script src="../../CubicVR.js" type="text/javascript">
+ </script>
+ <script type='text/javascript'>
+ // Note: this example's landscape setup code will be deprecated soon in favor of
+ // an object constructor and proper SceneObject container, it stands as an example
+ // of using the landscape's orient and height functions
+ function webGLStart(gl,canvas) {
+ // Add a box to mesh, size 1.0, apply material and UV parameters
+ var boxMesh = new CubicVR.Mesh({
+ primitive: {
+ type: "box",
+ size: 1.0,
+ material: {
+ textures: {
+ color: "../images/6583-diffuse.jpg"
+ }
+ },
+ uvmapper: {
+ projectionMode: "cubic",
+ scale: [1, 1, 1]
+ }
+ },
+ compile:true
+ });
+
+ // Generate a grass material for the landscape
+ var landscapeMaterial = new CubicVR.Material({
+ textures: {
+ color: "../images/grass.jpg"
+ }
+ });
+
+ // Generate a planar UVMapper for the landscape material.
+ var landscapeUV = new CubicVR.UVMapper({
+ projectionMode: "planar",
+ projectionAxis: "y",
+ scale: [1, 1, 1]
+ });
+
+ // Generate a size 400 landscape with 92 divisions in the X and Z axis, apply landscapeMaterial to faces.
+ var landscape = new CubicVR.Landscape(200,92,92,landscapeMaterial);
+
+ landscape.mapGen(function(x,z) {
+ return 2.0*Math.sin(x/4.0)+2.0*Math.cos(z/5.0)-4.0;
+ });
+
+ // Apply the UVMapper coordinates to the landscape
+ landscapeUV.apply(landscape.getMesh(),landscapeMaterial);
+
+ // Compile the heightfield mesh and prepare it for rendering, pass false to keep mesh data for landscape mapping
+ landscape.getMesh().prepare(false);
+
+
+ // New scene with our canvas dimensions and default camera with FOV 80
+ var scene = new CubicVR.Scene(canvas.width, canvas.height, 80);
+
+ // Bind the landscape to the scene
+ scene.bindSceneObject(landscape);
+
+ // set initial camera position and target
+ scene.camera.position = [10, 10, 10];
+ scene.camera.target = [0, 0, 0];
+
+ // Add a point light
+ var light = new CubicVR.Light({
+ type:"point",
+ position: [0,20,0],
+ distance: 100
+ });
+
+ scene.bind(light);
+
+
+ // generate some boxes for the landscape
+ var boxes = [];
+ var num_boxes = 64;
+
+ for (var i = 0; i < num_boxes; i++) {
+ // SceneObject container for the mesh
+ boxes[i] = new CubicVR.SceneObject(boxMesh);
+ // Add SceneObject containing the mesh to the scene
+ boxes[i].scale=[1+Math.random()*4.0,1+Math.random()*4.0,1+Math.random()*4.0];
+ scene.bind(boxes[i]);
+ }
+
+ // Add our scene to the window resize list
+ CubicVR.addResizeable(scene);
+
+ // Start our main drawing loop, it provides a timer and the gl context as parameters
+ CubicVR.MainLoop(function(timer, gl) {
+
+ // input seed for box positions
+ var t = 1000+timer.getSeconds()/100.0;
+
+ for (i = 0; i < num_boxes; i++) {
+
+ var boxObject = boxes[i];
+
+ // use a simple deterministic position for each box
+ boxObject.position[0] = 50*Math.sin(t*(1.5+(0.33*i)));
+ boxObject.position[2] = 50*Math.cos(t*(2.1+(0.29*i)));
+
+ // query the orientation for the current box X/Z position and X/Z scale
+ var orientval = landscape.orient(boxObject.position[0],boxObject.position[2],boxObject.scale[0],boxObject.scale[2],0);
+ // use the results to set the orientation
+ boxObject.position = orientval[0];
+ boxObject.rotation = orientval[1];
+ // push the box out of the ground so it rests on it's base (1/2 height)
+ boxObject.position[1] += boxObject.scale[1]/2.0;
+ }
+
+ scene.render();
+ });
+
+ // initialize a mouse view controller
+ var mvc = new CubicVR.MouseViewController(canvas, scene.camera);
+ }
+ </script>
+ </head>
+ <body onLoad="CubicVR.start('auto',webGLStart);"></body>
+</html>
View
145 samples/basic/lathe_torus.html
@@ -1,76 +1,75 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<!DOCTYPE html>
<html>
-
- <head>
- <title>
- CubicVR.js: Lathe test - Torus /w Scene and MouseViewController
- </title>
- <script src="../../CubicVR.js" type="text/javascript">
- </script>
- <script type='text/javascript'>
- // Simple torus using lathe
-
-
- function makeTorus(radius, thick, lat) {
- var pointList = new Array();
-
- var M_TWO_PI = Math.PI * 2.0;
-
- // generate a circle on the right side (radius) of the X/Y axis, circle radius of (thick)
- for (var i = 0; i <= M_TWO_PI; i += (M_TWO_PI / lat)) {
- pointList.push([radius + Math.cos(i) * thick, Math.sin(i) * thick, 0]);
- }
-
- var torusMesh = new CubicVR.Mesh({
- primitive: {
- type: "lathe",
- divisions: lat,
- points: pointList,
- material: {
- textures: {
- color: new CubicVR.Texture("../images/2062-diffuse.jpg")
- }
- },
- uv: {
- projectionMode: "planar",
- projectionAxis: "y",
- scale: [0.5, 0.5, 0.5]
- }
- },
- compile: true
- });
-
- return torusMesh;
+ <head>
+ <title>
+ CubicVR.js: Lathe test - Torus /w Scene and MouseViewController
+ </title>
+ <script src="../../CubicVR.js" type="text/javascript">
+ </script>
+ <script type='text/javascript'>
+ // Simple torus using lathe
+
+
+ function makeTorus(radius, thick, lat) {
+ var pointList = new Array();
+
+ var M_TWO_PI = Math.PI * 2.0;
+
+ // generate a circle on the right side (radius) of the X/Y axis, circle radius of (thick)
+ for (var i = 0; i <= M_TWO_PI; i += (M_TWO_PI / lat)) {
+ pointList.push([radius + Math.cos(i) * thick, Math.sin(i) * thick, 0]);
+ }
+
+ var torusMesh = new CubicVR.Mesh({
+ primitive: {
+ type: "lathe",
+ divisions: lat,
+ points: pointList,
+ material: {
+ textures: {
+ color: new CubicVR.Texture("../images/2062-diffuse.jpg")
+ }
+ },
+ uv: {
+ projectionMode: "planar",
+ projectionAxis: "y",
+ scale: [0.5, 0.5, 0.5]
}
-
- function webGLStart(gl,canvas) {
- // New scene with our canvas dimensions and default camera with FOV 80
- var scene = new CubicVR.Scene(canvas.width, canvas.height, 80);
-
- // SceneObject container for the mesh
- var sceneObj = new CubicVR.SceneObject(makeTorus(0.75, 0.3, 24));
-
- // Add SceneObject containing the mesh to the scene
- scene.bind(sceneObj);
-
- // set initial camera position and target
- scene.camera.position = [1, 1, 1];
- scene.camera.target = [0, 0, 0];
-
- // Add our scene to the window resize list
- CubicVR.addResizeable(scene);
-
- // Start our main drawing loop, it provides a timer and the gl context as parameters
- CubicVR.MainLoop(function(timer, gl) {
- scene.render();
- });
-
- // initialize a mouse view controller
- mvc = new CubicVR.MouseViewController(canvas, scene.camera);
- }
- </script>
- </head>
-
- <body onLoad="CubicVR.start('auto',webGLStart);"></body>
-
+ },
+ compile: true
+ });
+
+ return torusMesh;
+ }
+
+ function webGLStart(gl,canvas) {
+ // New scene with our canvas dimensions and default camera with FOV 80
+ var scene = new CubicVR.Scene(canvas.width, canvas.height, 80);
+
+ // SceneObject container for the mesh
+ var sceneObj = new CubicVR.SceneObject(makeTorus(0.75, 0.3, 24));
+
+ // Add SceneObject containing the mesh to the scene
+ scene.bind(sceneObj);
+
+ // set initial camera position and target
+ scene.camera.position = [1, 1, 1];
+ scene.camera.target = [0, 0, 0];
+
+ // Add our scene to the window resize list
+ CubicVR.addResizeable(scene);
+
+ // Start our main drawing loop, it provides a timer and the gl context as parameters
+ CubicVR.MainLoop(function(timer, gl) {
+ scene.render();
+ });
+
+ // initialize a mouse view controller
+ mvc = new CubicVR.MouseViewController(canvas, scene.camera);
+ }
+ </script>
+ </head>
+
+ <body onLoad="CubicVR.start('auto',webGLStart);"></body>
+
</html>
View
213 samples/basic/material_instances.html
@@ -1,110 +1,107 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<!DOCTYPE html>
<html>
-
- <head>
- <title>
- CubicVR.js: Basic Primitives /w Scene, MouseViewController and Advanced Materials
- </title>
- <script src="../../CubicVR.js" type="text/javascript">
- </script>
- <script type='text/javascript'>
- function webGLStart(gl,canvas) {
- // New scene with our canvas dimensions and default camera with FOV 80
- var scene = new CubicVR.Scene(canvas.width, canvas.height, 80);
- var light = new CubicVR.Light({
- type: "point",
- method: "dynamic",
- diffuse:[1,1,1],
- specular:[1,1,1],
- position:[0,5,-2],
- distance:20
- });
-
- scene.bind(light);
-
- var boxMesh = new CubicVR.Mesh({
- primitive: {
- type: "box",
- size: 1.0,
- material: {
- name: "boxMaterial",
- specular:[1,1,1],
- shininess: 0.9,
- env_amount: 1.0,
- textures: {
- color: "../images/2576-diffuse.jpg",
- normal: "../images/2576-normal.jpg",
- bump: "../images/2576-bump.jpg",
- envsphere: "../images/fract_reflections.jpg"
- }
- },
- uvmapper: {
- projectionMode: "cubic",
- scale: [0.5, 0.5, 0.5]
- }
- },
- compile:true
- });
-
- // Add SceneObjects
- var sceneObjs = [
- new CubicVR.SceneObject({mesh:boxMesh, position:[-1.5,0,-1]}),
- new CubicVR.SceneObject({mesh:boxMesh, position:[0,0,-1]}),
- new CubicVR.SceneObject({mesh:boxMesh, position:[1.5,0,-1]}),
- new CubicVR.SceneObject({mesh:boxMesh, position:[-1.5,0,1]}),
- new CubicVR.SceneObject({mesh:boxMesh, position:[0,0,1]}),
- new CubicVR.SceneObject({mesh:boxMesh, position:[1.5,0,1]})
- ];
-
-/* // Optionally retrieve array and use index
-
- sceneObjs[0].getInstanceMaterials()[0].color = [1,0,0];
- sceneObjs[1].getInstanceMaterials()[0].color = [0,1,0];
- sceneObjs[2].getInstanceMaterials()[0].color = [0,0,1];
- sceneObjs[3].getInstanceMaterials()[0].color = [1,1,0];
- sceneObjs[4].getInstanceMaterials()[0].color = [1,0,1];
- sceneObjs[5].getInstanceMaterials()[0].color = [0,1,1];
-*/
-
- sceneObjs[0].getInstanceMaterial("boxMaterial").color = [1,0,0];
- sceneObjs[1].getInstanceMaterial("boxMaterial").color = [0,1,0];
- sceneObjs[2].getInstanceMaterial("boxMaterial").color = [0,0,1];
- sceneObjs[3].getInstanceMaterial("boxMaterial").color = [1,1,0];
- sceneObjs[4].getInstanceMaterial("boxMaterial").color = [1,0,1];
- sceneObjs[5].getInstanceMaterial("boxMaterial").color = [0,1,1];
-
-
- for (var i = 0; i < sceneObjs.length; i++) {
- scene.bind(sceneObjs[i]);
- }
-
-
- // set initial camera position and target
- scene.camera.position = [0, 2, 2];
- scene.camera.target = [0, 0, 0];
-
- // initialize a mouse view controller
- mvc = new CubicVR.MouseViewController(canvas, scene.camera);
-
- // Add our scene to the window resize list
- CubicVR.addResizeable(scene);
-
- // Start our main drawing loop, it provides a timer and the gl context as parameters
- CubicVR.MainLoop(function(timer, gl) {
- var lus = timer.getLastUpdateSeconds();
-
- for (var i = 0; i < scene.sceneObjects.length; i++) {
- scene.sceneObjects[i].rotation[0] += lus*2.0+0.1*(i+1);
- scene.sceneObjects[i].rotation[2] += lus*2.5+0.2*(i+1);
- }
-
- scene.render();
- });
-
+ <head>
+ <title>
+ CubicVR.js: Basic Primitives /w Scene, MouseViewController and Advanced Materials
+ </title>
+ <script src="../../CubicVR.js" type="text/javascript">
+ </script>
+ <script type='text/javascript'>
+ function webGLStart(gl,canvas) {
+ // New scene with our canvas dimensions and default camera with FOV 80
+ var scene = new CubicVR.Scene(canvas.width, canvas.height, 80);
+ var light = new CubicVR.Light({
+ type: "point",
+ method: "dynamic",
+ diffuse:[1,1,1],
+ specular:[1,1,1],
+ position:[0,5,-2],
+ distance:20
+ });
+
+ scene.bind(light);
+
+ var boxMesh = new CubicVR.Mesh({
+ primitive: {
+ type: "box",
+ size: 1.0,
+ material: {
+ name: "boxMaterial",
+ specular:[1,1,1],
+ shininess: 0.9,
+ env_amount: 1.0,
+ textures: {
+ color: "../images/2576-diffuse.jpg",
+ normal: "../images/2576-normal.jpg",
+ bump: "../images/2576-bump.jpg",
+ envsphere: "../images/fract_reflections.jpg"
+ }
+ },
+ uvmapper: {
+ projectionMode: "cubic",
+ scale: [0.5, 0.5, 0.5]
}
- </script>
- </head>
-
- <body onLoad="CubicVR.start('auto',webGLStart);"></body>
-
-</html>
+ },
+ compile:true
+ });
+
+ // Add SceneObjects
+ var sceneObjs = [
+ new CubicVR.SceneObject({mesh:boxMesh, position:[-1.5,0,-1]}),
+ new CubicVR.SceneObject({mesh:boxMesh, position:[0,0,-1]}),
+ new CubicVR.SceneObject({mesh:boxMesh, position:[1.5,0,-1]}),
+ new CubicVR.SceneObject({mesh:boxMesh, position:[-1.5,0,1]}),
+ new CubicVR.SceneObject({mesh:boxMesh, position:[0,0,1]}),
+ new CubicVR.SceneObject({mesh:boxMesh, position:[1.5,0,1]})
+ ];
+
+ /* // Optionally retrieve array and use index
+
+ sceneObjs[0].getInstanceMaterials()[0].color = [1,0,0];
+ sceneObjs[1].getInstanceMaterials()[0].color = [0,1,0];
+ sceneObjs[2].getInstanceMaterials()[0].color = [0,0,1];
+ sceneObjs[3].getInstanceMaterials()[0].color = [1,1,0];
+ sceneObjs[4].getInstanceMaterials()[0].color = [1,0,1];
+ sceneObjs[5].getInstanceMaterials()[0].color = [0,1,1];
+ */
+
+ sceneObjs[0].getInstanceMaterial("boxMaterial").color = [1,0,0];
+ sceneObjs[1].getInstanceMaterial("boxMaterial").color = [0,1,0];
+ sceneObjs[2].getInstanceMaterial("boxMaterial").color = [0,0,1];
+ sceneObjs[3].getInstanceMaterial("boxMaterial").color = [1,1,0];
+ sceneObjs[4].getInstanceMaterial("boxMaterial").color = [1,0,1];
+ sceneObjs[5].getInstanceMaterial("boxMaterial").color = [0,1,1];
+
+
+ for (var i = 0; i < sceneObjs.length; i++) {
+ scene.bind(sceneObjs[i]);
+ }
+
+
+ // set initial camera position and target
+ scene.camera.position = [0, 2, 2];
+ scene.camera.target = [0, 0, 0];
+
+ // initialize a mouse view controller
+ mvc = new CubicVR.MouseViewController(canvas, scene.camera);
+
+ // Add our scene to the window resize list
+ CubicVR.addResizeable(scene);
+
+ // Start our main drawing loop, it provides a timer and the gl context as parameters
+ CubicVR.MainLoop(function(timer, gl) {
+ var lus = timer.getLastUpdateSeconds();
+
+ for (var i = 0; i < scene.sceneObjects.length; i++) {
+ scene.sceneObjects[i].rotation[0] += lus*2.0+0.1*(i+1);
+ scene.sceneObjects[i].rotation[2] += lus*2.5+0.2*(i+1);
+ }
+
+ scene.render();
+ });
+
+ }
+ </script>
+ </head>
+ <body onLoad="CubicVR.start('auto',webGLStart);"></body>
+</html>
View
369 samples/basic/material_uvoffset.html
@@ -1,187 +1,184 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<!DOCTYPE html>
<html>
-
- <head>
- <title>
- CubicVR.js: Basic Primitives /w Scene, MouseViewController and Advanced Materials
- </title>
- <script src="../../CubicVR.js" type="text/javascript">
- </script>
- <script type='text/javascript'>
- function webGLStart(gl,canvas) {
- // New scene with our canvas dimensions and default camera with FOV 80
- var scene = new CubicVR.Scene(canvas.width, canvas.height, 80);
- var light = new CubicVR.Light({
- type: "point",
- method: "dynamic",
- diffuse:[1,1,1],
- specular:[1,1,1],
- position:[0,5,-2],
- distance:20
- });
-
- scene.bind(light);
-
- // Create a material for the mesh
- var material1 = new CubicVR.Material({
- color: [80/255, 200/255, 120/255],
- specular:[1,1,1],
- shininess: 0.9,
- env_amount: 1.0,
- textures: {
- color: "../images/2576-diffuse.jpg",
- normal: "../images/2576-normal.jpg",
- bump: "../images/2576-bump.jpg",
- envsphere: "../images/fract_reflections.jpg"
- }
- });
-
- var material2 = new CubicVR.Material({
- specular:[1,1,1],
- color: [224/255, 17/255, 95/255],
- shininess: 0.9,
- env_amount: 1.0,
- textures: {
- color: "../images/2282-diffuse.jpg",
- normal: "../images/2282-normal.jpg",
- bump: "../images/2282-bump.jpg",
- envsphere: "../images/fract_reflections.jpg"
- }
- });
-
-
- var material3 = new CubicVR.Material({
- specular:[1,1,1],
- color: [197/255, 179/255, 88/255],
- shininess: 0.9,
- env_amount: 1.0,
- textures: {
- color: "../images/6583-diffuse.jpg",
- normal: "../images/6583-normal.jpg",
- bump: "../images/6583-bump.jpg",
- envsphere: "../images/fract_reflections.jpg"
- }
- });
-
-
- var uvplanar = {
- projectionMode: "planar",
- projectionAxis: "y",
- scale: [0.5, 0.5, 0.5]
- };
-
- var uvplane = {
- projectionMode: "planar",
- projectionAxis: "z",
- scale: [0.5, 0.5, 0.5]
- };
-
- var uvcubic = {
- projectionMode: "cubic",
- scale: [0.5, 0.5, 0.5]
- };
-
- var torusMesh = new CubicVR.Mesh({
- primitive: {
- type: "torus",
- innerRadius: 0.5,
- outerRadius: 0.75,
- lat: 24,
- lon: 24,
- material: material1,
- uvmapper: uvplanar,
- },
- compile: true
- });
-
- var planeMesh = new CubicVR.Mesh({
- primitive: {
- type: "plane",
- size: 1.0,
- material: material2,
- uvmapper: uvplane
- },
- compile: true
- });
-
- var boxMesh = new CubicVR.Mesh({
- primitive: {
- type: "box",
- size: 1.0,
- material: material3,
- uvmapper: uvcubic
- },
- compile: true
- });
-
- var sphereMesh = new CubicVR.Mesh({
- primitive: {
- type: "sphere",
- radius: 0.5,
- lat: 24,
- lon: 24,
- material: material3,
- uvmapper: uvcubic
- },
- compile: true
- });
-
- var coneMesh = new CubicVR.Mesh({
- primitive: {
- type: "cone",
- base: 1.0,
- material: material2,
- uvmapper: uvcubic
- },
- compile: true
- });
-
- var cylinderMesh = new CubicVR.Mesh({
- primitive: {
- type: "cylinder",
- radius: 0.5,
- height: 1.0,
- lon: 24,
- material: material1,
- uvmapper: uvcubic
- },
- compile: true
- });
-
-
- // Add SceneObjects
- scene.bind(new CubicVR.SceneObject({mesh:torusMesh, position:[-1.5,0,-1]}),true);
- scene.bind(new CubicVR.SceneObject({mesh:planeMesh, position:[0,0,-1]}),true);
- scene.bind(new CubicVR.SceneObject({mesh:boxMesh, position:[1.5,0,-1]}),true);
- scene.bind(new CubicVR.SceneObject({mesh:sphereMesh, position:[-1.5,0,1]}),true);
- scene.bind(new CubicVR.SceneObject({mesh:coneMesh, position:[0,0,1]}),true);
- scene.bind(new CubicVR.SceneObject({mesh:cylinderMesh, position:[1.5,0,1]}),true);
- // set initial camera position and target
- scene.camera.position = [0, 2, 2];